Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to migrate mysql data to ElasticSearch realtime

I have a mysql database with couple tables, I wanna migrate the mysql data to ElasticSearch. It's easy to migrate the whole database to ES via a batch job. But how should I update ES from mysql realtime. i.e if there was a update operation in mysql then I should do the same operation in ES. I researched mysql binLog which can reflect any changes from mysql. But I have to parse binLog to ES syntax, I think it's really painful. Thanks! (the same case with Solr)

like image 785
Jack Avatar asked Oct 09 '15 00:10

Jack


People also ask

Is Elasticsearch faster than MySQL?

The main difference ElasticSearch from MySQl-search is that ES works faster when large amounts of data through indexing. The index contains ready-made sets of data with which you are operating further ES-filters. So if you search with ES, you haven't to do a direct request to the database, as in MySQL.

Can Elasticsearch replace MySQL?

ES can not replace MySQL, because ES is not a relational database system.


1 Answers

There is an existing project which takes your binlog, transforms it and ships it to Elasticsearch, You can check it out at: https://github.com/siddontang/go-mysql-elasticsearch

Another one would be this one: https://github.com/noplay/python-mysql-replication.

Note, however, that whichever you pick, it's a good practice to pre-create your index and mappings before indexing your binlog. That gives you more control over your data.

UPDATE:

Here is another interesting blog article on the subject: How to keep Elasticsearch synchronized with a relational database using Logstash

like image 86
Val Avatar answered Sep 28 '22 05:09

Val