Data Transmission Service (DTS) migrates data from ApsaraDB RDS for MySQL to a MaxCompute project in three stages: schema migration, full data migration, and incremental data migration. This topic walks you through creating and running a DTS migration task.
Prerequisites
Before you begin, ensure that you have:
A MaxCompute project with available storage space larger than the total size of data in the source ApsaraDB RDS for MySQL database. For more information, see Create a MaxCompute project.
An IP address whitelist configured for the MaxCompute project to allow access from DTS. For more information, see Configure an IP address whitelist to allow access from Alibaba Cloud services to MaxCompute.
An AccessKey pair for the Alibaba Cloud account that owns the destination MaxCompute project. For more information, see Create an AccessKey pair.
Alternatively, create a RAM user and set it as the super administrator for the MaxCompute project.
Migration types
DTS supports three migration types for this scenario. Select the combination that fits your requirements.
| Migration type | What DTS does | Naming in MaxCompute |
|---|---|---|
| Schema migration | Migrates table schemas from the source database to MaxCompute | Appends _base to each source table name. For example, customer becomes customer_base. |
| Full data migration | Migrates all historical data to the _base table | customer → customer_base (the full baseline table) |
| Incremental data migration | Continuously migrates changes (INSERT, UPDATE, DELETE) to a separate _log table | customer → customer_log (the incremental data table) |
Choose your migration combination:
Full migration only (Schema Migration + Full Data Migration): Use when you can pause writes to the source database during migration. Lower cost — schema and full data migration are free.
Full + incremental migration (Schema Migration + Full Data Migration + Incremental Data Migration): Use when you need continuous service during migration. Incremental data migration is charged separately.
During incremental data migration, DTS migrates the following SQL operations:
| Operation type | SQL statements |
|---|---|
| DML | INSERT, UPDATE, DELETE |
| DDL | ADD COLUMN (ADD COLUMN with attribute columns is not supported) |
Permissions required
Grant the following permissions to the database accounts used by DTS.
| Database | Schema migration | Full data migration | Incremental data migration |
|---|---|---|---|
| RDS MySQL | SELECT | SELECT | SELECT, REPLICATION SLAVE, REPLICATION CLIENT (DTS grants these automatically) |
| MaxCompute | Read and write | Read and write | Read and write |
For more information about how to create a database account and grant the required permissions, see Create an account and Modify account permissions.
Limitations
DTS does not migrate foreign keys. Cascade and delete operations defined in the source database are not applied to the destination.
Source database limitations:
Tables must have PRIMARY KEY or UNIQUE constraints, with all fields unique. Otherwise, the destination database may contain duplicate records.
When renaming tables or columns during migration, a single task supports up to 1,000 tables. For more than 1,000 tables, configure multiple tasks or migrate the entire database at once.
For incremental data migration, binary logging must be enabled with the following configuration: To verify that binary logging is correctly configured, run:
binlog_format=rowbinlog_row_image=fullFor self-managed MySQL in a dual-primary cluster:
log_slave_updates=ONBinary logs on ApsaraDB RDS for MySQL: retain for at least 3 days (7 days recommended)
Binary logs on self-managed MySQL: retain for at least 7 days
ImportantIf binary logs are not retained for the minimum required period, DTS may fail to obtain them, causing task failure or data loss. Failure to meet these requirements may affect the service reliability and performance guaranteed by the DTS Service Level Agreement (SLA). For details on setting the retention period for ApsaraDB RDS for MySQL binary logs, see Configure parameters based on which the system automatically deletes the binary log files of an RDS instance.
SHOW VARIABLES LIKE 'binlog_format'; SHOW VARIABLES LIKE 'binlog_row_image';Both values must match the required settings before starting the migration task.
Do not perform DDL operations during schema migration or full data migration. Doing so causes task failure.
For MySQL 8.0.23 and later: invisible columns cannot be migrated, resulting in data loss.
To make a column visible:
ALTER TABLE <table_name> ALTER COLUMN <column_name> SET VISIBLE;. See Invisible Columns.Tables without primary keys generate invisible primary keys automatically — make those visible too. See Generated Invisible Primary Keys.
Read-only ApsaraDB RDS for MySQL V5.6 instances cannot be used as the source for incremental data migration (no transaction logs).
Other limitations:
The following object types cannot be migrated: INDEX, PARTITION, VIEW, PROCEDURE, FUNCTION, TRIGGER, and foreign key (FK).
MaxCompute does not support primary key constraints. If DTS re-transmits data (for example, after a network interruption), duplicate records may appear.
Do not use tools such as pt-online-schema-change for DDL operations during migration. Doing so may cause migration failure.
DTS retrieves FLOAT and DOUBLE values using the
ROUND(COLUMN, PRECISION)function. Default precision: 38 digits for FLOAT, 308 digits for DOUBLE. Verify that these precision settings meet your business requirements.Schedule migration during off-peak hours. Full data migration uses read and write resources on both the source and destination databases and may increase server load.
After full data migration completes, the tablespace used in the destination database is larger than in the source database due to fragmentation from concurrent INSERT operations.
DTS attempts to resume failed tasks for up to 7 days. Before switching workloads to the destination, stop or release the migration task — or revoke write permissions from the DTS account — to prevent source data from overwriting destination data.
ApsaraDB RDS for MySQL instances with EncDB enabled do not support full data migration.
ApsaraDB RDS for MySQL instances with Transparent Data Encryption (TDE) enabled support schema migration, full data migration, and incremental data migration.
If a DTS instance fails, the DTS helpdesk attempts recovery within 8 hours. During recovery, instance parameters may be adjusted. For details, see Modify instance parameters.
Special cases for self-managed MySQL:
A primary/secondary switchover during migration causes task failure.
If no DML operations occur on the source database for an extended period, migration latency readings may be inaccurate. Run a DML operation to refresh the latency display.
DTS periodically executes
CREATE DATABASE IF NOT EXISTS \test\`` on the source database to advance the binary log position.
Special cases for ApsaraDB RDS for MySQL:
Read-only V5.6 instances cannot be used for incremental data migration.
DTS periodically executes
CREATE DATABASE IF NOT EXISTS \test\`` on the source database to advance the binary log position.
Billing
| Migration type | Task configuration fee | Internet traffic fee |
|---|---|---|
| Schema migration and full data migration | Free | No charge in this example. If Access Method is set to Public IP Address, internet traffic fees apply. See Billing overview. |
| Incremental data migration | Charged. See Billing overview. | — |
Create a migration task
Step 1: Open the Data Migration page
Use either the DTS console or the DMS console.
DTS console
Log on to the DTS console.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 steps may vary based on the DMS console mode and layout. See Simple mode and Customize the layout and style of the DMS console.
Log on to the DMS console.DMS console
In the top navigation bar, move the pointer over Data + AI > DTS (DTS) > Data Migration.
From the drop-down list next to Data Migration Tasks, select the region.
Step 2: Configure source and destination databases
Click Create Task.
Configure the following parameters:
General
| Parameter | Description |
|---|---|
| Task Name | DTS generates a name automatically. Specify a descriptive name for easier identification. Task names do not need to be unique. |
Source Database
| Parameter | Description |
|---|---|
| Select Existing Connection | If the instance is registered with DTS, select it from the drop-down list — DTS populates the remaining fields automatically. Otherwise, configure the fields below manually. In the DMS console, select from Select a DMS database instance. |
| Database Type | Select MySQL. |
| Access Method | Select Cloud Instance. |
| Instance Region | Select the region of the source ApsaraDB RDS for MySQL instance. |
| Replicate Data Across Alibaba Cloud Accounts | Select No for same-account migrations. |
| RDS Instance ID | Enter the ID of the source instance. |
| Database Account | Enter the database account. See Permissions required for the required permissions. |
| Database Password | Enter the password for the database account. |
| Connection Method | Select Non-encrypted or SSL-encrypted. To use SSL encryption, enable SSL on the ApsaraDB RDS for MySQL instance first. See Use a cloud certificate to enable SSL encryption. |
Destination Database
| Parameter | Description |
|---|---|
| Select Existing Connection | If the instance is registered with DTS, select it from the drop-down list. Otherwise, configure the fields below manually. In the DMS console, select from Select a DMS database instance. |
| Database Type | Select MaxCompute. |
| Access Method | Select Alibaba Cloud Instance. |
| Instance Region | Select the region of the destination MaxCompute project. |
| Project | Enter the name of the MaxCompute project. |
| AccessKey ID of Alibaba Cloud Account | Enter the AccessKey ID of the Alibaba Cloud account that owns the MaxCompute project. See Prerequisites. |
| AccessKey Secret of Alibaba Cloud Account | Enter the AccessKey Secret of the account. |
Click Test Connectivity and Proceed.
DTS automatically adds its server CIDR blocks to the security settings of the source and destination databases. For manual configuration, see Add DTS server IP addresses to a whitelist.
For self-managed databases where Access Method is not Alibaba Cloud Instance, click Test Connectivity in the CIDR Blocks of DTS Servers dialog box.
Click OK to grant permissions to the MaxCompute account.
Step 3: Configure objects to migrate
On the Configure Objects page, configure the following parameters:
| Parameter | Description |
|---|---|
| Migration Types | Select the migration types based on your scenario: <br>- Schema Migration + Full Data Migration: full migration only (no ongoing sync) <br>- Schema Migration + Full Data Migration + Incremental Data Migration: continuous migration with minimal downtime <br><br> Note If you skip Schema Migration, create the destination database and table manually and enable object name mapping in Selected Objects. If you skip Incremental Data Migration, do not write to the source database during migration to maintain data consistency. |
| Naming Rules of Additional Columns | After migration, DTS adds extra columns to the destination table. Select New Rule or Previous Rule. Check for naming conflicts with existing columns before configuring. See Naming rules for additional columns. |
| Partition Definition of Incremental Data Table | Select partition names based on your requirements. See Partition. |
| Processing Mode of Conflicting Tables | Precheck and Report Errors: fails the precheck if tables with identical names exist in both databases. Use object name mapping to resolve conflicts. See Map object names. <br><br>Ignore Errors and Proceed: skips the identical-name check. <br> Warning Data inconsistency risks: during full migration, DTS skips conflicting records; during incremental migration, DTS overwrites them. If schemas differ, only specific columns may migrate or the task may fail. |
| Capitalization of Object Names in Destination Instance | Controls the case of database, table, and column names in the destination. Default: DTS default policy. See Specify the capitalization of object names in the destination instance. |
| Source Objects | Select the objects to migrate. Click |
| Selected Objects | To rename a single object, right-click it. To rename multiple objects, click Batch Edit. See Map object names. To filter rows, right-click a table and specify WHERE conditions. See Specify filter conditions. Note Renaming an object may cause dependent objects to fail migration. |
Step 4: Configure advanced settings
Click Next: Advanced Settings and configure the following parameters:
| Parameter | Description |
|---|---|
| Dedicated Cluster for Task Scheduling | By default, DTS schedules tasks on the shared cluster. Purchase a dedicated cluster to improve stability. See What is a DTS dedicated cluster. |
| Retry Time for Failed Connections | Duration DTS retries after a connection failure. Valid values: 10–1,440 minutes. Default: 720 minutes. Set to more than 30 minutes. If reconnected within this window, DTS resumes the task. Note Multiple tasks sharing the same source or destination database use the most recently set value. DTS charges for the instance during retries — set the value based on your business requirements. |
| Retry Time for Other Issues | Duration DTS retries after DDL or DML operation failures. Valid values: 1–1,440 minutes. Default: 10 minutes. Set to more than 10 minutes. Must be less than Retry Time for Failed Connections. |
| Enable Throttling for Full Data Migration | Limits read/write resource usage during full data migration to reduce source and destination server load. Configure Queries per second (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 resource usage during 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 of forward and reverse tasks | Controls whether DTS writes heartbeat table operations to the source database while running. Yesalert notification settings: does not write — a latency indicator may appear. No: writes heartbeat operations — may affect physical backup and cloning of the source database. |
| Environment Tag | Identifies the DTS instance environment. Optional. |
| Configure ETL | Enables extract, transform, and load (ETL) processing. Yes: enter data processing statements in the code editor. See Configure ETL in a data migration or data synchronization task. No: skips ETL. |
| Monitoring and Alerting | Configures alerts for task failures or latency exceeding a threshold. Yes: specify alert thresholds and contacts. See Configure monitoring and alerting when you create a DTS task. No: no alerts. |
Step 5: Save settings and 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 starting the migration. The task starts only after the precheck passes.
If the precheck fails, click View Details next to the failed item, fix the issue, and run the precheck again.
If a precheck item triggers an alert: for blocking alerts, fix the issue and rerun. For ignorable alerts, click Confirm Alert Details, click Ignore in the dialog box, confirm, then click Precheck Again. Ignoring alerts may cause data inconsistency.
Step 6: Purchase an instance
Wait until Success Rate reaches 100%, then click Next: Purchase Instance.
On the Purchase Instance page, configure the following:
| Section | Parameter | Description |
|---|---|---|
| New Instance Class | Resource Group | The resource group for the migration instance. Default: default resource group. See What is Resource Management? |
| Instance Class | Controls migration speed. Select based on your scenario. See Instance classes of data migration instances. |
Read and select the Data Transmission Service (Pay-as-you-go) Service Terms check box.
Click Buy and Start, then click OK in the confirmation dialog.
Track task progress on the Data Migration page.
Tasks without incremental migration stop automatically when complete. Status: Completed.
Tasks with incremental migration run continuously and never stop automatically. Status: Running.
Schema of an incremental data table
DTS migrates incremental data to a _log table in MaxCompute. Before querying this table, run the following command to enable full table scan:
set odps.sql.allow.fullscan=true;The incremental data table has the following schema:
| Field | Description |
|---|---|
record_id | Unique identifier of the log entry. Auto-increments with each new entry. For UPDATE operations, DTS generates two entries (pre-update and post-update) with the same record_id. |
operation_flag | Operation type: I (INSERT), D (DELETE), U (UPDATE). |
utc_timestamp | Timestamp of the operation in UTC, corresponding to the binary log timestamp. |
before_flag | Whether the column values are pre-update values. Valid values: Y and N. |
after_flag | Whether the column values are post-update values. Valid values: Y and N. |
What's next
Synchronize data from an ApsaraDB RDS for MySQL instance to a MaxCompute project — learn about the incremental data table schema in detail
Map object names — rename objects during migration
Specify filter conditions — migrate a subset of rows using SQL WHERE conditions
Billing overview — understand DTS pricing