All Products
Search
Document Center

Data Transmission Service:Migrate data from an ApsaraDB RDS for MySQL instance to an ApsaraDB for ClickHouse cluster

Last Updated:Mar 28, 2026

Data Transmission Service (DTS) migrates data from ApsaraDB RDS for MySQL to ApsaraDB for ClickHouse, enabling centralized analytics on your operational data. This topic covers the end-to-end configuration for that migration path, including both full and incremental (CDC) migration.

Before you begin

Before starting the migration task, make sure the following requirements are met.

Destination cluster

  • The destination ApsaraDB for ClickHouse cluster runs version 20.8 or later. See Create a cluster.

  • Storage space on the destination cluster exceeds the storage used by the source RDS MySQL instance.

Source database account permissions

The source database account must have read permissions on the objects to migrate. If the account was not created through the RDS console, grant it the following permissions manually:

GRANT REPLICATION CLIENT, REPLICATION SLAVE, SHOW VIEW, SELECT ON *.* TO '<account>'@'%';

See Create an account and Modify account permissions.

Destination cluster account permissions

ClickHouse versionRequired permissionsHow to grant
22.8 or laterRead and write permissions (a privileged account meets this requirement)Manage accounts for a Community-compatible Edition cluster
21.8Read, Write and Set Permissions and Allow DDLManage accounts for a Community-compatible Edition cluster

Binary log requirements (incremental migration only)

If you plan to include incremental data migration, configure the following on the source MySQL instance.

Enable binary log retention

The minimum retention period depends on the source type:

  • ApsaraDB RDS for MySQL: Binary logs must be retained for at least 3 days (7 days recommended).

  • Self-managed MySQL: Binary logs must be retained for at least 7 days.

Logs retained for less than the required minimum may cause the migration task to fail or result in data loss. To set the retention period for an RDS MySQL instance, see Configure parameters based on which the system automatically deletes the binary log files of an RDS instance.

Configure binary log format

Set the following parameters on the source MySQL instance:

ParameterRequired value
binlog_formatROW
binlog_row_imageFULL

These settings are required for DTS to read row-level change data. If they are not set correctly, the precheck fails and the migration task cannot start.

If the source is a self-managed MySQL database deployed in a dual-primary cluster, also set log_slave_updates = ON so DTS can obtain all binary logs.

Billing

Migration typeCost
Schema migration + full data migrationFree of charge
Incremental data migrationCharged. See Billing overview.

Run data migration during off-peak hours. Full data migration consumes read and write resources on both the source and destination, which increases database load.

Supported SQL operations for incremental migration

Operation typeSupported SQL operations
DMLINSERT, UPDATE, DELETE
DDLCREATE TABLE, DROP TABLE, TRUNCATE TABLE, ADD COLUMN, MODIFY COLUMN, DROP COLUMN

Limitations

Source database restrictions

  • Table-level migration limit: A single migration task supports a maximum of 1,000 tables when object name mapping is used. If you exceed this limit, split the tables across multiple tasks or migrate the entire database.

  • Invisible columns (MySQL 8.0.23 and later): DTS cannot read invisible columns, which causes data loss. To make a column visible, run ALTER TABLE <table_name> ALTER COLUMN <column_name> SET VISIBLE;. Tables without explicit primary keys automatically generate invisible primary keys — make those visible too. See Invisible Columns and Generated Invisible Primary Keys.

  • Read-only RDS MySQL V5.6: This instance type does not record transaction logs and cannot be used as the source for incremental migration.

  • EncDB-enabled instances: Full data migration is not supported. Transparent Data Encryption (TDE)-enabled instances support schema migration, full data migration, and incremental data migration.

  • DDL restrictions during migration: Do not execute DDL statements while schema migration or full data migration is running. For full-only migration, do not write to the source database during migration.

  • Physical backup restores and cascade operations: Change data generated by physical backup restores or cascade operations on the source is not recorded or migrated to the destination while the migration instance is running. If this occurs, you can perform full data migration again, provided your business is not affected.

