Use Data Transmission Service (DTS) to migrate data from an ApsaraDB RDS for MySQL instance to a PolarDB for MySQL cluster with minimal downtime. DTS supports schema migration, full data migration, and incremental data migration, so you can keep your application running during the migration.
This topic uses an ApsaraDB RDS for MySQL instance as the source. You can follow the same procedure for other supported MySQL sources.
Supported source databases
-
ApsaraDB RDS for MySQL instance
-
Self-managed databases:
-
Database with a public IP address
-
Database hosted on Elastic Compute Service (ECS)
-
Database connected over Express Connect, VPN Gateway, or Smart Access Gateway
-
Database connected over Database Gateway
-
Prerequisites
Before you begin, ensure that you have:
-
An ApsaraDB RDS for MySQL instance. See Create an ApsaraDB RDS for MySQL instance.
-
A PolarDB for MySQL cluster. See Purchase a pay-as-you-go cluster or Purchase a subscription cluster.
-
Enough available storage on the destination PolarDB for MySQL cluster to hold all data from the source instance.
Permissions required
Grant the following permissions to the database accounts used by DTS before configuring the migration task.
| Database | Schema migration | Full data migration | Incremental data migration |
|---|---|---|---|
| ApsaraDB RDS for MySQL | SELECT | SELECT | REPLICATION SLAVE, REPLICATION CLIENT, SHOW VIEW, SELECT |
| PolarDB for MySQL cluster | Read and write permissions | — | — |
For more information about how to create a database account and grant permissions, see the following topics:
-
ApsaraDB RDS for MySQL instance: Create an account on an ApsaraDB RDS for MySQL instance and Modify the permissions of a standard account on an ApsaraDB RDS for MySQL instance
-
PolarDB for MySQL cluster: Create a database account
Migration types
DTS supports three migration types that you can combine based on your needs:
| Migration type | What it does | Billable? |
|---|---|---|
| Schema migration | Copies schemas (tables, views, triggers, stored procedures, functions) to the destination | Free |
| Full data migration | Copies all existing data to the destination | Free |
| Incremental data migration | Continuously replicates changes from the source to the destination after full migration completes | Yes |
Recommended: Select all three types. This approach keeps your application running without interruption during migration.
Note on schema migration behavior:
-
DTS migrates foreign keys from the source to the destination. During full and incremental migration, DTS temporarily disables foreign key constraint checks and cascade operations at the session level. If you run cascade or delete operations on the source during this time, data inconsistency may occur.
-
For views, stored procedures, and functions, DTS changes the SECURITY attribute from DEFINER to INVOKER. DTS does not migrate user information. To call a view, stored procedure, or function in the destination database, grant the required read and write permissions to INVOKER.
SQL operations supported for incremental migration
| Operation type | Supported 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 |
Billing
| Migration type | Instance configuration fee | Internet traffic fee |
|---|---|---|
| Schema migration + full data migration | Free | Charged only when migrating from Alibaba Cloud over the Internet. See Billing overview. |
| Incremental data migration | Charged. See Billing overview. | — |
Limitations
Source database requirements
-
The server hosting the source database must have enough outbound bandwidth. Insufficient bandwidth reduces migration speed.
-
Tables must have PRIMARY KEY or UNIQUE constraints with all unique fields. Tables without these constraints may result in duplicate records in the destination.
-
If you select tables as migration objects and need to rename tables or columns in the destination database, a single task supports up to 1,000 tables. For more than 1,000 tables, split them across multiple tasks or migrate the entire database instead.
-
Do not perform DDL operations on databases or tables during schema migration or full data migration. The task fails if schemas change mid-migration.
-
If you run full data migration only (without incremental), do not write to the source database during migration. To guarantee data consistency, use schema migration, full data migration, and incremental data migration together.
If you include incremental data migration, the source database must also meet these requirements:
-
Binary logging is enabled, with
binlog_formatset torowandbinlog_row_imageset tofull. If these conditions are not met, precheck returns errors and the task cannot start.-
Important: For self-managed MySQL in a dual-primary cluster, set
log_slave_updatestoONso DTS can capture all binary logs.
-
-
Binary log retention period: Insufficient log retention causes DTS to fail to obtain binary logs, which may result in task failure or data loss. Meeting these retention requirements is necessary to achieve the Service Level Agreement (SLA) guarantees.
-
Incremental migration only: retain logs for more than 24 hours.
-
Full + incremental migration: retain logs for at least 7 days. After full migration completes, you can reduce retention to more than 24 hours.
-
Destination database requirements
-
DTS automatically creates the destination database in the PolarDB for MySQL cluster. If the source database name is invalid, create the database manually before configuring the task. See Database Management.
-
Throttling is not supported for full data migration.
Other limitations
-
Use the same engine version for the source and destination databases to ensure compatibility.
-
Full data migration uses read and write resources on both the source and destination databases, which increases load. Schedule migration during off-peak hours.
-
Full data migration with concurrent INSERT operations causes table fragmentation in the destination. After migration completes, the destination tablespace is larger than the source.
-
DTS uses
ROUND(COLUMN, PRECISION)to read FLOAT and DOUBLE columns. If you do not specify a precision, DTS uses 38 digits for FLOAT and 308 digits for DOUBLE. Verify that these precision settings meet your requirements. -
DTS retries failed tasks for up to 7 days. Before switching workloads to the destination, stop or release the migration task — or run
REVOKEto remove write permissions from the DTS account. Otherwise, if the task resumes automatically, data from the source may overwrite data in the destination.
Self-managed MySQL sources only
-
If a primary/secondary failover occurs while the migration task is running, the task fails.
-
DTS calculates migration latency based on the timestamp of the latest migrated data in the destination and the current timestamp in the source. If no DML operations run on the source for an extended period, the reported latency may be inaccurate. Run a DML operation on the source to refresh the latency. If you migrate an entire database, create a heartbeat table that receives an update every second.
-
DTS periodically runs
CREATE DATABASE IF NOT EXISTS `test`on the source to advance the binary log file position.
Create a migration task
Step 1: Go to the Data Migration Tasks page
-
Log on to the Data Management (DMS) console.
-
In the top navigation bar, click DTS.
-
In the left-side navigation pane, choose DTS (DTS) > Data Migration.
Console layout may vary. See Simple mode and Configure the DMS console based on your business requirements. Alternatively, go directly to the Data Migration Tasks page.
Step 2: Select the region
From the drop-down list next to Data Migration Tasks, select the region where the migration instance resides.
In the new DTS console, select the region in the upper-left corner.
Step 3: Configure source and destination databases
Click Create Task and configure the following parameters.
Read the limits displayed at the top of the page after selecting the source and destination instances. This helps prevent task failures and data inconsistency.
Task settings
| Parameter | Description |
|---|---|
| Task Name | DTS generates a name automatically. Specify a descriptive name to identify the task. The name does not need to be unique. |
Source Database
| Parameter | Description |
|---|---|
| Select an existing DMS database instance | Select an existing instance to reuse its settings, or configure parameters manually. |
| Database Type | Select MySQL. |
| Access Method | Select Alibaba Cloud Instance. |
| Instance Region | Select the region where the source ApsaraDB RDS for MySQL instance resides. |
| Replicate Data Across Alibaba Cloud Accounts | Select No to migrate within the same Alibaba Cloud account. |
| RDS Instance ID | Select the source ApsaraDB RDS for MySQL instance. |
| Database Account | Enter the database account. See Permissions required. |
| Database Password | Enter the password for the database account. |
| Encryption | Select Non-encrypted or SSL-encrypted. If you select SSL-encrypted, enable SSL on the source instance first. See Configure SSL encryption for an ApsaraDB RDS for MySQL instance. |
Destination Database
| Parameter | Description |
|---|---|
| Select an existing DMS database instance | Select an existing instance to reuse its settings, or configure parameters manually. |
| Database Type | Select PolarDB for MySQL. |
| Access Method | Select Alibaba Cloud Instance. |
| Instance Region | Select the region where the destination PolarDB for MySQL cluster resides. |
| PolarDB Cluster ID | Select the destination PolarDB for MySQL cluster. |
| Database Account | Enter the database account. See Permissions required. |
| Database Password | Enter the password for the database account. |
Step 4: Test connectivity
Click Test Connectivity and Proceed at the bottom of the page.
DTS automatically adds its server CIDR blocks to the whitelist of Alibaba Cloud database instances and to the security group rules of ECS-hosted databases. For self-managed databases in data centers or on third-party cloud providers, manually add the DTS CIDR blocks to the database whitelist. See Add the CIDR blocks of DTS servers to the security settings of on-premises databases.
Adding DTS CIDR blocks to database whitelists or security group rules introduces security exposure. Before proceeding, take preventive measures such as using strong credentials, restricting exposed ports, authenticating API calls, auditing whitelist entries regularly, and using Express Connect, VPN Gateway, or Smart Access Gateway instead of public internet connections where possible.
Step 5: Configure migration objects and advanced settings
Migration type
| Goal | Selection |
|---|---|
| Full migration with downtime | Schema Migration + Full Data Migration |
| Zero-downtime migration (recommended) | Schema Migration + Full Data Migration + Incremental Data Migration |
If you do not select Incremental Data Migration, do not write to the source instance during migration to maintain data consistency.
Processing mode for conflicting tables
| Mode | Behavior |
|---|---|
| Precheck and Report Errors | Checks for tables with identical names in the source and destination. The task fails the precheck if conflicts exist. Use object name mapping to rename conflicting tables before starting. |
| Ignore Errors and Proceed | Skips the identical-name check. If schemas match, records with the same primary keys are skipped. If schemas differ, only some columns migrate or the task fails. |
Selecting Ignore Errors and Proceed may cause data inconsistency.
Select objects
Select one or more objects from the Source Objects section and click
to add them to the Selected Objects section.
You can select columns, tables, or schemas. If you select tables or columns, DTS does not migrate views, triggers, or stored procedures.
To rename a single object, right-click it in Selected Objects. See Map the name of a single object.
To rename multiple objects at once, click
in the upper-right corner of Selected Objects. See Map multiple object names at a time.
Renaming an object may cause other objects that depend on it to fail migration.
To filter rows by condition, right-click a table in Selected Objects and specify a WHERE clause. See Use SQL conditions to filter data.
To select specific DML or DDL operations for a table, right-click the table in Selected Objects and select the operations. See SQL operations supported for incremental migration.
Advanced settings
| Parameter | Description |
|---|---|
| Set Alerts | Select Yes to receive notifications when the task fails or migration latency exceeds the threshold. Configure alert thresholds and contacts. See Configure monitoring and alerting when you create a DTS task. |
| Capitalization of object names in destination instance | Controls how DTS handles capitalization for database, table, and column names in the destination. See Specify the capitalization of object names in the destination instance. |
| 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). Important
pt-online-schema-change is not supported — using it causes the DTS task to fail. Options: Yes (migrate temp table data, may extend task duration), No, Adapt to DMS Online DDL (migrate only original DDL; destination tables may be locked), No, Adapt to gh-ost (migrate only original DDL; destination tables may be locked). |
| Retry time for failed connections | How long DTS retries after a connection failure. Valid range: 10–1,440 minutes. Default: 720 minutes. Set a value greater than 30 minutes. If DTS reconnects within this window, the task resumes automatically. |
For retry time, if multiple tasks share the same source or destination database, the most recently set value takes precedence. DTS charges for the instance during retry periods — release the instance promptly after migration completes.
Step 6: Run the precheck
Click Next: Save Task Settings and Precheck.
DTS runs a precheck before starting the task. To resolve failures:
-
For failed items: click View Details, fix the issue, then click Precheck Again.
-
For alert items that can be ignored: click Confirm Alert Details > Ignore > OK, then click Precheck Again.
Ignoring alert items may cause data inconsistency.
Step 7: Purchase the instance
Wait for the Success Rate to reach 100%, then click Next: Purchase Instance.
On the Purchase Instance page, select an Instance Class for the migration instance. Higher instance classes provide faster migration speeds. See Specifications of data migration instances.
Step 8: Start the task
Read and accept the Data Transmission Service (Pay-as-you-go) Service Terms, then click Buy and Start.
Monitor the migration progress in the task list.