Data Transmission Service (DTS) synchronizes data from a source ApsaraDB RDS for MySQL instance to a destination instance in three sequential phases: schema synchronization, full data synchronization, and incremental data synchronization. Use this guide to configure the task end-to-end.
Prerequisites
Before you begin, make sure that you have:
-
A source ApsaraDB RDS for MySQL instance in normal status
-
A destination ApsaraDB RDS for MySQL instance with available storage larger than the total data size of the source instance. See Create an ApsaraDB RDS for MySQL instance
Billing
| Synchronization type | Fee |
|---|---|
| Schema synchronization and full data synchronization | Free |
| Incremental data synchronization | Charged. See Billing overview |
Supported SQL operations
| 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 |
RENAME TABLE can cause data inconsistency. If you rename a synchronized table during the task, data from that table stops syncing to the destination. To avoid this, select the database (not individual tables) as the sync object, and make sure both the pre-rename and post-rename database are included.
Required database account permissions
| Database | Required permissions |
|---|---|
| Source ApsaraDB RDS for MySQL instance | Read and write permissions. See Create an account and Modify the permissions of an account |
| Destination ApsaraDB RDS for MySQL instance | Read and write permissions. See Create an account and Modify the permissions of an account |
If the source database account was not created through the ApsaraDB RDS for MySQL console, grant it the REPLICATION CLIENT, REPLICATION SLAVE, SHOW VIEW, and SELECT permissions manually. To sync account information from the source, additional permissions are required. See Migrate database accounts.
Limits
Review these limits before starting. Most task failures and data inconsistencies are caused by overlooking them.
Table structure
-
Tables to sync must have a PRIMARY KEY or UNIQUE constraint with all unique fields. Without this, the destination may contain duplicate records.
-
If you select tables (not databases) as sync objects and plan to rename tables or columns, a single task supports up to 1,000 tables. For more than 1,000 tables, configure multiple tasks or sync at the database level.
Binary log
The following binary log settings must be in place before DTS can read changes from the source:
-
binlog_row_image must be set to
full. Binary logging is enabled by default on ApsaraDB RDS for MySQL instances, but verify this parameter. See Modify instance parameters.-
If the source is a self-managed MySQL database: you must enable binary logging and set
binlog_formattorowandbinlog_row_imagetofull. -
If the source is a self-managed MySQL database deployed in a dual-primary cluster: you must also set
log_slave_updatestoONto ensure DTS can obtain all binary logs. See Create an account for a self-managed MySQL database and configure binary logging.
-
-
Binary log retention must be at least 7 days. If DTS cannot access the required binary logs, the task fails and data loss may occur. See Manage binary log files.
Do not execute DDL statements on the source database during schema synchronization or full data synchronization. This causes the task to fail.
Version and character set compatibility
-
The destination database version must be the same as or later than the source. An older destination version may cause compatibility issues.
-
If the source database is MySQL 8.0.23 or later and includes invisible columns, DTS cannot obtain the data of those columns — data loss occurs.
-
If the destination database is MySQL 8.0.23 or later and includes invisible columns, the destination columns to receive data cannot be found, causing the DTS instance to fail and data loss to occur.
-
In both cases, run
ALTER TABLE <table_name> ALTER COLUMN <column_name> SET VISIBLE;to make invisible columns visible before starting the task. Tables without primary keys auto-generate invisible primary keys; make those visible too. See Invisible Columns and Generated Invisible Primary Keys. -
If you are not using schema synchronization, make sure field type compatibility is maintained. For example, a
textfield in the source mapped to avarchar(255)field in the destination may cause data truncation. -
If the data contains 4-byte characters (such as rare characters or emojis), destination tables must use the UTF8mb4 character set. If using schema synchronization, set the
character_set_serverparameter to UTF8mb4 in the destination database. -
Column names in MySQL are not case-sensitive. If the source has multiple columns whose names differ only in capitalization, they are written to the same column in the destination, causing unexpected results.
Online DDL
-
Do not use pt-online-schema-change for online DDL on tables selected as sync objects. Use Data Management (DMS) instead. See Perform lock-free DDL operations.
-
If DDL operations fail in the destination, the DTS task continues running. Check task logs for failed DDL statements. See View task logs.
-
DTS does not synchronize data that uses parsers defined by comments.
Data consistency
-
Do not write data from other sources to the destination during synchronization. This causes data inconsistency.
-
Data generated by binary log change operations (such as data restored from a physical backup or cascade operations) is not recorded or synchronized to the destination while the task is running.
Foreign key behavior
-
During schema synchronization, DTS synchronizes foreign keys from the source to the destination.
-
During full and incremental data synchronization, DTS temporarily disables foreign key constraint checks and cascade operations at the session level. Cascade update or delete operations on the source during this time may cause data inconsistency.
Performance impact
Full data synchronization reads all data from the source database once, which increases load on both databases. To reduce risk:
-
Run synchronization tasks during off-peak hours.
-
Expect the destination tablespace to be larger than the source after full synchronization, due to concurrent INSERT fragmentation.
-
After the task status changes to Completed, run
analyze table <table_name>to verify that data was written correctly to the destination. (For example, a high availability (HA) switchover in the source may cause some data to be written only to memory.)
Special cases
For self-managed MySQL sources:
-
If a primary/secondary switchover occurs on the source database while the task is running, the task fails.
-
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 a long time, the latency may be inaccurate. If latency is too high, perform a DML operation on the source to update it. If you select an entire database as the sync object, you can create a heartbeat table that is updated every second to keep the latency accurate.
-
DTS executes
CREATE DATABASE IF NOT EXISTS 'test'in the source on a schedule to advance the binary log position.
For ApsaraDB RDS for MySQL sources:
-
Read-only ApsaraDB RDS for MySQL 5.6 instances (which do not record transaction logs) cannot be used as a source.
-
DTS executes
CREATE DATABASE IF NOT EXISTS 'test'in the source on a schedule to advance the binary log position. -
ApsaraDB RDS for MySQL instances with the EncDB feature enabled do not support full data synchronization. Instances with Transparent Data Encryption (TDE) enabled support schema synchronization, full data synchronization, and incremental data synchronization.
If DTS technical support restores a failed task:
-
Support attempts restoration within 8 hours. The task may be restarted and certain task parameters may be modified. Database parameters are not modified.
Configure the synchronization task
Step 1: Go to the Data Synchronization Tasks page
-
Log on to the Data Management (DMS) console.
-
In the top navigation bar, click Data + AI.
-
In the left-side navigation pane, choose DTS (DTS) > Data Synchronization.
Navigation may differ based on your DMS console mode and layout. See Simple mode and Customize the layout and style of the DMS console. Alternatively, go directly to the Data Synchronization Tasks page of the new DTS console.
Step 2: Create the task
-
Select the region where your data synchronization instance resides.
In the new DTS console, select the region in the top navigation bar instead.
-
Click Create Task.
-
(Optional) Click New Configuration Page in the upper-right corner of the page.
Skip this step if the Back to Previous Version button is displayed. The new configuration page is recommended.
Step 3: Configure source and destination databases
After configuring the source and destination databases, review the Limits displayed on the page before proceeding. Skipping this step may cause the task to fail or result in data inconsistency.
Fill in the following parameters for both the source and destination:
| Section | Parameter | Description |
|---|---|---|
| N/A | Task Name | A descriptive name for the DTS task. DTS generates a default name; replace it with something meaningful. A unique name is not required. |
| Source Database | Select a DMS database instance | In this example, no database instance is preselected. Configure the parameters below manually. |
| Database Type | Select MySQL. | |
| Access Method | Select Alibaba Cloud Instance. | |
| Instance Region | The region where the source instance resides. | |
| Replicate Data Across Alibaba Cloud Accounts | Select No (same-account example). | |
| RDS Instance ID | The ID of the source ApsaraDB RDS for MySQL instance. | |
| Database Account | The database account for the source instance. See Required database account permissions. | |
| Database Password | The password for the database account. | |
| Encryption | Select Non-encrypted or SSL-encrypted. To use SSL encryption, enable it on the instance first. See Use a cloud certificate to enable SSL encryption. | |
| Destination Database | Select a DMS database instance | In this example, no database instance is preselected. Configure the parameters below manually. |
| Database Type | Select MySQL. | |
| Access Method | Select Alibaba Cloud Instance. | |
| Instance Region | The region where the destination instance resides. | |
| Replicate Data Across Alibaba Cloud Accounts | Select No (same-account example). | |
| RDS Instance ID | The ID of the destination ApsaraDB RDS for MySQL instance. | |
| Database Account | The database account for the destination instance. See Required database account permissions. | |
| Database Password | The password for the database account. | |
| Encryption | Select Non-encrypted or SSL-encrypted. To use SSL encryption, enable it on the instance first. See Use a cloud certificate to enable SSL encryption. |
Step 4: Test connectivity
Click Test Connectivity and Proceed.
DTS automatically adds its server CIDR blocks to the whitelist of Alibaba Cloud database instances. For ECS-hosted databases, DTS adds the CIDR blocks to the ECS security group rules and you must make sure that the ECS instance can access the database — if the database spans multiple ECS instances, add the CIDR blocks to each instance's security group manually. For on-premises databases or databases hosted by third-party cloud providers, add the DTS server CIDR blocks to the database whitelist manually. See CIDR blocks of DTS servers.
Adding DTS server CIDR blocks to whitelists or security groups introduces security risks. Before proceeding, take preventive measures such as strengthening your credentials, restricting exposed ports, authenticating API calls, and auditing whitelist rules regularly. Alternatively, connect the database to DTS using Express Connect, VPN Gateway, or Smart Access Gateway.
Step 5: Configure sync objects
In the Configure Objects step, fill in the following parameters:
| Parameter | Description |
|---|---|
| Synchronization Types | Incremental Data Synchronization is selected by default. Also select Schema Synchronization and Full Data Synchronization. DTS uses the full sync as the baseline before starting incremental sync. |
| Method to Migrate Triggers in Source Database | Select how to handle triggers from the source. Only available when Schema Synchronization is selected. See Synchronize or migrate triggers from the source database. |
| Enable Migration Assessment | Select Yes to check whether source and destination schemas (including index lengths, stored procedures, and dependent tables) meet requirements. Assessment results are shown during precheck but do not affect precheck outcome. Only available when Schema Synchronization is selected. |
| Synchronization Topology | Select One-way Synchronization. |
| Processing Mode of Conflicting Tables | Precheck and Report Errors (recommended): the precheck fails if the destination contains tables with the same names as the source. Use object name mapping to resolve naming conflicts. Ignore Errors and Proceed: skips the precheck for identical table names. During full sync, existing destination records with matching primary or unique key values are kept. During incremental sync, matching records are overwritten. Schema differences may cause partial sync or task failure. |
| Capitalization of Object Names in Destination Instance | Controls the casing of database names, table names, and column names in the destination. The default is DTS default policy. See Specify the capitalization of object names in the destination instance. |
| Source Objects | Select the objects to sync (columns, tables, or databases) and click the arrow icon to add them to Selected Objects. Selecting tables or columns excludes other object types (views, triggers, stored procedures) from sync. |
| Selected Objects | To rename a single object in the destination, right-click it and select the rename option. To rename multiple objects at once, click Batch Edit. See Map object names. To filter rows using WHERE conditions, right-click an object and set the conditions. See Set filter conditions. To sync specific SQL operations for a table or database, right-click the object and select the operations. |
Renaming an object with object name mapping may cause other objects that depend on it to fail syncing.
Step 6: Configure advanced settings
Click Next: Advanced Settings and fill in the following parameters:
| Parameter | Description |
|---|---|
| Dedicated Cluster for Task Scheduling | By default, DTS schedules the task on a shared cluster. Purchase a dedicated cluster for improved stability. See What is a DTS dedicated cluster. |
| Copy the temporary table of the Online DDL tool that is generated in the source table to the destination database | Controls whether to sync temporary tables generated by online DDL tools. If using DMS or gh-ost for online DDL, select Yes to sync temporary table data (note: large operations extend sync time), No, Adapt to DMS Online DDL to sync only the final DDL (destination tables may be locked), or No, Adapt to gh-ost to sync only the final DDL from gh-ost (destination tables may be locked). Do not use pt-online-schema-change when tables (not an entire database) are selected as sync objects — it will cause the task to fail. |
| Whether to Migrate Accounts | Select Yes to sync account information from the source. Specify the accounts to sync and review their permissions. |
| Retry Time for Failed Connections | How long DTS retries failed connections after the task starts. Valid values: 10–1440 minutes. Default: 720 minutes. Set to more than 30 minutes. If DTS reconnects within this window, the task resumes. Otherwise, it fails. Note: when DTS retries a connection, you are charged for the DTS instance. If you specify different retry time ranges for multiple tasks sharing the same source or destination database, the shortest retry time range takes precedence. We recommend releasing the DTS instance promptly after the source and destination instances are released. |
| Retry Time for Other Issues | How long DTS retries failed DDL or DML operations. Valid values: 1–1440 minutes. Default: 10 minutes. Set to more than 10 minutes. This value must be less than Retry Time for Failed Connections. |
| Enable Throttling for Full Data Migration | Limits read/write load during full data synchronization. Configure Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s). Only visible when Full Data Synchronization is selected. |
| Enable Throttling for Incremental Data Synchronization | Limits load during incremental sync. Configure RPS of Incremental Data Synchronization and Data synchronization speed for incremental synchronization (MB/s). |
| Environment Tag | Tag the DTS instance for identification. Optional. |
| Whether to delete SQL operations on heartbeat tables of forward and reverse tasks | Controls whether DTS writes heartbeat SQL operations to the source database. Select Yes to skip writing (a sync latency may appear on the task page). Select No to write heartbeat operations (this may affect physical backup and cloning of the source database). |
| Configure ETL | Select Yes to enable the extract, transform, and load (ETL) feature and enter processing statements. See What is ETL? and Configure ETL in a data migration or data synchronization task. |
| Monitoring and Alerting | Select Yes to receive notifications when the task fails or synchronization latency exceeds the threshold. Configure the alert threshold and notification settings. See Configure monitoring and alerting. |
Step 7: Configure data verification (optional)
Click Next Step: Data Verification to set up data verification for the task. See Configure a data verification task.
Step 8: Run the precheck
Click Next: Save Task Settings and Precheck.
To preview the API parameters for this configuration, hover over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters.
DTS runs a precheck before the task can start. Wait for the precheck to complete:
-
If an item fails, click View Details to see the cause and fix the issue, then click Precheck Again.
-
If an item shows an alert, either fix the issue or click Confirm Alert Details > Ignore > OK > Precheck Again to proceed. Ignoring alerts may lead to data inconsistency.
Step 9: Purchase the instance
After Success Rate reaches 100%, click Next: Purchase Instance.
On the buy page, configure the following:
| Section | Parameter | Description |
|---|---|---|
| New Instance Class | Billing Method | Subscription: pay upfront for a fixed period. More cost-effective for long-term use. Pay-as-you-go: billed hourly. Suitable for short-term use; release the instance when no longer needed to stop charges. |
| Resource Group Settings | The resource group for the instance. Default: default resource group. See What is Resource Management? | |
| Instance Class | Controls sync throughput. See Instance classes of data synchronization instances. | |
| Subscription Duration | Available when Subscription is selected. Options: 1–9 months, 1 year, 2 years, 3 years, or 5 years. |
Read and select Data Transmission Service (Pay-as-you-go) Service Terms, then click Buy and Start and confirm.
The task appears in the task list. Monitor its progress there.
What's next
-
Modify the objects to be synchronized — add or remove tables and databases from a running task
-
View task logs — diagnose failed DDL statements or sync errors
-
Map object names — rename objects in the destination without changing the source
-
Configure monitoring and alerting — get notified when the task fails or latency spikes