Sync MySQL to Elasticsearch in Minutes with DBSyncer and Docker
This guide introduces the open‑source DBSyncer tool, explains its key features, shows how to install it via Docker, and provides a step‑by‑step example of synchronizing a MySQL product table to an Elasticsearch index, including configuration, field mapping, and verification.
Introduction
DBSyncer is an open‑source visual data‑synchronization tool that supports MySQL, Oracle, PostgreSQL, Elasticsearch, Kafka, files and other scenarios. It has more than 3.1k stars on Gitee.
Features
Combination driver: custom source‑to‑target sync, e.g., MySQL → ES.
Real‑time monitoring: full and incremental sync with status, result, sync logs and system logs.
Plugin development: write code to customize transformation logic.
Installation
Docker provides the easiest way to run DBSyncer.
docker pull registry.cn-hangzhou.aliyuncs.com/xhtb/dbsyncer:latest docker run -p 18686:18686 --name=db-syncer \
-e "TZ=Asia/Shanghai" \
-v /mydata/db-syncer/data:/app/dbsyncer/data \
-v /mydata/db-syncer/plugins:/app/dbsyncer/plugins \
-d registry.cn-hangzhou.aliyuncs.com/xhtb/dbsyncer:latestAfter the container starts, the web console is available at http://<host>:18686 with default credentials admin:admin.
Usage Example: Sync MySQL product table to Elasticsearch
This example demonstrates syncing a simplified product table from a development database to a test database and then to an ES index.
Create two MySQL databases mall_dev and mall_test. Add both connections in DBSyncer, then create a driver that maps the source to the target.
Define the field mapping (select all fields for a full sync) and start the driver.
MySQL → Elasticsearch
First create the ES index mapping:
PUT /product_index
{
"mappings": {
"properties": {
"id": {"type": "long"},
"title": {"type": "text"},
"sub_title": {"type": "text"},
"pic": {"type": "text"},
"price": {"type": "double"}
}
}
}Add the ES connection in DBSyncer (password optional) and create a driver from MySQL to ES, ensuring the primary key is configured.
Start the driver; upon successful sync the data appears in Elasticsearch and can be queried via Kibana.
Conclusion
DBSyncer provides a visual interface for full‑ and incremental data synchronization between databases and search engines, with extensibility through plugins.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
