Data Transmission Service (DTS) lets you synchronize data between databases in real time. This topic walks you through configuring a data synchronization task in a DTS dedicated cluster — in this example, from one ApsaraDB RDS for MySQL instance to another.
Common use cases include active geo-redundancy, geo-disaster recovery, zone-disaster recovery, cross-border data synchronization, cloud business intelligence (BI) systems, and real-time data warehousing.
Prerequisites
Before you begin, ensure that you have:
A DTS dedicated cluster. For more information, see Create a DTS dedicated cluster
Source and destination ApsaraDB RDS for MySQL instances created. For more information, see Create an ApsaraDB RDS for MySQL instance
Enough storage space on the destination instance — it must be larger than the total data size of the source instance
The source and destination instances and the DTS dedicated cluster all in the same region
Limitations
Source database requirements
Tables to be synchronized must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination database may contain duplicate records.
If you select tables (not an entire database) and need to rename tables or columns: the limit is 1,000 tables per synchronization task. For more than 1,000 tables, split them across multiple tasks or synchronize the entire database instead.
Binary logging requirements:
Binary logging must be enabled, and
binlog_row_imagemust be set tofull. For details, see Modify the parameters of an ApsaraDB RDS for MySQL instance.ImportantFor self-managed MySQL databases: - Set
binlog_formattorowandbinlog_row_imagetofull. - For dual-primary cluster deployments, setlog_slave_updatestoONto make sure DTS can obtain all binary logs. For more information, see Create an account for a self-managed MySQL database and configure binary logging.For incremental synchronization only: retain binary logs for at least 24 hours.
For both full and incremental synchronization: retain binary logs for at least seven days. After full data synchronization completes, you can set the retention period to more than 24 hours.
If binary log retention requirements are not met, DTS may fail to obtain the required logs, causing task failure, data inconsistency, or data loss. In such cases, the DTS Service Level Agreement (SLA) does not guarantee service reliability or performance. For more information about binary log files, see View and delete the binary log files of an ApsaraDB RDS for MySQL instance.
Schema synchronization behavior
DTS synchronizes foreign keys from the source database to the destination database during schema synchronization.
During full and incremental synchronization, DTS temporarily disables foreign key constraint checks and cascade operations at the session level. Cascade update or delete operations on the source during synchronization may cause data inconsistency.
Other limitations
The destination database version must be the same as or later than the source database version. An older destination version may cause compatibility issues.
Run synchronization during off-peak hours. Initial full data synchronization uses read and write resources on both instances and increases server load.
After initial full data synchronization, the destination tablespace will be larger than the source due to fragmentation from concurrent INSERT operations.
If synchronizing selected tables (not the entire database), do not use tools such as pt-online-schema-change for DDL operations during synchronization — the task will fail. If you need online DDL on source tables, use Data Management (DMS). For more information, see Perform lock-free DDL operations.
Write to the destination database only through DTS during synchronization. Writing through other tools can cause data inconsistency or loss.
Notes for self-managed MySQL databases
A primary/secondary switchover on the source database while the task is running causes the task to fail.
DTS calculates synchronization latency based on the timestamp of the latest synchronized data in the destination and the current timestamp in the source. If no DML operations are performed on the source for an extended period, the displayed latency may be inaccurate. To update the latency reading, perform a DML operation on the source.
If you synchronize an entire database, create a heartbeat table that is updated every second to keep the latency reading accurate.
DTS periodically executes
CREATE DATABASE IF NOT EXISTS 'test'in the source database to advance the binary log file position.
Supported synchronization topologies
One-way one-to-one synchronization
One-way one-to-many synchronization
One-way cascade synchronization
One-way many-to-one synchronization
Two-way one-to-one synchronization
For more information, see Synchronization topologies.
SQL operations that can be synchronized
| Operation type | SQL statements |
|---|---|
| DML | INSERT, UPDATE, DELETE |
| DDL | ALTER TABLE, ALTER VIEW, CREATE FUNCTION, CREATE INDEX, CREATE PROCEDURE, CREATE TABLE, CREATE VIEW, DROP INDEX, DROP TABLE, RENAME TABLE, TRUNCATE TABLE |
DDL statements not listed above are not synchronized.
Configure a data synchronization task
Step 1: Navigate to the dedicated cluster
Go to the Dedicated Cluster page.
In the top navigation bar, select the region where your DTS dedicated cluster resides.
In the Actions column of the DTS dedicated cluster, choose Configure Task > Configure Data Synchronization Task.
Step 2: Configure source and destination databases
After configuring the source and destination databases, read the limitations displayed at the top of the page before proceeding. Skipping this step may cause task failure or data inconsistency.
General
| Parameter | Description |
|---|---|
| Task Name | DTS generates a name automatically. Specify a descriptive name based on your business requirements. The name does not need to be unique. |
Source Database
| Parameter | Description |
|---|---|
| Select an existing database connection (Optional) | Select an existing connection to reuse its settings. If no connection exists, configure the parameters below manually. |
| Database Type | Select MySQL. |
| Connection Type | Select Alibaba Cloud Instance. |
| Instance Region | The region is set when you create the dedicated cluster and cannot be changed. |
| Replicate Data Across Alibaba Cloud Accounts | Select No for this example. |
| RDS Instance ID | The ID of the source ApsaraDB RDS for MySQL instance. The source and destination instances can be the same or different — DTS supports synchronization between two instances or within a single instance. |
| Database Account | A database account with read permissions on the objects to be synchronized. |
| Database Password | The password of the database account. |
| Encryption | Select Non-encrypted or SSL-encrypted. If you select SSL-encrypted, enable SSL encryption on the instance before configuring this task. For more information, see Configure SSL encryption for an ApsaraDB RDS for MySQL instance. |
Destination Database
| Parameter | Description |
|---|---|
| Select an existing database connection (Optional) | Select an existing connection to reuse its settings. If no connection exists, configure the parameters below manually. |
| Database Type | Select MySQL. |
| Connection Type | Select Alibaba Cloud Instance. |
| Instance Region | The region of the destination ApsaraDB RDS for MySQL instance. |
| RDS Instance ID | The ID of the destination ApsaraDB RDS for MySQL instance. |
| Database Account | A database account with read and write permissions on the destination database. |
| Database Password | The password of the database account. |
| Encryption | Select Non-encrypted or SSL-encrypted. If you select SSL-encrypted, enable SSL encryption on the instance before configuring this task. For more information, see Configure SSL encryption for an ApsaraDB RDS for MySQL instance. |
Step 3: Test connectivity
Click Test Connectivity and Proceed.
DTS automatically handles network access based on your database type:
Alibaba Cloud database instances (such as ApsaraDB RDS for MySQL or ApsaraDB for MongoDB): DTS adds its server CIDR blocks to the instance whitelist automatically.
Self-managed databases on Elastic Compute Service (ECS): DTS adds its server CIDR blocks to the ECS security group rules. Make sure the ECS instance can reach the database.
On-premises or third-party cloud databases: Manually add the DTS server CIDR blocks to the database whitelist. For more information, see Add the CIDR blocks of DTS servers to the security settings of on-premises databases.
Adding DTS CIDR blocks to your whitelist or security group rules introduces potential security risks. Before proceeding, take preventive measures such as strengthening username and password security, limiting exposed ports, authenticating API calls, and regularly auditing whitelist or security group rules. For higher security requirements, connect your database to DTS through Express Connect, VPN Gateway, or Smart Access Gateway.
Step 4: Select objects and configure synchronization settings
Choose a synchronization mode
DTS supports three synchronization modes. Select the combination that fits your use case:
Schema synchronization: Synchronizes table schemas (DDL structure) from source to destination.
Full data synchronization: Copies all existing data from source to destination. This is the baseline for subsequent incremental synchronization.
Incremental data synchronization (selected by default): Continuously replicates ongoing data changes after the initial full sync.
For this example, select all three: Schema Synchronization, Full Data Synchronization, and Incremental Data Synchronization.
Synchronization parameters
| Parameter | Description |
|---|---|
| Processing Mode of Conflicting Tables | Precheck and Report Errors (default): The precheck fails if the destination contains tables with the same names as source tables. Use object name mapping to rename synchronized tables if needed. Ignore Errors and Proceed: Skips the name conflict check. During full synchronization, existing destination records with the same primary key are retained. During incremental synchronization, they are overwritten. If schemas differ between source and destination, data initialization may fail or only some columns may be synchronized. Use with caution. |
| Method to Migrate Triggers in Source Database | Select how to synchronize triggers. If no triggers are in scope, skip this parameter. Available only when Schema Synchronization is selected. For more information, see Synchronize or migrate triggers from the source database. |
| Enable Migration Assessment | Select Yes to check whether source and destination schemas (index lengths, stored procedures, dependent tables) meet requirements. Assessment results are visible during the precheck but do not affect precheck pass/fail. Available only when Schema Synchronization is selected. |
| Synchronization Topology | Select One-way Synchronization for this example. |
| Capitalization of Object Names in Destination Instance | Controls the capitalization of database, table, and column names in the destination. DTS default policy is selected by default. For more information, see Specify the capitalization of object names in the destination instance. |
Select objects to synchronize
In the Source Objects section, select the objects to synchronize and click the rightwards arrow icon to move them to the Selected Objects section.
You can select columns, tables, or entire databases. Selecting tables or columns means DTS does not synchronize views, triggers, or stored procedures to the destination.
In the Selected Objects section, you can:
Rename a single object: right-click the object. For more information, see Map the name of a single object.
Rename multiple objects at once: click Batch Edit in the upper-right corner. For more information, see Map multiple object names at a time.
Filter specific SQL operations per object: right-click the object and select the SQL operations to synchronize.
Filter data with WHERE conditions: right-click the object and specify the conditions. For more information, see Use SQL conditions to filter data.
Renaming an object with object name mapping may cause other objects dependent on it to fail synchronization.
Step 5: Configure advanced settings
Click Next: Advanced Settings and configure the following parameters.
Data verification
For information on enabling data verification, see Enable data verification.
Advanced settings
| Parameter | Description |
|---|---|
| Select the dedicated cluster used to schedule the task | Your DTS dedicated cluster is selected by default. |
| Set Alerts | Configure alerting for task failures or latency exceeding a threshold. Select No to skip, or Yes to configure alert thresholds and contacts. For more information, see Configure monitoring and alerting when you create a DTS task. |
| Copy the temporary table of the Online DDL tool that is generated in the source table to the destination database | Controls how DTS handles temporary tables generated by online DDL tools (Data Management (DMS) or gh-ost). Yes: synchronizes temporary table data. Note that large online DDL operations may extend synchronization time significantly. No, Adapt to DMS Online DDL: does not synchronize temporary tables; only the original DDL from DMS is synchronized. Destination tables may be locked during the operation. No, Adapt to gh-ost: does not synchronize temporary tables; only the original DDL from gh-ost is synchronized. Destination tables may be locked. Use default or custom regular expressions to filter shadow tables. Important pt-online-schema-change is not supported — using it causes the DTS task to fail. |
| Whether to Migrate Accounts | Select Yes to synchronize database account information from the source. If selected, choose the accounts to synchronize. Required permissions: the source account needs SELECT on mysql.user, mysql.db, mysql.columns_priv, and mysql.tables_priv. The destination account needs CREATE USER and GRANT OPTION. System accounts (root, mysql.infoschema, mysql.session, mysql.sys) and accounts already in the destination database cannot be synchronized. |
| Method to Migrate Triggers in Source Database | Select a mode for synchronizing triggers. If no triggers are in scope, skip this parameter. For more information, see Synchronize or migrate triggers from the source database. |
| Retry Time for Failed Connection | How long DTS retries when the source or destination database is unreachable after the task starts. Valid values: 10–1,440 minutes. Default: 720 minutes. Set a value greater than 30 minutes. If multiple DTS tasks share the same source or destination database, the shortest retry time among them takes precedence. DTS charges for the instance during retry periods — release the instance promptly if the source or destination instances are no longer needed. |
| The wait time before a retry when other issues occur in the source and destination databases | How long DTS retries when DDL or DML operations fail. Valid values: 1–1,440 minutes. Default: 10 minutes. Set a value greater than 10 minutes. This value must be smaller than Retry Time for Failed Connection. |
Step 6: Run the precheck
Click Next: Save Task Settings and Precheck.
DTS runs a precheck before the task can start. The task launches only after all precheck items pass.
If a precheck item fails: click View Details, troubleshoot the issue, and click Precheck Again.
If an alert is triggered:
If the alert cannot be ignored: click View Details, resolve the issue, and run the precheck again.
If the alert can be ignored: click Confirm Alert Details, then Ignore, then OK, and then Precheck Again.
Ignoring an alert item may result in data inconsistency and exposes your business to potential risks.
Step 7: Start the task
Wait until the precheck success rate reaches 100%, then click Next: Select DTS Instance Type.
In the New Instance Class section, configure the instance class. Set a minimum of 1 DTS unit (DU) up to the number of remaining available DUs.
Read and select the checkbox to agree to the Data Transmission Service (Pay-as-you-go) Service Terms.
Click Start Task, then click OK.
To monitor task progress, go to the cluster details page and click Cluster Task List in the left-side navigation pane.