Git Product home page Git Product logo

py-mysql-elasticsearch-sync's Introduction

py-mysql-elasticsearch-sync

Simple and fast MySQL to Elasticsearch sync tool, written in Python.

中文文档

Introduction

This tool helps you to initialize MySQL dump table to Elasticsearch by parsing mysqldump, then incremental sync MySQL table to Elasticsearch by processing MySQL Binlog. Also, during the binlog syncing, this tool will save the binlog sync position, so that it is easy to recover after this tool being shutdown for any reason.

Installation

By following these steps.

1. ibxml2 and libxslt

This tool depends on python lxml package, so that you should install the lxml's dependecies correctly, the libxml2 and libxslt are required.

For example, in CentOS:

sudo yum install libxml2 libxml2-devel libxslt libxslt-devel

Or in Debian/Ubuntu:

sudo apt-get install libxml2-dev libxslt-dev python-dev

See lxml Installation for more infomation.

2. mysqldump

And then, mysqldump is required in the machine where this tool will be run on it.(and the mysql server must enable binlog)

3. this tool

Then install this tool

pip install py-mysql-elasticsearch-sync

Configuration

There is a sample config file in repo, you can start by editing it.

Running

Simply run command

es-sync path/to/your/config.yaml

and the tool will dump your data as stream to sync, when dump is over, it will start to sync binlog.

The latest synced binlog file and position are recorded in your info file which is configured in your config file. You can restart dump step by remove it, or you can change sync position by edit it.

Or if you but want to load it from your own dumpfile. You should dump your table first as xml format(by adding -Xoption to your mysqldump command)

then

es-sync path/to/your/config.yaml --fromfile

to start sync, when xml sync is over, it will also start binlog sync.

Deployment

We provide an upstart script to help you deploy this tool, you can edit it for your own condition, besides, you can deploy it in your own way.

MultiTable Supporting

Now Multi-table is supported through setting tables in config file, the first table is master as default and the others are slave.

Master table and slave tables must use the same primary key, which is defined via _id.

Table has higher priority than tables.

TODO

  • MultiIndex Supporting

py-mysql-elasticsearch-sync's People

Contributors

windfarer avatar huangweicong112 avatar gogogen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.