Data Transmission Service (DTS) migrates data from a self-managed MySQL database to a PolarDB for MySQL cluster with minimal downtime. This guide walks you through configuring and running a migration task, covering schema migration, full data migration, and incremental data migration.
In this guide, you:
-
Review prerequisites, permissions, and limits
-
Configure source and destination databases
-
Select migration types and objects
-
Run a precheck and purchase a migration instance
-
Verify the migration and cut over
Prerequisites
Before you begin, make sure that:
-
The self-managed MySQL database is connected to Alibaba Cloud, and the CIDR blocks of DTS servers are added to its security settings (security group rules, firewalls, whitelists). For details, see Preparation.
-
(For incremental migration) Binary logging is enabled on the source MySQL database. For details, see Create an account for a self-managed MySQL database and configure binary logging.
-
A destination PolarDB for MySQL cluster exists with storage space larger than the source database. See Purchase a pay-as-you-go cluster or Purchase a subscription cluster.
For supported database versions, see Overview of data migration scenarios.
Migration types
DTS supports three migration types, which can be combined:
| Migration type | What it does |
|---|---|
| Schema migration | Migrates schemas of selected objects (tables, views, triggers, stored procedures, stored functions) from source to destination. |
| Full data migration | Migrates all existing data from the source database. |
| Incremental data migration | After full data migration completes, continuously mirrors changes from source to destination, keeping the service running during migration. |
Schema migration behavior:
-
DTS changes the SECURITY attribute from DEFINER to INVOKER for views, stored procedures, and functions, and sets DEFINER to the destination database account used in the migration.
-
DTS does not migrate user information. Grant read and write permissions to INVOKER on the destination database to call views, stored procedures, or stored functions.
-
DTS migrates foreign keys from the source to the destination. During full and incremental data migration, DTS temporarily disables the constraint check and cascade operations on foreign keys at the session level.
SQL operations supported in incremental data migration:
| Operation type | Supported 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 operations can cause data inconsistency. If you select a table as the migration object and rename it during migration, data may not reach the destination. To prevent this, select the entire database as the migration object and make sure the databases containing the table before and after the rename are both included.
Billing
| Migration type | Instance configuration fee | Internet traffic fee |
|---|---|---|
| Schema migration + full data migration | Free | Charged only when Access Method is set to Public IP Address. See Billing overview. |
| Incremental data migration | Charged. See Billing overview. | — |
Permissions required
Grant the following permissions to the database accounts used by DTS:
| Database | Schema migration | Full migration | Incremental migration |
|---|---|---|---|
| Self-managed MySQL | SELECT | SELECT | SELECT on objects to be migrated; REPLICATION CLIENT; REPLICATION SLAVE; SHOW VIEW; permissions to create databases and tables (so DTS can create the test database to advance the binary log position) |
| PolarDB for MySQL cluster | Read and write | Read and write | Read and write |
For instructions, see:
-
Self-managed MySQL: Create an account for a self-managed MySQL database and configure binary logging
-
PolarDB for MySQL: Create and manage database accounts
Limitations
Source database
-
The server must have sufficient outbound bandwidth; otherwise migration speed decreases.
-
Tables must have PRIMARY KEY or UNIQUE constraints with all fields unique; otherwise duplicate records may appear in the destination.
-
When renaming tables or columns in the destination, a single task supports up to 1,000 tables. For more than 1,000 tables, configure multiple tasks or migrate the entire database.
-
During schema migration and full data migration, do not run DDL statements that change database or table schemas; the task will fail.
-
During full-only migration (no incremental), do not write to the source database; this causes data inconsistency. To maintain consistency, select schema migration, full data migration, and incremental data migration together.
-
Data generated by cascade operations or restored from a physical backup is not recorded in binary logs and will not be migrated.
-
If the source is MySQL 8.0.23 or later and the data includes invisible columns, those columns cannot be read and data loss occurs. To make a column visible, run:
ALTER TABLE <table_name> ALTER COLUMN <column_name> SET VISIBLE;
Tables without primary keys automatically generate invisible primary keys. Make those invisible primary keys visible before migration. See Generated Invisible Primary Keys.
Binary log requirements for incremental migration:
| Parameter | Required value | Notes |
|---|---|---|
binlog_format |
ROW |
If not set to ROW, the precheck fails and the task cannot start. |
binlog_row_image |
FULL |
If not set to FULL, the precheck fails and the task cannot start. |
log_slave_updates |
ON |
Required only when the source is a self-managed MySQL in a dual-primary cluster, so DTS can read all binary logs. |
| Binary log retention | At least 7 days (self-managed MySQL) | Binary logs of an ApsaraDB RDS for MySQL instance must be retained for at least 3 days; 7 days is recommended. If binary logs are purged too early, the task may fail or data inconsistency may occur. |
Self-managed MySQL source: special cases
-
If a primary/secondary switchover occurs on the source while the task is running, the task fails.
-
Migration latency is calculated based on the timestamp of the latest migrated data in the destination versus the current time in the source. If no DML operations are performed on the source for an extended period, the reported latency may be inaccurate. Run a DML operation on the source to refresh the latency value. If you migrate an entire database, create a heartbeat table that is updated every second.
-
DTS periodically runs
CREATE DATABASE IF NOT EXISTS \test\`` on the source to advance the binary log position.
ApsaraDB RDS for MySQL source: special cases
-
In incremental data migration, an ApsaraDB RDS for MySQL instance that does not record transaction logs, such as a read-only ApsaraDB RDS for MySQL V5.6 instance, cannot be used as the source database.
-
DTS periodically runs
CREATE DATABASE IF NOT EXISTS \test\`` on the source to advance the binary log position.
Destination database (PolarDB for MySQL)
-
DTS automatically creates databases in the destination cluster. If the source database name does not comply with PolarDB for MySQL naming conventions, manually create the database before configuring the task. See Manage databases.
-
Throttling is not available for full data migration to PolarDB for MySQL.
Other limitations
-
The source and destination MySQL versions must match.
-
DTS does not migrate data that uses parser definitions specified via comments.
-
Schedule migration during off-peak hours. Full data migration uses read and write resources of both databases and increases server load.
-
After full data migration, concurrent INSERT operations create table fragmentation in the destination, making its tablespace larger than the source.
-
If data contains four-byte characters (rare characters, emojis), the destination database and tables must use the UTF8mb4 character set. If you use DTS schema migration, set
character_set_serverto UTF8mb4 in the destination database. -
DTS uses
ROUND(COLUMN, PRECISION)to read FLOAT and DOUBLE columns. Default precision: 38 digits for FLOAT, 308 digits for DOUBLE. Verify that precision settings meet your requirements. -
DTS retries failed tasks for up to 7 days. Before switching workloads to the destination, stop or release any failed task, or revoke write permissions from DTS accounts. Otherwise, the source database may overwrite destination data when a failed task resumes.
-
DATETIME values cannot be converted to VARCHAR.
-
If DDL statements fail in the destination, the DTS task continues running. View failed DDL statements in task logs.
-
If the source is an ApsaraDB RDS for MySQL instance with EncDB enabled, full data migration is not supported. Transparent Data Encryption (TDE) is supported for all three migration types.
-
To migrate accounts, see Migrate database accounts.
-
If a DTS task fails, DTS technical support attempts to restore it within 8 hours. The task may be restarted and certain task parameters may be modified during restoration. Database parameters are not modified.
Configure and run a migration task
Step 1: Open the Data Migration page
Use either console to start:
DTS console
-
Log on to the DTS console.
-
In the left-side navigation pane, click Data Migration.
-
In the upper-left corner, select the region where the migration instance resides.
DMS console
The actual operation may vary based on the mode and layout of the DMS console. For more information, see Simple mode and Customize the layout and style of the DMS console.
-
Log on to the DMS console
-
In the top navigation bar, go to .
-
In the drop-down list to the right of Data Migration Tasks, select the region.
Step 2: Configure source and destination databases
Click Create Task to open the task configuration page.
After configuring the source and destination databases, read the Limits displayed at the top of the page before proceeding; otherwise the task may fail or data inconsistency may occur.
Task Name
| Parameter | Description |
|---|---|
| Task Name | DTS generates a name automatically. Specify a descriptive name to identify the task easily. The name does not need to be unique. |
Source Database
| Parameter | Description |
|---|---|
| Select Existing Connection | Select a registered instance to auto-populate parameters, or configure the connection manually. |
| Database Type | Select MySQL. |
| Access Method | Select the connection type based on the source database location. This guide uses Public IP. For other instance types, see Overview of preparations. |
| Instance Region | The region where the self-managed MySQL database resides. |
| Hostname or IP address | The public IP address or hostname of the source database. |
| Port | The service port of the source database, which must be open to the internet. Default: 3306. |
| Database Account | The account for the source database. See Permissions required. |
| Database Password | The password for the account. |
| Encryption | Non-encrypted (if SSL is not enabled) or SSL-encrypted (if SSL is enabled; upload a CA Certificate and configure the CA Key). |
Destination Database
| Parameter | Description |
|---|---|
| Select Existing Connection | Select a registered instance to auto-populate parameters, or configure the connection manually. |
| Database Type | Select PolarDB for MySQL. |
| Access Method | Select Cloud Instance. |
| Instance Region | The region where the destination PolarDB for MySQL cluster resides. |
| PolarDB Instance ID | The ID of the destination PolarDB for MySQL cluster. |
| Database Account | The account for the destination cluster. See Permissions required. |
| Database Password | The password for the account. |
| Encryption | Configure based on your requirements. See Configure SSL encryption. |
Step 3: Test connectivity
At the bottom of the page, click Test Connectivity and Proceed, then click Test Connectivity in the CIDR Blocks of DTS Servers dialog.
Make sure the CIDR blocks of DTS servers can be added (automatically or manually) to the security settings of both databases. See Add the CIDR blocks of DTS servers.
Step 4: Select migration objects and types
On the Configure Objects page, configure the following:
| Parameter | Description |
|---|---|
| Migration Types | Select Schema Migration and Full Data Migration for a one-time migration. To maintain service continuity, also select Incremental Data Migration. If you omit Schema Migration, manually create the target database and tables, and enable object name mapping in Selected Objects. |
| Method to migrate triggers in source database | Select a trigger migration method based on your requirements. Available only when Migration Types includes Schema Migration. See Configure the method to synchronize or migrate triggers. |
| Processing mode of conflicting tables | Precheck and Report Errors: fails the precheck if identical table names exist in source and destination (use object name mapping to rename conflicting tables). Ignore Errors and Proceed: skips the precheck for identical table names. Note that data inconsistency may result: during full data migration, DTS does not migrate the conflicting record and the existing destination record is retained; during incremental data migration, DTS migrates the record and the existing destination record is overwritten. |
| Whether to migrate event | Select Yesalert notification settings to migrate events, then complete the follow-up steps. See Synchronize or migrate events. |
| Capitalization of object names in destination instance | Controls case of database, table, and column names in the destination. Default: DTS default policy. See Specify the capitalization of object names. |
| Source Objects | Select objects and click |
| Selected Objects | Right-click an object to rename it individually, or click Batch Edit for bulk renaming. To filter rows, right-click a table and set a WHERE condition. To restrict SQL operations at the database or table level, right-click and select the operations to include. |
Step 5: Configure advanced settings
Click Next: Advanced Settings and configure:
| Parameter | Description |
|---|---|
| Dedicated cluster for task scheduling | By default, DTS uses the shared cluster. For higher stability, purchase a dedicated cluster. See What is a DTS dedicated cluster. |
| Select the engine type of the destination database | InnoDB (default) or X-Engine (Online Transaction Processing (OLTP) storage engine). |
| Copy the temporary table of the online DDL tool | Controls handling of temporary tables created by online DDL tools. Yes: migrates temporary table data (may increase latency). No, Adapt to DMS Online DDL: migrates only the original DDL from DMS (destination tables may lock). No, Adapt to gh-ost: migrates only original DDL from gh-ost (destination tables may lock). Do not use pt-online-schema-change; it causes task failure. |
| Whether to migrate accounts | Select Yes to migrate accounts; then select accounts and confirm permissions. See Migrate database accounts. |
| Retry time for failed connections | Duration DTS retries reconnecting after a connection failure. Range: 10–1,440 minutes. Default: 720 minutes. We recommend that you set the parameter to a value greater than 30 minutes. |
| Retry time for other issues | Duration DTS retries after DDL or DML failures. Range: 1–1,440 minutes. Default: 10 minutes. We recommend that you set the parameter to a value greater than 10 minutes. Must be smaller than Retry time for failed connections. |
| Enable throttling for full data migration | Limits QPS, RPS, and migration speed to reduce load on the destination. Configure QPS to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s). Available only when Full Data Migration is selected. |
| Enable throttling for incremental data migration | Limits RPS and migration speed for incremental migration. Configure RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s). Available only when Incremental Data Migration is selected. |
| Whether to delete SQL operations on heartbeat tables | Yes: DTS does not write heartbeat table operations to the source (migration latency may be displayed). No: DTS writes heartbeat table operations to the source (may affect source database physical backup and cloning). |
| Configure ETL | Yes: enables extract, transform, and load (ETL); enter processing statements in the code editor. No: ETL is disabled. See What is ETL? |
| Monitoring and alerting | Yes: configures alerts for task failures or latency exceeding a threshold. See Configure monitoring and alerting. |
Step 6: Configure data verification (optional)
Click Next Step: Data Verification to set up a data verification task. See Configure a data verification task.
Step 7: Run the precheck and purchase an instance
-
Click Next: Save Task Settings and Precheck.
To preview the API parameters for this task configuration, hover over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters.
-
Wait for the precheck to complete.
-
If an item fails, click View Details, fix the issue, then click Precheck Again.
-
If an alert is triggered for an item that can be ignored, click Confirm Alert Details > Ignore > OK, then click Precheck Again.
-
-
When Success Rate reaches 100%, click Next: Purchase Instance.
-
On the Purchase Instance page, set the Instance Class:
Parameter Description Resource Group The resource group for the migration instance. Default: default resource group. Instance Class The instance class determines migration speed. Select based on your requirements. See Instance classes of data migration instances. -
Select the Data Transmission Service (Pay-as-you-go) Service Terms check box, then click Buy and Start > OK.
View the task progress on the Data Migration page:
-
Schema migration or full-only migration: the task stops automatically. Status shows Completed.
-
Incremental data migration: the task runs continuously and does not stop automatically. Status shows Running.