Other restrictions

  • Migration of INDEX, PARTITION, VIEW, PROCEDURE, FUNCTION, TRIGGER, and foreign keys is not supported.

  • The RENAME TABLE operation cannot be migrated.

  • If the source database has online DDL change operations in temporary table mode, such as multi-table merge scenarios, data loss in the destination database or failure of the migration instance may occur.

  • If the source contains online DDL changes performed with pt-online-schema-change, data loss or migration failure may occur. If you migrate one or more tables instead of an entire database, do not use pt-online-schema-change to perform online DDL operations on the migration objects in the source database — otherwise the migration fails. Online DDL changes performed with DMS or gh-ost are supported — DTS migrates the original DDL statement without copying temporary table data, but this may cause locked tables in the destination. You can use Data Management (DMS) to perform online DDL operations.

  • If DDL statements in the source do not follow standard MySQL syntax, the migration task may fail or data may be lost.

  • The number of databases to migrate must not exceed 256 (the ClickHouse limit).

  • Database, table, and column names must comply with ApsaraDB for ClickHouse naming conventions.

  • During schema migration, DTS adds _sign, _is_deleted, and _version fields to destination tables. If you skip schema migration, create the destination tables manually and include these fields. See Appendix: table and field information.

  • Data from sources other than DTS must not be written to the destination database while migration is running.

  • If a DTS task fails to run, DTS technical support will try to restore the task within 8 hours. During the restoration, the task may be restarted and the parameters of the DTS task may be modified. Note: only the parameters of the DTS task may be modified — the parameters of databases are not modified. The parameters that may be modified include but are not limited to those in the Modify instance parameters section.

ClickHouse-specific constraints

  • Time-type data range: ClickHouse time types have range limits. Source data outside these ranges is written incorrectly. See Appendix: time information.

  • Partition key: Cannot be a nullable field. Supported types: BIGINT, INT, TIMESTAMP, DATETIME, DATE.

  • Maximum databases: 256.

Special cases

Self-managed MySQL sources

  • If you perform a primary/secondary switchover on the source database while the data 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 operation is performed on the source for a long time, the migration latency may be inaccurate. To update the latency, perform a DML operation on the source. If you select an entire database as the migration object, you can create a heartbeat table that is updated every second.

  • DTS executes CREATE DATABASE IF NOT EXISTS \test\`` in the source database on a scheduled basis to advance the binary log file position.

ApsaraDB RDS for MySQL sources

  • In incremental data migration, a read-only ApsaraDB RDS for MySQL V5.6 instance cannot be used as the source database.

  • DTS executes CREATE DATABASE IF NOT EXISTS \test\`` in the source database on a scheduled basis to advance the binary log file position.

Data type mappings

MySQL and ClickHouse data types do not map one-to-one. During schema migration, DTS maps source types to compatible ClickHouse types. See Data type mappings between heterogeneous databases.

Migrate data from RDS MySQL to ClickHouse

Step 1: Open the Data Migration page

Use one of the following methods to navigate to the Data Migration page.

DTS console

  1. Log on to the DTS console.DTS console

  2. In the left-side navigation pane, click Data Migration.

  3. In the upper-left corner, select the region where the data migration instance resides.

DMS console

Note

The actual navigation may vary based on the DMS console mode and layout. See Simple mode and Customize the layout and style of the DMS console.

  1. Log on to the DMS console.DMS console

  2. In the top navigation bar, go to Data + AI > DTS (DTS) > Data Migration.

  3. From the drop-down list next to Data Migration Tasks, select the region where the instance resides.

Step 2: Configure the task

Click Create Task to open the task configuration page. Configure the parameters described in the following table.

CategoryParameterDescription
Task NameA descriptive name for this DTS task. The name does not need to be unique.
Source DatabaseSelect Existing ConnectionIf the instance is registered with DTS, select it from the list — DTS fills in the connection details automatically. Otherwise, configure the following parameters manually. In the DMS console, select the instance from the Select a DMS database instance list.
Database TypeSelect MySQL.
Access MethodSelect Alibaba Cloud Instance.
Instance RegionThe region where the source RDS MySQL instance resides.
Replicate Data Across Alibaba Cloud AccountsSelect No (same-account migration).
RDS Instance IDThe ID of the source RDS MySQL instance.
Database AccountThe database account for the source instance. See Before you begin.
Database PasswordThe password for the database account.
EncryptionSelect Non-encrypted or SSL-encrypted. To use SSL encryption, enable it on the RDS instance first. See Use a cloud certificate to enable SSL encryption.
Destination DatabaseSelect Existing ConnectionIf the cluster is registered with DTS, select it from the list. Otherwise, configure the following parameters manually.
Database TypeSelect ClickHouse.
Access MethodSelect Alibaba Cloud Instance.
Instance RegionThe region where the destination ClickHouse cluster resides.
Replicate Data Across Alibaba Cloud AccountsSelect No (same-account migration).
Cluster TypeSelect the cluster type.
Cluster IDThe ID of the destination ClickHouse cluster.
Database AccountThe database account for the destination cluster. See Before you begin.
Database PasswordThe password for the database account.

