DBSyncer Documentation

repository·master·Indexed 21 days ago

https://github.com/86dbs/dbsyncer

DBSyncer is an open-source data synchronization middleware supporting full and incremental synchronization across relational databases (MySQL, Oracle, SQL Server, PostgreSQL, OceanBase, ClickHouse, H2, Sqlite), non-relational databases (Elasticsearch, Redis), message queues (Kafka), and files. It features combination-driven mapping, real-time monitoring, and customizable logic via plugins. The documentation covers installation via downloadable packages or Docker, building from source, JVM configuration, and API references for configuration parsing using PreloadCommand and PersistenceCommand.

Tokens
4.1K
Snippets
10
Records
18
Agent score
76%

What's inside DBSyncer

  1. Overview of DBSyncer

    master

    DBSyncer is an open-source data synchronization middleware designed to facilitate data movement between various sources and targets. It supports a wide range of scenarios including relational databases (MySQL, Oracle, SQL Server, PostgreSQL), non-relational databases (Elasticsearch, Redis), message queues (Kafka), and files.

    Key features include:

    • Combination Driven: Map relationships between different database types (e.g., relational to non-relational).
    • Real-time Monitoring: Monitor full and incremental synchronization status, results, and logs.
    • Customizable Logic: Upload plugins to implement custom transformation and synchronization logic.
  2. Install DBSyncer via Downloadable Package

    master

    To install DBSyncer using the pre-compiled zip files:

    1. Install JDK 1.8.
    2. Download the installation package (dbsyncer-x.x.x.zip) from the releases page.
    3. Extract the package.
    4. Run the startup script:
      • Windows: Execute bin/startup.bat
      • Linux: Execute bin/startup.sh
    5. Access the web interface at http://127.0.0.1:18686.
    6. Default credentials: admin / admin.
  3. Manage DBSyncer Docker Container

    master

    Once the container is running, use these commands for management:

    Log Management:

    • View local logs (on host): ls -la /opt/dbsyncer/logs
    • View container logs (last 20 lines): docker logs --tail 20 dbsyncer
    • Follow real-time logs: docker logs -f dbsyncer
    • View logs inside the container: ls -la /app/dbsyncer/logs

    Container Control:

    • Enter container shell: docker exec -it dbsyncer /bin/bash
    • Stop container: docker stop dbsyncer
    • Start container: docker start dbsyncer
    • Restart container: docker restart dbsyncer
    • Remove container: docker rm dbsyncer (must stop first)
    # Example: Follow real-time logs
    docker logs -f dbsyncer
    
    # Example: Enter container
    docker exec -it dbsyncer /bin/bash
  4. Install DBSyncer using Docker

    master

    You can run DBSyncer using Docker containers.

    Pull Images

    Community Edition:

    docker pull images.dbsyncer.cn/xhtb-dbs/dbsyncer:latest
    docker pull images.dbsyncer.cn/xhtb-dbs/dbsyncer:2.1.2

    Enterprise Edition:

    docker pull scxhtb-registry.cn-hangzhou.cr.aliyuncs.com/xhtb/dbsyncer-enterprise:latest
    docker pull scxhtb-registry.cn-hangzhou.cr.aliyuncs.com/xhtb/dbsyncer-enterprise:2.1.2

    Run Container

    Use the following command to start the community edition with persistent storage for data, logs, and plugins:

    docker run -d \
      --name=dbsyncer \
      --restart=unless-stopped \
      -p 18686:18686 \
      -e TZ="Asia/Shanghai" \
      -m 5g \
      --memory-swap=5g \
      -v /opt/dbsyncer/data:/app/dbsyncer/data \
      -v /opt/dbsyncer/logs:/app/dbsyncer/logs \
      -v /opt/dbsyncer/plugins:/app/dbsyncer/plugins \
      --log-driver json-file \
      --log-opt max-size=100m \
      --log-opt max-file=7 \
      images.dbsyncer.cn/xhtb-dbs/dbsyncer:latest
  5. Understand DBSyncer Default JVM Configuration

    master

    The startup-docker.sh script applies a specific set of JVM optimizations designed for containerized environments. If you are building a custom image or troubleshooting performance, note the following defaults:

    Memory Management

    • Heap Size: Fixed at 2GB (-Xms2g -Xmx2g) to prevent unbounded growth.
    • Stack Size: -Xss512k.
    • Metaspace: Starts at 256MB, maxes at 384MB.
    • Direct Memory: Limited to 256MB (-XX:MaxDirectMemorySize=256m) to control NIO usage.

    Garbage Collection (GC)

    • Collector: Uses G1GC (-XX:+UseG1GC).
    • G1 Region Size: 16m.
    • Max Pause Target: 200ms.

    Error Handling & Logging

    • Heap Dumps: Enabled on OutOfMemoryError. Dumps are saved to $DBS_HOME/logs/heapdump.hprof.
    • Error Logs: JVM error logs are saved to $DBS_HOME/logs/hs_err_pid_%p.log.
    • Encoding: Forced to UTF-8 for both stdout and file encoding.

    System Properties

    • spring.config.location: Points to $DBS_HOME/conf/application.properties.
    • LOG_HOME: Points to $DBS_HOME/logs.
  6. Start the DBSyncer application via startup.sh

    master

    The startup.sh script is used to launch the DBSyncer application in the background. It automatically handles directory creation for conf and logs, verifies the existence of the configuration file, and manages JVM parameters.

    Prerequisites

    • Configuration File: You must have a valid configuration file located at $DBS_HOME/conf/application.properties before running the script.
    • JRE/JDK: A Java runtime must be installed. The script requires access to the JRE lib/ext directory (specifically for JCE/SSL support). If the script cannot find it, you may need to set the JAVA_HOME environment variable.
    • OS Support: The script supports linux-gnu (x86_64 and aarch64) and darwin (macOS).

    Execution

    Run the script from the bin directory:

    ./startup.sh

    Post-Startup

    • PID Tracking: The process ID (PID) of the running application is saved to $DBS_HOME/tmp.pid.
    • Logs: Detailed application output and error logs are stored in the $DBS_HOME/logs directory.
    • Verification: If the application is already running, the script will exit with an error message indicating the existing PID.
    #!/bin/bash
    ./startup.sh
  7. Start DBSyncer on Windows using startup.bat

    master

    To start the DBSyncer application on a Windows environment, execute the startup.bat script located in the bin directory. This script configures the necessary environment variables, JVM memory settings, and system properties required for the application to run correctly.

    Prerequisites

    • Java JDK 8: You must have JDK 8 installed.
    • JAVA_HOME: The JAVA_HOME environment variable must be set and point to your JDK 8 installation directory.

    Execution

    Open a command prompt, navigate to the directory containing startup.bat, and run:

    startup.bat
  8. Troubleshoot Common Connection Issues

    master

    If you encounter connection errors, check the following known issues:

    • MySQL Connection Failure: The default driver version is 8.0.21. If you are using MySQL 5.x, you must manually replace the driver with mysql-connector-java-5.1.40.jar.
    • SQL Server SSL/TLS Errors: If you see errors regarding TLS protocol versions (e.g., The server selected protocol version TLS10 is not accepted by client preferences [TLS12]), check your driver and SSL configuration.
    • Data Encoding/Garbled Text: If data becomes garbled (e.g., importing MySQL 8 tables to SQL Server 2008R2 nvarchar fields), verify character set settings between source and target.
  9. Configure DBSyncer via Environment Variables

    master

    When running DBSyncer in a Docker or containerized environment using the startup-docker.sh script, you can extend the default JVM configuration using the JAVA_OPTS_EXT environment variable. This is useful for overriding memory limits or adding specific performance tuning parameters.

    Supported Environment Variables:

    • JAVA_OPTS_EXT: A space-separated string of additional JVM arguments (e.g., -Xmx3500m -XX:MaxDirectMemorySize=512m).
    export JAVA_OPTS_EXT="-Xmx3500m -XX:MaxDirectMemorySize=512m"
  10. Supported Connectors and Versions

    master

    DBSyncer supports the following connectors and version ranges:

    ConnectorSourceTargetSupported Versions
    MySQL5.7.19+
    OceanBase3.x+
    Oracle10g-19c
    SqlServer2008+
    PostgreSQL9.5.25+
    ClickHouse22.x+
    H22.2.x
    Sqlite2+
    RedisSource (CDC): 5.x-7.x; Target: 2.6+
    ES6.0.0-8.15.3
    Kafka2.10-0.9.0.0+
    File*.txt, *.unl
    Http
    SQLSupports relational DBs above

    Planned support: Doris, Kingbase