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 Python.

[中文文档](https://github.com/zhongbiaodev/py-mysql-elasticsearch-sync/blob/master/README_CN.md)

## 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](http://lxml.de/installation.html) 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](https://github.com/zhongbiaodev/py-mysql-elasticsearch-sync/blob/master/src/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, you can edit it for your own condition, besides, you can deploy it in your own way.

## TODO
- [ ] MultiIndex Supporting
- [ ] Multi table Supporting

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.3.2.tar.gz (11.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.3.2-py2.py3-none-any.whl (12.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for py-mysql-elasticsearch-sync-0.3.3.2.tar.gz
Algorithm Hash digest
SHA256 01aa36bf8983b3e6ab6636fd9ed436b353bcedca46b94393219a6f92af543672
MD5 a3e12f3d88167db51e8eed30ef9af485
BLAKE2b-256 190fc3f268dc42904199b1da1e4622273f61d3fc52a37f7a712b59a758400951

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_mysql_elasticsearch_sync-0.3.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d5e65118b2ba0822412e8357477bb47327a028a607d880e7a2db913b23fb4841
MD5 a8b4f98c128a20f427764b33dd35bfb2
BLAKE2b-256 a4ab2e511e4568fcf6eb2cf566c4e1463ecb2601348cf354480e20191683a818

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