Step 3: Test connectivity

Click Test Connectivity and Proceed at the bottom of the page.

DTS server CIDR blocks must be added to the security settings of both the source and destination databases. See Add the CIDR blocks of DTS servers. If the source or destination is a self-managed database not using the Alibaba Cloud Instance access method, click Test Connectivity in the CIDR Blocks of DTS Servers dialog box.

Step 4: Select objects to migrate

On the Configure Objects page, configure the following settings.

ConfigurationDescription
Migration TypesSelect the migration types based on your scenario: <br>- Schema Migration + Full Data Migration: Migrates the current snapshot. No ongoing replication. <br>- Schema Migration + Full Data Migration + Incremental Data Migration: Migrates the snapshot and applies ongoing changes. Use this option to keep the destination in sync during the cutover window. <br><br>
Note

If you skip Schema Migration, create the destination tables manually before starting the task. If you skip Incremental Data Migration, do not write to the source database during migration.

Processing Mode of Conflicting TablesPrecheck and Report Errors (default): DTS checks for tables with identical names in the source and destination. The task cannot start if conflicts exist. Use object name mapping to resolve conflicts without deleting destination tables. <br><br>Ignore Errors and Proceed: Skips the check. During full migration, conflicting records in the destination are retained (not overwritten). During incremental migration, conflicting records are overwritten. Use this option with caution.
Capitalization of Object Names in Destination InstanceSpecifies how database, table, and column names are capitalized in the destination. Defaults to DTS default policy. See Specify the capitalization of object names.
Source ObjectsSelect objects (databases or tables) to migrate, then click the arrow icon to move them to Selected Objects.
Selected ObjectsRight-click a table to rename it (single object) or set row filter conditions. Click Batch Edit to rename multiple objects at once (batch rename).
Note

Renaming an object may cause dependent objects to fail migration.

Note
  • To set filter conditions for data, right-click the table to be migrated in the Selected Objects box and set the filter conditions in the dialog box that appears. For more information, see Set filter conditions.

  • If you use the object name mapping feature, other objects that depend on the renamed object may fail to migrate.

Step 5: Configure advanced settings

Click Next: Advanced Settings and configure the following parameters.

ParameterDescription
Dedicated Cluster for Task SchedulingBy default, DTS schedules tasks on the shared cluster. For higher stability, purchase a dedicated cluster. See What is a DTS dedicated cluster.
Time zone of destination databaseThe time zone for DateTime data written to ClickHouse.
Retry Time for Failed ConnectionsHow long DTS retries after a connection failure. Range: 10–1,440 minutes. Default: 720. Set this to at least 30 minutes. If DTS reconnects within this window, the task resumes automatically.
Retry Time for Other IssuesHow long DTS retries after DDL or DML failures. Range: 1–1,440 minutes. Default: 10. Set this to at least 10 minutes. Must be smaller than Retry Time for Failed Connections.
Enable Throttling for Full Data MigrationLimits the read/write load on source and destination during full migration. 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 MigrationLimits load 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 tasksYes:alert notification settings DTS does not write heartbeat SQL to the source. A task latency value may be displayed. No: DTS writes heartbeat SQL, which may affect features like physical backup and cloning of the source.
Environment TagOptional. Select a tag to identify the instance environment.
Configure ETLYes: Enables the extract, transform, and load (ETL) feature. Enter data processing statements in the editor. See Configure ETL in a data migration or data synchronization task. No: Disables ETL.
Monitoring and AlertingYes: Configures alerts for task failure or latency threshold breaches. Set the alert threshold and notification contacts. See Configure monitoring and alerting. No: No alerting.

