|
|
6 سال پیش | |
|---|---|---|
| logstash | 6 سال پیش | |
| mysql | 6 سال پیش | |
| rdbc | 6 سال پیش | |
| .gitignore | 6 سال پیش | |
| README.md | 6 سال پیش | |
| docker-compose.yml | 6 سال پیش |
This is an example how Elasticsearch can be synchronized with a MySQL database by using Logstash.
The MySQL database stores articles in a table and every time an article gets inserted or updated, Logstash takes care
of that the changes are synchronized to Elasticsearch.
To keep them in sync, Logstash polls the MySQL instance every 5 seconds and checks the articles table for updates.
The articles table has a modifcation_time column and Logstash tracks the last known value to query the updates (see
sync-pipeline.conf).
docker and docker-composedocker-compose up to startup all components (MySQL, Elasticsearch and Logstash).Connect to the MySQL database and insert some articles (schema: blog, username: blog, password: blog).
insert into articles (id, title, content) values ('1','first_title','first_content');
insert into articles (id, title, content) values ('2','second_title','second_content');
insert into articles (id, title, content) values ('3','third_title','third_content');
Query Elasticsearch and see the result.
curl localhost:9200/articles/_search
Insert and update some articles in MySQL and query Elasticsearch afterwards to see the changes.