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.1.tar.gz (7.5 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.1-py2.py3-none-any.whl (7.8 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for py-mysql-elasticsearch-sync-0.3.3.1.tar.gz
Algorithm Hash digest
SHA256 8a23474f728bf20a83a6516f1522a3b861b7e14400d15ab90ce6c888c07ba9b4
MD5 91ac5d579ec7c9c56e7a49b310529bde
BLAKE2b-256 c5f46ec932aac0ab71839389bf0d5c66a68bc35d0d82ffe1aed3804a589d8492

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_mysql_elasticsearch_sync-0.3.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e603da15a0f05db64f549ac20e0599138857b5f852538583f12cc63b0445fd7d
MD5 0b88f54799e02ec0875b7708ef816455
BLAKE2b-256 e0cad4d58828b698eb1bbf65352c05a2ff07a5af9ccaa7e1973aa9bc083b78b6

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