Synchronize PolarDB for MySQL to ApsaraDB RDS for MySQL
Synchronize data in real time from PolarDB for MySQL to ApsaraDB RDS for MySQL by using DTS.
Prerequisites
- A PolarDB for MySQL cluster is created. Create a PolarDB for MySQL cluster.
- binary logging for the PolarDB for MySQL cluster is enabled. Enable binary logging.
Usage notes
During full data initialization, DTS consumes read and write resources of the source and destination databases, which may increase the database load. When the databases have low performance, low specifications, or heavy workloads (for example, a large number of slow SQL statements, tables without primary keys, or deadlocks on the destination database), the database pressure may be further increased and services may become unavailable. Therefore, you must evaluate the performance of the source and destination databases before starting data synchronization, and it is recommended that you perform data synchronization during off-peak hours (for example, when the CPU load of both the source and destination databases is below 30%).
- During initial full data synchronization, concurrent INSERT operations cause table fragmentation in the target cluster, resulting in a larger tablespace than the source database.
- If a source table lacks a primary key or unique constraint and contains duplicate rows, duplicate data may exist in the target database.
- If the target is an ApsaraDB RDS for MySQL or RDS MySQL Serverless instance (except MySQL 5.7 and 8.0), DTS creates an account named dtssyncwriter in the target database. This account has write permissions and is used only by DTS.
Billing
|
Synchronization type |
Pricing |
|
Schema synchronization and full data synchronization |
Free of charge. |
|
Incremental data synchronization |
Charged. For more information, see Billing overview. |
Supported SQL operations
|
Operation type |
SQL statement |
|
DML |
INSERT, UPDATE, DELETE, and REPLACE |
|
DDL |
|
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
For usage notes on each topology, see Synchronization topologies.
Limitations
Trigger incompatibility
If the sync object is an entire database and a trigger in that database updates a table within the database, data inconsistency between the source and destination databases may occur. For information about the workaround, see Configure tasks for source databases with triggers.
RENAME TABLE limitation
RENAME TABLE operations may cause data inconsistency during synchronization. For example, if the sync object contains only table A and the source instance renames table A to table B during synchronization, table B will not be synchronized to the destination database. To avoid this issue, you can select the entire database in which table A and table B reside as the sync object when you configure the data synchronization task.
Procedure
- Purchase a data synchronization instance. Purchase process.
Note When you purchase the instance, set PolarDB to PolarDB, MySQL to MySQL, and One-way Synchronization to One-way Synchronization.
- Log on to the Data Transmission Service console.
Note
If you are automatically redirected to the Data Management (DMS) console, you can click the
icon in the lower-right corner and then click
to return to the classic DTS console. - In the navigation pane on the left, click Data Synchronization.
- In the top navigation bar of the Data Synchronization page, select the region where the destination instance is located.
- Find the purchased data synchronization instance and click Configure Synchronization Channel.
- Configure the source and target instances.
Category Parameter Description N/A Synchronization Task Name DTS auto-generates a task name. Specify a descriptive name for easy identification. Source Instance Information Instance Type Fixed as PolarDB Instance. Not editable. Instance Region The source region selected during purchase. Not editable. PolarDB Instance ID Select the source PolarDB for MySQL cluster ID. Database Account Enter the database account for the source PolarDB for MySQL cluster. Database Password Enter the password for the database account. Target Instance Information Instance Type Select RDS Instance. Instance Region The target region selected during purchase. Not editable. Database Account Enter the database account for the target RDS instance. Database Password Enter the password for the database account. Note If the target RDS instance runs MySQL 5.5 or MySQL 5.6, you do not need to configure Database Account and Database Password.Connection Method Select Non-encrypted or SSL-encrypted as needed. If you select SSL-encrypted, enable SSL encryption for the RDS instance first. Set SSL encryption. -
In the lower-right corner of the page, click Set Whitelist and Next.
If the source or destination database is an Alibaba Cloud database instance, such as an ApsaraDB RDS for MySQL or ApsaraDB for MongoDB instance, DTS automatically adds the CIDR blocks of DTS servers to the IP address whitelist of the instance. If the source or destination database is a self-managed database hosted on an Elastic Compute Service (ECS) instance, DTS automatically adds the CIDR blocks of DTS servers to the security group rules of the ECS instance, and you must make sure that the ECS instance can access the database. If the self-managed database is hosted on multiple ECS instances, you must manually add the CIDR blocks of DTS servers to the security group rules of each ECS instance. If the source or destination database is a self-managed database that is deployed in a data center or provided by a third-party cloud service provider, you must manually add the CIDR blocks of DTS servers to the IP address whitelist of the database to allow DTS to access the database. For more information, see Whitelist DTS server IP addresses.
WarningAdding the public IP address blocks of the DTS service, either automatically or manually, may pose security risks. Using this product, you acknowledge that you understand and accept the potential security risks and that you must implement basic security measures. These measures include, but are not limited to, strengthening password security, limiting the ports open to each CIDR block, using authentication for internal API calls, and regularly checking and restricting unnecessary CIDR blocks. Alternatively, you can connect through a private network using a leased line, VPN Gateway, or Smart Access Gateway.
- Configure the handling mode for existing tables in the destination database and select the synchronization objects.
Configuration Item Description Handling Mode for Existing Tables - Precheck and Report an Error: DTS checks whether a table with the same name exists in the destination database. If no table with the same name exists, the check passes. If a table with the same name exists, the precheck fails, and the data synchronization task does not start. Note If you cannot delete or rename the table in the destination database, you can use the object name mapping feature to avoid name conflicts. For more information, see Map object names in the destination instance.
- Ignore Errors and Proceed: DTS skips the check for tables with the same name in the destination database. Warning If you select Ignore Errors and Proceed, data inconsistency may occur and pose risks to your business. For example:
- If the table schemas are the same, records in the destination table with the same primary key value as in the source table are retained during the initial synchronization phase. During the incremental synchronization phase, these records are overwritten.
- If the table schemas are different, data may fail to be initialized, only some columns may be synchronized, or the synchronization may fail.
Select Synchronization Objects In the Source Objects box, click the object that you want to synchronize, and then click the
icon to move it to the Selected Objects box.You can select databases and tables as synchronization objects.
Note- If you select an entire database as a synchronization object, the schema changes of all objects in that database are synchronized to the destination database.
- By default, the names of the synchronization objects are not changed. To change the name of an object in the destination cluster, use the object name mapping feature. For more information, see Map object names in the destination instance.
Change Mapped Name Change the names of synchronized objects in the destination instance. For more information, see Map databases, tables, and columns.
Replicate Temporary Tables to Destination Database During Online DDL in DMS If you use Data Management (DMS) to perform online DDL changes on the source database, you can choose whether to synchronize the temporary tables generated by the DDL changes.
-
Yes: Synchronizes the temporary tables generated by online DDL changes.
NoteIf a large amount of temporary table data is generated by online DDL changes, the data synchronization task may be delayed.
-
No: Does not synchronize the temporary tables generated by online DDL changes. Only the original DDL operations from the source database are synchronized.
NoteThis option causes tables in the destination database to be locked.
Retry Duration for Unstable Connections If DTS cannot connect to the source or destination instance, it retries for 720 minutes (12 hours) by default. You can also specify a custom retry duration. If DTS reconnects to the source or destination instance within the specified duration, the synchronization task automatically resumes. Otherwise, the task fails.
NoteYou are billed for task run time during connection retries. Customize the retry duration based on your business needs, or release the DTS instance as soon as the source and destination instances are released.
- Precheck and Report an Error: DTS checks whether a table with the same name exists in the destination database. If no table with the same name exists, the check passes. If a table with the same name exists, the precheck fails, and the data synchronization task does not start.
- After you complete the preceding configurations, click Next in the lower-right corner of the page.
- Configure advanced settings for initial synchronization.
Note There are two types of initial synchronization: initial schema synchronization and initial full data synchronization. If you select both Initial Schema Synchronization and Initial Full Data Synchronization, DTS synchronizes the schema and historical data of the objects from the source database to the target database before the incremental data synchronization starts. After you complete the preceding configurations, click Precheck and Start in the lower-right corner of the page.
NoteBefore the synchronization task is officially started, a precheck is performed. The synchronization task can only be started after the precheck passes.
If the precheck fails, click the
icon next to a specific check item to view the failure details.Follow the prompt to fix the issue and run the precheck again.
If you do not need to fix the warning check items, you can also select Ignore, Ignore Warning Items and Rerun Precheck to skip the warning check items and run the precheck again.
- After Precheck Passed is displayed in the Precheck dialog box, close the dialog box. The synchronization task starts automatically.
- Wait until the synchronization channel is initialized and the task enters the Synchronizing state.
The Data Synchronization page displays the status of data synchronization jobs.

icon next to a specific check item to view the failure details.