Skip to main content

MySQL to Elasticsearch sync tool

Project description

# py-mysql-elasticsearch-sync
Simple and fast MySQL to Elasticsearch sync tool, written in Python3.

## 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. Python3
This tool is written in Python3.4, so you must install Python3.4 or above first, by following [this guide](https://docs.python.org/3.4/using/index.html)
##### 2. ibxml2 and libxslt
Also, 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](http://lxml.de/installation.html) for more infomation.
##### 3. mysqldump
And then, mysqldump is required.


##### 4. this tool
Then install this tool

```
pip3 install py-mysql-elasticsearch-sync
```

## Configuration
There is a [sample config](https://github.com/zhongbiaodev/py-mysql-elasticsearch-sync/blob/master/sample.yaml) 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 ```-X```option 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,since we use virtualenv for requirements isolation, you must edit it for your own condition, besides, you can deploy it in your own way.


## TODO
- [ ] MultiIndex Supporting
- [ ] Multi table Supporting
- [ ] Python version compat

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-mysql-elasticsearch-sync-0.3.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_mysql_elasticsearch_sync-0.3.0-py2.py3-none-any.whl (7.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file py-mysql-elasticsearch-sync-0.3.0.tar.gz.

File metadata

File hashes

Hashes for py-mysql-elasticsearch-sync-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ebd8dfc7377f8fb3c96a5027c66e3358f9d8c5f310b5629fba76c55f6c3cf9a7
MD5 2ac412df604fdfa7a7904e31636afe5b
BLAKE2b-256 edc11a533b659548f9c8133b2b8358acfefdc6b8ae7b976ec69d72e1c08ee51d

See more details on using hashes here.

File details

Details for the file py_mysql_elasticsearch_sync-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for py_mysql_elasticsearch_sync-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 83fc1965bd02e55ddbbc8e2b33f8f2aff1f6c034bfa34f08e9eaee33b5d1f211
MD5 4c77aa1fcdcd6d4a570e58d65b6ed0b1
BLAKE2b-256 1bb414cf7b7330e960b28c89a8619e43c2ac60f8dbd415f132b889face4e53b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page