Step 6: Configure ClickHouse table fields

Click Next: Configure Database and Table Fields to set the Type, Primary Key Column, Sort Key, Distribution Key, and Partition Key for each destination table in ClickHouse.

  • DTS provides a default configuration. To review or modify all tables, set Definition Status to All.

  • Primary Key Column and Sort Key support composite keys — select multiple fields from the drop-down list.

  • Partition Key must be one or more columns from Primary Key Column. Only BIGINT, INT, TIMESTAMP, DATETIME, and DATE types are supported. Nullable fields cannot be used as the partition key. Leaving the partition key blank is allowed.

  • Distribution Key accepts a single field only.

For details on primary keys, sort keys, and partition keys in ClickHouse, see CREATE TABLE.

Step 7: Run a precheck

Click Next: Save Task Settings and Precheck.

To view the API parameters that correspond to this task configuration, hover over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters.

DTS runs a precheck before starting the migration. If the precheck fails:

  1. Click View Details next to the failed item.

  2. Fix the issue based on the check results.

  3. Click Precheck Again.

If an alert item can be ignored: click Confirm Alert Details > Ignore > OK > Precheck Again. Ignoring alerts may cause data inconsistency.

Step 8: Purchase the instance and start migration

  1. Wait for Success Rate to reach 100%, then click Next: Purchase Instance.

  2. On the Purchase Instance page, configure the following:

    SectionParameterDescription
    New Instance ClassResource GroupThe resource group for the migration instance. Default: default resource group. See What is Resource Management?
    Instance ClassThe instance class determines migration speed. See Instance classes of data migration instances.
  3. Read and accept Data Transmission Service (Pay-as-you-go) Service Terms.

  4. Click Buy and Start > OK.

Verify the migration

Monitor the task on the Data Migration page.

  • Full-only migration (no incremental): The task stops automatically when complete. Status shows Completed.

  • Migration with incremental data: The task runs continuously. Status shows Running. Stop the task manually after cutting over your applications.

Query migrated data correctly

DTS uses the ReplicatedReplacingMergeTree engine and adds _sign, _is_deleted, and _version fields to destination tables. Without the FINAL keyword, queries may return duplicate or deleted rows. Always use FINAL and filter on _sign:

SELECT * FROM <table_name> FINAL WHERE _sign > 0;

The WHERE _sign > 0 condition filters out rows marked as deleted.

Appendix: time information

ClickHouse time types have range limits. Source values outside these ranges are written incorrectly to the destination.

Data typeMinimum valueMaximum value
Date1970-01-01 00:00:002149-06-06 00:00:00
Date321925-01-01 00:00:002283-11-11 00:00:00
DateTime1970-01-01 08:00:002106-02-07 14:28:15
DateTime641925-01-01 08:00:002283-11-12 07:59:59

Appendix: table and field information

Table requirements for manual creation

If you skip schema migration, create the destination tables before starting the task. The tables must meet these requirements.

Important

If the destination table includes an ENGINE clause, it must be ENGINE = ReplicatedReplacingMergeTree(_version, _is_deleted). Otherwise, data inconsistency may occur.

  • Community Edition: Create one local table and one distributed table. The distributed table name must match the source table name. The local table name must be <distributed_table_name>_local.

  • Enterprise Edition: Create a table with the same name as the source table.

DTS-managed fields

DTS automatically adds the following fields to destination tables during schema migration.

VersionFieldTypeDefaultDescription
Community Edition earlier than 23.8_signInt81DML operation type: INSERT or UPDATE = 1, DELETE = -1
_versionUInt641Timestamp when the row was written to ClickHouse
Enterprise Edition and Community Edition 23.8 and later_signInt81DML operation type: INSERT or UPDATE = 1, DELETE = -1
_is_deletedUInt80Deletion flag: INSERT or UPDATE = 0, DELETE = 1
_versionUInt641Timestamp when the row was written to ClickHouse

Partition key calculation logic

Source field typePartition key expression
BIGINTintDiv(key, 18014398509481984)
INTintDiv(key, 4194304)
TIMESTAMPtoYYYYMM(key)
DATETIMEtoYYYYMM(key)
DATEtoYYYYMM(key)