Use Data Transmission Service (DTS) to continuously synchronize data from a PolarDB for MySQL cluster to an ApsaraDB RDS for MySQL instance. Common use cases include disaster recovery, read offloading, and zero-downtime migration transitions.
Supported destination types
This topic uses an ApsaraDB RDS for MySQL instance as the destination. The same procedure applies to the following destination types:
-
ApsaraDB RDS for MySQL instance
-
Self-managed database hosted on Elastic Compute Service (ECS)
-
Self-managed database connected over Express Connect, VPN Gateway, or Smart Access Gateway
-
Self-managed database connected over Database Gateway
-
Self-managed database connected over Cloud Enterprise Network (CEN)
Prerequisites
Before you begin, ensure that you have:
-
A PolarDB for MySQL cluster. See Purchase a subscription cluster or Purchase a pay-as-you-go cluster
-
An ApsaraDB RDS for MySQL instance as the destination. See Create an ApsaraDB RDS for MySQL instance
-
Available storage on the destination instance that exceeds the total data size of the source cluster
-
A source database account with read permissions on the objects to be synchronized
-
A destination database account with read and write permissions on the destination database
-
Binary logging enabled on the source cluster with
loose_polar_log_binset toon(required for incremental data synchronization). See Enable binary logging and Modify parameters
Enabling binary logging incurs storage charges for binary log files on your PolarDB for MySQL cluster.
Binary log retention requirements:
| Task type | Minimum retention period |
|---|---|
| Incremental data synchronization only | 24 hours |
| Full data synchronization + incremental data synchronization | 7 days |
After full data synchronization completes, you can set the retention period to more than 24 hours. If binary logs are not retained for long enough, DTS may fail to read them, causing the task to fail or, in exceptional cases, data inconsistency or loss. Tasks that do not meet these requirements fall outside the DTS SLA.
Limitations
Source database limitations
-
Tables must have PRIMARY KEY or UNIQUE constraints, with all fields unique. Tables without these constraints may produce duplicate records in the destination.
-
When you select tables as the synchronization objects and need to edit them (such as renaming tables or columns), a single task supports up to 1,000 tables. For more than 1,000 tables, configure multiple tasks or synchronize at the database level.
-
Read-only nodes of the source PolarDB for MySQL cluster cannot be synchronized.
DDL operations during synchronization
-
Do not use pt-online-schema-change for DDL operations on source tables during synchronization. This may cause the task to fail.
-
If DTS is the only writer to the destination database, you can use Data Management (DMS) to perform online DDL operations on source tables. See Perform lock-free operations.
-
If tools other than DTS also write to the destination, DMS online DDL operations may cause data loss in the destination.
RENAME TABLE risk
If you select a table (not a database) as the synchronization object and rename it during synchronization, data for that table stops being synchronized. To avoid this, select the entire database as the synchronization object and ensure that both the pre-rename and post-rename database names are included in the selected objects.
Full data synchronization performance
DTS uses read and write resources on both the source and destination during initial full data synchronization. Schedule synchronization during off-peak hours to minimize load. Concurrent INSERT operations during full synchronization cause table fragmentation in the destination, so the destination tablespace will be larger than the source after full synchronization completes.
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 constraint checks and cascade operations on foreign keys at the session level. Cascade update or delete operations on the source during synchronization may cause data inconsistency.
Billing
| Synchronization type | Cost |
|---|---|
| Schema synchronization and full data synchronization | Free |
| Incremental data synchronization | Charged. See Billing overview |
Supported synchronization topologies
For details, see Synchronization topologies.
-
One-way one-to-one synchronization
-
One-way one-to-many synchronization
-
One-way cascade synchronization
-
Two-way cascade synchronization
-
One-way many-to-one synchronization
-
Two-way one-to-one synchronization
SQL operations that can be synchronized
| Type | Operations |
|---|---|
| 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 |
Configure a data synchronization task
Step 1: Open the Data Synchronization Tasks page
-
Log in to the Data Management (DMS) console.
-
In the top navigation bar, click DTS.
-
In the left-side navigation pane, choose DTS (DTS) > Data Synchronization.
Navigation options vary based on your DMS console mode. See Simple mode or Customize the layout and style of the DMS console. You can also go directly to the Data Synchronization Tasks page.
Step 2: Create a task
-
Select the region where the synchronization instance will reside.
In the new DTS console, select the region in the top navigation bar.
-
Click Create Task.
-
(Optional) If the Back to Previous Version button is not displayed, click New Configuration Page in the upper-right corner. Use the new configuration page when available — some parameters differ between versions.
Step 3: Configure source and destination databases
After configuring source and destination databases, read the Limits displayed at the top of the page before proceeding. Skipping this may cause task failure or data inconsistency.
Source database parameters:
| Parameter | Description |
|---|---|
| Task Name | Name of the task. DTS assigns a default name. Specify a descriptive name for easier identification. Uniqueness is not required. |
| Select a DMS database instance | Select an existing registered instance, or configure the source database manually. To register an Alibaba Cloud database, see Register an Alibaba Cloud database instance. To register a self-managed database, see Register a database hosted on a third-party cloud service or a self-managed database. In the DTS console, use the Database Connections page. |
| Database Type | Select PolarDB for MySQL. |
| Access Method | Select Alibaba Cloud Instance. |
| Instance Region | Region where the source PolarDB for MySQL cluster resides. |
| Replicate Data Across Alibaba Cloud Accounts | Select No (this example uses the same Alibaba Cloud account). |
| PolarDB Cluster ID | ID of the source PolarDB for MySQL cluster. |
| Database Account |
Account with read permissions on the objects to be synchronized. |
| Database Password | Password for the database account. |
| Encryption | Whether to encrypt the connection to the source cluster. See Configure SSL encryption. |
Destination database parameters:
| Parameter | Description |
|---|---|
| Select a DMS database instance | Select an existing registered instance, or configure the destination database manually. See the registration links above. |
| Database Type | Select MySQL. |
| Access Method | Select Alibaba Cloud Instance. |
| Instance Region | Region where the destination ApsaraDB RDS for MySQL instance resides. |
| Replicate Data Across Alibaba Cloud Accounts | Select No. |
| RDS Instance ID | ID of the destination ApsaraDB RDS for MySQL instance. |
| Database Account | Account with read and write permissions on the destination database. |
| Database Password | Password for the database account. |
| Encryption | Select Non-encrypted or SSL-encrypted. If you select SSL-encrypted, enable SSL encryption on the RDS instance first. See Configure the SSL encryption feature. |
Step 4: Test connectivity
Click Test Connectivity and Proceed.
DTS automatically adds its CIDR blocks to the whitelist of Alibaba Cloud database instances and to the security group rules of ECS-hosted databases. For databases hosted on multiple ECS instances, manually add the CIDR blocks to each ECS instance's security group rules. For self-managed databases in data centers or on third-party cloud providers, add the DTS CIDR blocks manually. See Add the CIDR blocks of DTS servers.
Adding DTS CIDR blocks to a whitelist or security group introduces potential security exposure. Before proceeding, take preventive measures such as strengthening account credentials, restricting exposed ports, authenticating API calls, auditing whitelist rules regularly, and connecting via Express Connect, VPN Gateway, or Smart Access Gateway where possible.
Step 5: Select objects to synchronize
On the Select Objects page, configure the following parameters:
| Parameter | Description |
|---|---|
| Synchronization Types | Select Schema Synchronization, Full Data Synchronization, and Incremental Data Synchronization. Full data synchronization establishes the baseline that incremental synchronization depends on — select all three together for a complete synchronization setup. Incremental Data Synchronization is selected by default. |
| Method to Migrate Triggers in Source Database | Available only when Schema Synchronization is selected. Choose how to handle triggers. See Synchronize or migrate triggers from the source database. |
| Synchronization Topology | Select One-way Synchronization. |
| Processing Mode of Conflicting Tables | Precheck and Report Errors (default): fails the precheck if tables with identical names exist in both source and destination. Use object name mapping to resolve conflicts. See Map object names. Ignore Errors and Proceed: skips the precheck for identical table names. During full synchronization, existing records in the destination are retained when primary or unique key values match. During incremental synchronization, matching records are overwritten. If schemas differ, synchronization may partially fail. |
| Capitalization of Object Names in Destination Instance | Default is DTS default policy. Adjust if the destination requires specific capitalization. See Specify the capitalization of object names in the destination instance. |
| Source Objects | Select objects and click the arrow icon to move them to Selected Objects. You can select columns, tables, or databases. Selecting tables or columns excludes views, triggers, and stored procedures. |
| Selected Objects | Right-click an object to rename it or set row-level filter conditions. Click Batch Edit to rename multiple objects at once. See Map object names and Set filter conditions. Renaming an object may break synchronization of dependent objects. |
Step 6: Configure advanced settings
Click Next: Advanced Settings and configure the following:
| Parameter | Description |
|---|---|
| Dedicated Cluster for Task Scheduling | DTS uses shared clusters by default. For higher task stability, purchase a dedicated cluster. 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 how DTS handles temporary tables from online DDL tools (DMS or gh-ost). Yes: synchronizes temporary table data (may extend synchronization time). No, Adapt to DMS Online DDL: skips temporary tables; only the final DDL is synchronized (destination tables may lock temporarily). No, Adapt to gh-ost: skips gh-ost shadow tables; only the final DDL is synchronized (destination tables may lock temporarily). Do not use pt-online-schema-change — it causes the task to fail. |
| Retry Time for Failed Connections | How long DTS retries failed connections after the task starts. Range: 10–1,440 minutes. Default: 720. We recommend that you set this parameter to a value greater than 30. If multiple tasks share the same source or destination, the shortest retry time applies. Retry time counts toward billing. |
| Retry Time for Other Issues | How long DTS retries failed DDL or DML operations. Range: 1–1,440 minutes. Default: 10. We recommend that you set this parameter to a value greater than 10. Must be less than Retry Time for Failed Connections. |
| Enable Throttling for Full Data Migration | Limits queries per second (QPS) to the source, RPS, and migration speed (MB/s) during full synchronization to reduce load. Visible only when Full Data Synchronization is selected. |
| Enable Throttling for Incremental Data Synchronization | Limits RPS and synchronization speed (MB/s) during incremental synchronization. |
| Environment Tag | Optional tag to classify the DTS instance. |
| Whether to delete SQL operations on heartbeat tables of forward and reverse tasks | Yes: DTS does not write heartbeat SQL to the source (task latency metrics may be affected). No: DTS writes heartbeat SQL to the source (may affect physical backup and cloning of the source). |
| Configure ETL | Yes: enables extract, transform, and load (ETL) processing. Enter data processing statements in the code editor. See Configure ETL. No: disables ETL. |
| Monitoring and Alerting | Yes: configure alert thresholds and notification settings to receive alerts on task failure or synchronization latency. See Configure monitoring and alerting. No: no alerting. |
Step 7: Configure data verification (optional)
Click Next: Verification Configurations to set up data verification. See Configure data verification.
Step 8: Run the precheck
Click Next: Save Task Settings and Precheck.
To preview the OpenAPI parameters for this task, hover over the button and click Preview OpenAPI parameters.
Before the precheck runs, verify the following to reduce the risk of failure:
-
Binary logging is enabled and
loose_polar_log_binis set toon -
The source account has read permissions; the destination account has read and write permissions
-
Binary log retention meets the minimums listed in the Prerequisites section
-
Source tables have PRIMARY KEY or UNIQUE constraints
The task starts only after the precheck passes.
-
If an item fails, click View Details to review the cause, fix the issue, then click Precheck Again.
-
If an alert can be safely ignored, click Confirm Alert Details > Ignore > OK, then click Precheck Again. Ignoring alerts may result in data inconsistency.
Step 9: Purchase a synchronization instance
Wait until the success rate reaches 100%, then click Next: Purchase Instance.
| Parameter | Description |
|---|---|
| Billing Method | Subscription: pay upfront for a fixed term. Available durations: 1–9 months, or 1, 2, 3, or 5 years. Lower cost per month for longer terms. Pay-as-you-go: billed hourly. Release the instance when no longer needed to stop charges. |
| Resource Group Settings | Resource group for the instance. Default: default resource group. See What is Resource Management? |
| Instance Class | Determines synchronization performance and speed. Choose based on your data volume and latency requirements. See Instance classes of data synchronization instances. |
| Subscription Duration | Available only for subscription billing. Set the term and instance count. |
Read and accept the Data Transmission Service (Pay-as-you-go) Service Terms, then click Buy and Start.
The synchronization task appears in the task list. Monitor its progress from there.
DTS periodically executes CREATE DATABASE IF NOT EXISTS \test\`` on the source database to advance the binary log position. This is expected behavior.