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.

macrozheng
macrozheng
macrozheng
Sync MySQL to Elasticsearch in Minutes with DBSyncer and Docker

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:latest

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

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendDockerElasticsearchMySQLData SynchronizationDBSyncer
macrozheng
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.