Data Transmission Service (DTS) lets you migrate data from an ApsaraDB RDS for MySQL instance to an ApsaraMQ for Kafka instance — streaming both your existing historical data and ongoing changes into Kafka topics with no application downtime.
How it works
DTS runs migration in up to three sequential phases:
Schema migration: DTS reads the table definitions from the source MySQL instance and prepares the destination.
Full data migration: DTS copies all existing rows from the selected tables into the specified Kafka topic. Concurrent INSERT operations during this phase may cause the destination tablespace to be larger than the source.
Incremental data migration: After full data migration finishes, DTS reads the MySQL binary log and streams INSERT, UPDATE, and DELETE events to the Kafka topic in real time. This phase runs continuously — the task never auto-stops — so your applications can keep writing to the source without interruption.
DTS does not migrate foreign keys. Cascade and delete operations triggered in the source are not replicated.
Prerequisites
Before you begin, make sure you have:
An ApsaraDB RDS for MySQL instance (source) and an ApsaraMQ for Kafka instance (destination), both already created. See Create an ApsaraDB RDS for MySQL instance if you need to create the RDS instance.
Available storage in the destination ApsaraMQ for Kafka instance that exceeds the total size of your source data.
A topic created in the destination ApsaraMQ for Kafka instance to receive the migrated data. See the "Step 1: Create a topic" section in Step 3: Create resources.
A Kafka cluster running version 0.10.1.0 to 2.0.
Read permissions on the objects to be migrated granted to the source database account. Grant the required permission:
GRANT SELECT ON <database_name>.* TO '<dts_user>'@'%';
Limitations
Source database
| Constraint | Details |
|---|---|
| Bandwidth | The source server must have enough outbound bandwidth. Low bandwidth reduces migration speed. |
| Primary key requirement | Tables must have PRIMARY KEY or UNIQUE constraints with unique field values. Without them, the destination may contain duplicate records. |
| Table count (when renaming) | If you select tables as migration objects and rename tables or columns in the destination, a single task supports up to 1,000 tables. For more than 1,000 tables, split into multiple tasks or migrate the entire database. |
| DDL operations during migration | Do not run DDL statements that change database or table schemas during schema migration or full data migration. The task will fail. |
| Writes during full-data-only migration | If you do not include incremental data migration, do not write to the source during migration. To guarantee consistency, select schema migration, full data migration, and incremental data migration together. |
| Binary log data | Change data generated by physical backup restores or cascade operations is not recorded in the binary log and will not be migrated. |
| MySQL 8.0.23+ invisible columns | DTS cannot read invisible columns — data loss occurs. Run ALTER TABLE <table_name> ALTER COLUMN <column_name> SET VISIBLE; before starting the task. Tables without primary keys auto-generate invisible primary keys; make these visible too. See Invisible Columns and Generated Invisible Primary Keys. |
| FLOAT/DOUBLE precision | DTS uses ROUND(COLUMN, PRECISION) to retrieve values. If you don't specify precision, DTS sets FLOAT to 38 digits and DOUBLE to 308 digits. Verify that these defaults meet your requirements. |
Binary log requirements for incremental migration
Before enabling incremental data migration, verify and configure these MySQL settings:
| Setting | Required value | How to check |
|---|---|---|
binlog_format | row | SHOW GLOBAL VARIABLES LIKE 'binlog_format'; |
binlog_row_image | full | SHOW GLOBAL VARIABLES LIKE 'binlog_row_image'; |
log_slave_updates | ON (self-managed dual-primary clusters only) | SHOW GLOBAL VARIABLES LIKE 'log_slave_updates'; |
| Binary log retention (RDS MySQL) | At least 3 days (7 days recommended) | See Configure parameters for automatic binary log deletion |
| Binary log retention (self-managed MySQL) | At least 7 days | SHOW VARIABLES LIKE 'expire_logs_days'; |
For self-managed MySQL instances, you can fix non-compliant settings by running the corresponding command:
-- Set binlog format
SET GLOBAL binlog_format = 'ROW';
-- Set binlog row image
SET GLOBAL binlog_row_image = 'FULL';For ApsaraDB RDS for MySQL instances, binary log parameters must be modified through the RDS console, not by running SET GLOBAL commands directly. If binary log retention is set below the minimum, DTS may fail to read the logs and the task may fail. In exceptional cases, data inconsistency or loss may occur. This affects your Service Level Agreement (SLA) with DTS.
Other limitations
You can select only tables as the objects to be migrated.
Migrate during off-peak hours to reduce load on the source and destination servers.
Before switching production workloads to the destination, stop or release any DTS tasks that failed in the last 7 days. DTS attempts to resume failed tasks automatically, which could overwrite data in the destination. Alternatively, revoke write permissions from the DTS accounts on the destination.
If data from other sources is written to the destination during migration, data inconsistency will occur.
If the destination Kafka cluster is upgraded or downgraded during migration, restart the migration task.
If Transparent Data Encryption (TDE) is enabled on the source RDS MySQL instance, schema migration, full data migration, and incremental data migration are all supported. If the EncDB feature is enabled instead, full data migration is not supported.
If a DTS task fails, DTS technical support will attempt to restore it within 8 hours. During restoration, the task may be restarted and task-level parameters may be modified. Database parameters are not changed.
Special cases
Self-managed MySQL:
If a primary/secondary switchover occurs while the task is running, the task fails.
Migration latency may appear inaccurate if no DML operations run on the source for a long time. Run any DML operation on the source to refresh the latency. If you migrated an entire database, create a heartbeat table that receives updates every second.
DTS periodically runs
CREATE DATABASE IF NOT EXISTS \test\`` on the source to advance the binary log position.
ApsaraDB RDS for MySQL:
Read-only RDS MySQL V5.6 instances (which do not record transaction logs) cannot be used as the source for incremental data migration.
DTS periodically runs
CREATE DATABASE IF NOT EXISTS \test\`` on the source to advance the binary log position.
Billing
| Migration type | Task configuration fee | Internet traffic fee |
|---|---|---|
| Schema migration + full data migration | Free | Charged only when data crosses Alibaba Cloud over the Internet. See Billing overview. |
| Incremental data migration | Charged. See Billing overview. | Same as above. |
Supported SQL operations for incremental migration
| Operation type | SQL statements |
|---|---|
| DML | INSERT, UPDATE, DELETE |
| DDL | CREATE TABLE, ALTER TABLE, DROP TABLE, RENAME TABLE, TRUNCATE TABLE |
| CREATE VIEW, ALTER VIEW, DROP VIEW | |
| CREATE PROCEDURE, ALTER PROCEDURE, DROP PROCEDURE | |
| CREATE FUNCTION, DROP FUNCTION, CREATE TRIGGER, DROP TRIGGER | |
| CREATE INDEX, DROP INDEX |
Kafka message format
DTS writes records to Kafka in one of two formats. Select the format that matches your consumer implementation.
DTS Avro
Records follow the DTS Avro schema definition. See the schema on GitHub.
Canal JSON
Records are written in Canal JSON format. The following example shows a typical INSERT event:
{
"data": [
{
"id": "1",
"name": "example_value",
"updated_at": "2026-01-01 00:00:00"
}
],
"database": "example_db",
"es": 1735689600000,
"id": 1,
"isDdl": false,
"mysqlType": {
"id": "int(11)",
"name": "varchar(255)",
"updated_at": "datetime"
},
"old": null,
"pkNames": ["id"],
"sql": "",
"sqlType": {
"id": 4,
"name": 12,
"updated_at": 93
},
"table": "example_table",
"ts": 1735689600123,
"type": "INSERT"
}For UPDATE events, the old field contains the before-image values (the column values before the change).
For full parameter details and sample consumer code, see Canal JSON data format.
Create the migration task
Step 1: Go to the Data Migration page
Use either 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 will reside.
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 to the right of Data Migration Tasks, select the region where the migration instance will reside.
Step 2: Configure the source and destination databases
Click Create Task.
WarningAfter configuring the source and destination, read the Limits displayed at the top of the page before proceeding. Skipping this step may cause the task to fail or data inconsistency.
Configure the parameters in the following table.
Source Database
| Parameter | Description |
|---|---|
| Task Name | A name for the DTS task. DTS generates a default name. Use a descriptive name to make the task easy to identify — uniqueness is not required. |
| Select Existing Connection | If the source instance is already registered with DTS, select it from the list — DTS fills in the remaining parameters automatically. Otherwise, configure the parameters below. |
| Database Type | Select MySQL. |
| Connection Type | Select Alibaba Cloud Instance. |
| Instance Region | The region where the source ApsaraDB RDS for MySQL instance resides. |
| Cross-account | Select No for same-account migration. |
| RDS Instance ID | The ID of the source ApsaraDB RDS for MySQL instance. |
| Database Account | A database account with read permissions on the objects to be migrated. |
| Database Password | The password for the database account. |
| Encryption | Select Non-encrypted or SSL-encrypted. To use SSL, first enable SSL encryption on the RDS instance. See Use a cloud certificate to enable SSL encryption. |
Destination Database
| Parameter | Description |
|---|---|
| Select Existing Connection | If the destination instance is already registered with DTS, select it from the list. Otherwise, configure the parameters below. |
| Database Type | Select Kafka. |
| Connection Type | Select Alibaba Cloud Instance. |
| Instance Region | The region where the destination ApsaraMQ for Kafka instance resides. |
| Kafka Instance ID | The ID of the destination ApsaraMQ for Kafka instance. |
| Encryption | Select Non-encrypted or SCRAM-SHA-256 based on your security requirements. |
| Topic | The topic that receives the migrated data. Select from the drop-down list. |
| Topic That Stores DDL Information | The topic that stores DDL event data. If left blank, DDL information is written to the topic specified in Topic. |
| Use Kafka Schema Registry | Whether to use Kafka Schema Registry for schema management. Select No or Yesalert notification settings. If Yes, enter the URL or IP address registered in Kafka Schema Registry for your Avro schemas. |
Click Test Connectivity and Proceed.
DTS must be able to access the source and destination. Add the CIDR blocks of DTS servers to the security settings of both databases. See Add the CIDR blocks of DTS servers. If the source or destination is a self-managed database with an access method other than Alibaba Cloud Instance, click Test Connectivity in the CIDR Blocks of DTS Servers dialog box.
Step 3: Select migration objects and configure settings
On the Configure Objects page, set the following parameters.
| Parameter | Description |
|---|---|
| Migration Types | Select the migration types based on your needs: <br>- Schema migration + full data migration only: select Schema Migration and Full Data Migration. <br>- Zero-downtime migration with ongoing replication: select Schema Migration, Full Data Migration, and Incremental Data Migration. <br><br> Note Schema migration is not supported when the destination is an ApsaraMQ for Kafka instance. If you do not select incremental data migration, do not write to the source during migration. |
| Processing Mode for Existing Destination Tables | - Precheck and Report Errors: fails the precheck if the destination already has tables with the same names as the source. Use object name mapping to resolve naming conflicts. <br>- Ignore Errors and Proceed: skips the name conflict check. During full data migration, conflicting records in the destination are retained. During incremental data migration, they are overwritten. Use with caution. |
| Data Format in Kafka | The format in which records are written to Kafka: <br>- DTS Avro: records follow the DTS Avro schema. See the schema definition on GitHub. <br>- Canal JSON: records are written in Canal JSON format. See Canal JSON data format for parameter details and sample code. |
| Kafka Data Compression Format | The compression algorithm for Kafka messages: <br>- LZ4 (default): low compression ratio and high compression speed. <br>- GZIP: high compression ratio and low compression speed. GZIP consumes a large quantity of CPU resources. <br>- Snappy: medium compression ratio and medium compression speed. |
| Policy for Shipping Data to Kafka Partitions | How DTS routes records to Kafka partitions. See Specify the policy for migrating data to Kafka partitions. |
| Message acknowledgement mechanism | The acknowledgement policy DTS uses when writing to Kafka. See Message acknowledgement mechanism. |
| Capitalization of Object Names in Destination Instance | The case policy for database, table, and column names in the destination. The default is DTS default policy. See Specify the capitalization of object names. |
| Source Objects | Select one or more tables from Source Objects and click the arrow icon to move them to Selected Objects. Only tables can be selected. |
| Selected Objects | To route a source table to a specific topic, configure partitions, or set partition keys, use the object name mapping feature. See Use the object name mapping feature. To migrate specific DML or DDL operations on an object, right-click the object in Selected Objects and select the operations to include. |
Click Next: Advanced Settings.
| Parameter | Description |
|---|---|
| Dedicated Cluster for Task Scheduling | By default, DTS schedules the task on the shared cluster. For higher stability, purchase a dedicated cluster. See What is a DTS dedicated cluster. |
| Retry Time for Failed Connections | How long DTS retries after a connection failure. Valid values: 10–1,440 minutes. Default: 720. Set to at least 30. If DTS reconnects within this window, the task resumes. If not, the task fails. <br><br> Note When multiple tasks share the same source or destination, the most recently set retry time applies. You are billed during retries. |
| Retry Time for Other Issues | How long DTS retries after DDL or DML operation failures. Valid values: 1–1,440 minutes. Default: 10. Set to at least 10. This value must be less than Retry Time for Failed Connections. |
| Enable Throttling for Full Data Migration | Limits read/write throughput during full data migration to reduce load on the source. 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 throughput during incremental data 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 SQL to the source: <br>- Yes: DTS does not write heartbeat SQL. Migration latency may appear elevated in the console. <br>- No: DTS writes heartbeat SQL. Physical backup and cloning operations on the source may be affected. |
| Environment Tag | An optional tag to categorize the DTS instance by environment (for example, production or test). |
| Configure ETL | Whether to apply extract, transform, and load (ETL) transformations. Select Yes to write data processing statements in the code editor. See Configure ETL in a data migration or synchronization task. |
| Monitoring and Alerting | Whether to configure alerts for task failures or high migration latency. Select Yes and configure alert thresholds and notification contacts. See Configure monitoring and alerting. |
Step 4: Run the precheck
To preview the API parameters for this task, hover over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters.
Click Next: Save Task Settings and Precheck. DTS runs an automated precheck before starting the task. If any item fails:
Click View Details next to the failed item, fix the issue, then click Precheck Again.
If an alert item is non-critical and can be ignored, click Confirm Alert Details > Ignore > OK, then click Precheck Again. Ignoring alerts may lead to data inconsistency.
Step 5: Purchase the instance and start the task
Wait for Success Rate to reach 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 | The instance class determines migration throughput. See Instance classes of data migration instances. |
Read and accept Data Transmission Service (Pay-as-you-go) Service Terms by selecting the check box.
Click Buy and Start, then click OK in the confirmation dialog.
Verify the task
On the Data Migration page, check the task status:
Completed: the task included only schema migration and full data migration. No incremental migration is running.
Running: the task includes incremental data migration. The task runs continuously and does not auto-stop.
Use the object name mapping feature
Use this feature to route source table data to a specific Kafka topic, control the number of partitions, or set partition keys for hash-based routing.
In the Selected Objects section, hover over a table name.
Right-click and select Edit.
In the dialog box, configure the following parameters.
| Parameter | Description |
|---|---|
| Table Name | The name of the Kafka topic that receives data from this source table. Defaults to the topic specified in Destination Database settings. <br><br> Important When the destination is ApsaraMQ for Kafka, the topic must already exist in the instance. For self-managed Kafka clusters with schema migration included, DTS creates the topic automatically. Changing this value routes the table's data to the specified topic. |
| Filter Conditions | SQL filter conditions to selectively migrate rows. See Specify filter conditions. |
| Number of Partitions | The number of partitions in the target topic. |
| Partition Key | One or more columns used to calculate hash values for partition routing. Available only when Policy for Shipping Data to Kafka Partitions is set to Ship Data to Separate Partitions Based on Hash Values of Primary Keys. Clear Synchronize All Tables before selecting partition key columns. |
Click OK.
If you rename an object using object name mapping, other objects that depend on it may fail to migrate.