All Products
Search
Document Center

Data Transmission Service:Migrate data from PolarDB for MySQL to ApsaraDB for SelectDB

Last Updated:Dec 27, 2025

This topic describes how to use Data Transmission Service (DTS) to migrate data from a PolarDB for MySQL cluster to an ApsaraDB for SelectDB instance for large-scale data analysis.

Prerequisites

You have created a source PolarDB for MySQL cluster and a target ApsaraDB for SelectDB instance.

Precautions

Type

Description

Source database limits

  • Bandwidth requirement: The server that hosts the source database must have an outbound bandwidth of 100 Mb/s or more. Otherwise, the data migration speed decreases.

  • Requirements for the objects to migrate:

    • Migration of read-only nodes from the source PolarDB for MySQL cluster is not supported.

    • Migration of OSS external tables from the source PolarDB for MySQL cluster is not supported.

    • Migration of indexes, partitions, views, procedures, functions, triggers, and foreign keys is not supported.

    • All tables to be migrated have primary keys or UNIQUE constraints:

      Ensure that the table fields are unique. Otherwise, duplicate data may exist in the destination database.

    • The migration objects include tables that have no primary keys or UNIQUE constraints:

      When you configure the instance, select Migration Types and then select Schema Migration. In the Configurations for Databases, Tables, and Columns step, set Engine to duplicate for these tables. Otherwise, the instance may fail or data may be lost.

      Note

      During schema migration, DTS adds fields to the destination table. For more information, see Additional column information.

  • If you migrate tables and need to edit them, such as mapping column names, a single data migration task can migrate a maximum of 1,000 tables. If you exceed this limit, an error is reported after you submit the task. In this case, split the tables into multiple migration tasks or configure a task to migrate the entire database.

  • For incremental migration:

    • Enable binary logging (Binlog) and set the loose_polar_log_bin parameter to on. Otherwise, an error is reported during the precheck and the data migration task cannot start. For more information about how to enable binary logging and modify parameters, see Enable binary logging and Modify parameters.

      Note

      Enabling binary logging for a PolarDB for MySQL cluster consumes storage space and incurs fees.

    • Retain the binary logs of the PolarDB for MySQL cluster for at least 3 days. We recommend that you retain them for 7 days. Otherwise, Data Transmission Service (DTS) may fail because it cannot obtain the binary logs. In extreme cases, this may cause data inconsistency or data loss. Issues caused by a binary log retention period that is shorter than the required period are not covered by the DTS Service-Level Agreement (SLA).

      Note

      For more information about how to set the retention period for binary logs of a PolarDB for MySQL cluster, see Modify the retention period.

  • Source database operation limits:

    • During schema migration and full data migration, do not perform data definition language (DDL) operations to change the schema of the database or tables. Otherwise, the data migration task fails.

    • If you perform only full data migration, do not write new data to the source instance. Otherwise, the data in the source and destination instances will be inconsistent. To ensure real-time data consistency, select schema migration, full data migration, and incremental data migration.

  • Data changes from operations that are not recorded in binary logs during the migration are not migrated to the destination database. Examples of such operations include data recovery using physical backup and cascade operations.

    Note

    If this occurs, you can perform a full data migration again when your business permits.

Other limits

  • You can migrate data only to tables that use the Unique or Duplicate engine in SelectDB instances.

    If the destination table uses the Unique engine

    If the destination table uses the Unique engine, make sure that all unique keys of the destination table exist in the source table and are included in the migration objects. Otherwise, data inconsistency may occur.

    If the destination table uses the Duplicate engine

    If the destination table uses the Duplicate engine, duplicate data may exist in the destination database in the following cases. You can remove duplicate data based on the additional columns (_is_deleted, _version, and _record_id).

    • A retry operation occurred in the migration instance.

    • The migration instance was restarted.

    • Two or more DML operations were performed on the same data row after the migration instance started.

      Note

      If the destination table uses the Duplicate engine, DTS converts UPDATE or DELETE statements to INSERT statements.

  • When you configure parameters in the Selected Objects box, you can set only the bucket_count (number of buckets) parameter.

    Note

    The value of the bucket_count parameter must be a positive integer. The default value is auto.

  • DTS does not support primary/secondary failover of the database instance during full migration. If a failover occurs, reconfigure the migration task promptly.

  • During data migration, do not create clusters in the destination SelectDB instance. Otherwise, the data migration task fails. You can restart the migration instance to resume the failed task.

  • SelectDB instances support only database and table names that start with a letter. If the name of a database or table that you want to migrate does not start with a letter, use the object name mapping feature to rename the database or table.

  • If the name of an object that you want to migrate, such as a database, table, or column, contains Chinese characters, use the object name mapping feature to rename the object. For example, you can change the name from Chinese to English. Otherwise, the task may fail.

  • You cannot perform DDL operations that modify multiple columns at a time or that modify the same table in succession.

  • During data migration, do not add backend (BE) nodes to the SelectDB database. Otherwise, the task fails. You can restart the migration instance to resume the failed task.

  • In a multi-table merge scenario, where data from multiple source tables is migrated to a single destination table, ensure that the schemas of the source tables are consistent. Otherwise, data inconsistency or task failure may occur.

  • In a PolarDB for MySQL cluster, M in the VARCHAR(M) data type represents the character length. In SelectDB, N in the VARCHAR(N) data type represents the byte length. If you do not use the schema migration feature provided by DTS, set the length of VARCHAR fields in SelectDB to four times the length of VARCHAR fields in the PolarDB for MySQL cluster.

  • When using DMS or gh-ost to perform online DDL operations on the source, DTS migrates only the original DDL statements to the destination. In this scenario, DTS does not need to migrate large amounts of temporary table data, but this may cause tables to be locked at the destination.

    Note

    Online DDL operations performed on the source using tools such as pt-online-schema-change cannot be migrated. If such changes occur at the source, it may lead to data loss at the destination or cause the migration instance to fail.

  • Before migrating data, evaluate the performance of the source and destination databases. Migrate data during off-peak hours. During initial full data synchronization, DTS consumes read and write resources from both the source and destination databases. This can increase the database load.

  • Initial full synchronization concurrently executes INSERT operations, which causes fragmentation in the tables of the destination database. Therefore, after the initial full synchronization is complete, the tablespace of the destination instance is larger than that of the source instance.

  • During data migration, do not use tools such as pt-online-schema-change to perform online DDL operations on the migration objects in the source database. Otherwise, the migration will fail.

  • Data inconsistency between the source and destination databases may occur if data from sources other than DTS is written to the destination database during data migration.

  • During incremental migration, DTS uses a batch synchronization policy to reduce the load on the destination. By default, DTS writes data to a single synchronization object at most once every 5 seconds. Therefore, a DTS migration task may experience a normal synchronization latency, which is usually within 10 seconds. To reduce this normal migration latency, modify the selectdb.reservoir.timeout.milliseconds parameter of the DTS instance in the console to adjust the batch processing time. The allowed range is [1000, 10000] milliseconds.

    Note

    When adjusting the batch processing time, a shorter time increases the write frequency of DTS. This may increase the load and write response time (RT) at the destination, which in turn increases the DTS synchronization latency. Therefore, adjust the time based on the load at the destination.

  • If an instance fails, DTS helpdesk will try to recover the instance within 8 hours. During the recovery process, operations such as restarting the instance or adjusting its parameters may be performed.

    Note

    When parameters are adjusted, only the parameters of the DTS instance are modified. The parameters in the database are not modified. The parameters that may be modified include but are not limited to those described in Modify instance parameters.

Billing

Migration type

Link configuration fees

Data transfer cost

Schema migration and full data migration

Free of charge.

This example is free of charge.

Note

When the Access Method for the destination database is Public IP Address, data transfer costs apply. For more information, see Billing overview.

Incremental data migration

Charged. For more information, see Billing overview.

SQL operations that support incremental migration

Operation type

SQL statement

DML

INSERT, UPDATE, and DELETE

DDL

  • ADD COLUMN

  • MODIFY COLUMN

  • CHANGE COLUMN

  • DROP COLUMN, DROP TABLE

  • TRUNCATE TABLE

  • RENAME TABLE

    Important

    RENAME TABLE operations may cause data inconsistency between the source and destination databases. For example, if you select a table as the object to be migrated and rename the table during data migration, the data of this table is not migrated to the destination database. To prevent this situation, you can select the database to which this table belongs as the object to be migrated when you configure the data migration task. Make sure that the databases to which the table belongs before and after the RENAME TABLE operation are added to the objects to be migrated.

Permissions required for database accounts

Database

Schema migration

Full migration

Incremental migration

Source: PolarDB for MySQL

The SELECT permission

The SELECT permission

Access control list

Destination SelectDB instance

The USAGE_PRIV permission and the following read and write permissions: SELECT_PRIV, LOAD_PRIV, ALTER_PRIV, CREATE_PRIV, and DROP_PRIV

To create a database account and grant permissions:

Procedure

  1. Use one of the following methods to go to the Data Migration page and select the region in which the data migration instance resides.

    DTS console

    1. Log on to the DTS console.

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

    3. In the upper-left corner of the page, select the region in which the data migration instance resides.

    DMS console

    Note

    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.

    1. Log on to the DMS console.

    2. In the top navigation bar, move the pointer over Data + AI > DTS (DTS) > Data Migration.

    3. From the drop-down list to the right of Data Migration Tasks, select the region in which the data synchronization instance resides.

  2. Click Create Task to go to the task configuration page.

  3. Configure the source and destination databases. The following table describes the parameters.

    Category

    Configuration

    Description

    N/A

    Task Name

    The name of the DTS task. DTS automatically generates a task name. We recommend that you specify a descriptive name that makes it easy to identify the task. You do not need to specify a unique task name.

    Source Database

    Select Existing Connection

    • If you use a database instance that is registered with DTS, select the instance from the drop-down list. DTS automatically populates the following database parameters for the instance. For more information, see Manage database connections.

      Note

      In the DMS console, you can select the database instance from the Select a DMS database instance drop-down list.

    • If you fail to register the instance with DTS, or you do not need to use the instance that is registered with DTS, you must configure the following database information.

    Database Type

    Select PolarDB for MySQL.

    Access Method

    Select Alibaba Cloud Instance.

    Instance Region

    The region in which the source PolarDB for MySQL cluster resides.

    Replicate Data Across Alibaba Cloud Accounts

    Specifies whether to migrate data across Alibaba Cloud accounts. For this example, select No.

    Note

    To configure a data migration task between different Alibaba Cloud accounts, you must first configure RAM authorization.

    PolarDB Cluster ID

    Select the ID of the source PolarDB for MySQL cluster.

    Database Account

    The database account of the source PolarDB for MySQL cluster. For permission requirements, see Permission requirements for database accounts.

    Database Password

    The password that is used to access the database.

    Encryption

    Select an option based on your PolarDB for MySQL cluster. For more information about the Secure Sockets Layer (SSL) encryption feature, see Configure SSL encryption.

    Destination Database

    Select Existing Connection

    • If you use a database instance that is registered with DTS, select the instance from the drop-down list. DTS automatically populates the following database parameters for the instance. For more information, see Manage database connections.

      Note

      In the DMS console, you can select the database instance from the Select a DMS database instance drop-down list.

    • If you fail to register the instance with DTS, or you do not need to use the instance that is registered with DTS, you must configure the following database information.

    Database Type

    Select SelectDB.

    Access Method

    Select Alibaba Cloud Instance.

    Instance Region

    Select the region for the destination SelectDB instance.

    Replicate Data Across Alibaba Cloud Accounts

    This example is for a migration within the same Alibaba Cloud account. Select No.

    Instance ID

    Select the ID of the destination SelectDB instance.

    Database Account

    Enter the database account for the destination SelectDB instance. For information about permission requirements, see Permission requirements for database accounts.

    Database Password

    The password that is used to access the database.

  4. In the lower part of the page, click Test Connectivity and Proceed.

    Note

    Make sure that the CIDR blocks of DTS servers can be automatically or manually added to the security settings of the source and destination databases to allow access from DTS servers. For more information, see Add DTS server IP addresses to a whitelist.

  5. Configure the objects to be migrated.

    1. On the Configure Objects page, configure the objects that you want to migrate.

      Configuration

      Note

      Migration Types

      • To perform only a full data migration, select both Schema Migration and Full Data Migration.

      • To migrate data without service downtime, select Schema Migration, Full Data Migration, and Incremental Data Migration.

      Important
      • When data is migrated from a PolarDB for MySQL cluster to a SelectDB instance, data types are converted. If you do not select Schema Migration, you must create tables that use the Unique or Duplicate key model in the destination SelectDB instance before you start the data migration. For more information, see Data type mapping, Additional column information, and Data model.

      • If you do not select Incremental Data Migration, do not write new data to the source instance during the data migration to ensure data consistency.

      Processing Mode of Conflicting Tables

      • Precheck and Report Errors: DTS checks whether tables with the same name exist in the destination database. If no tables with the same name exist, the task passes this check. If tables with the same name exist, the precheck fails and the data migration task does not start.

        Note

        If you cannot delete or rename the table in the destination database, you can map the table to a different name. For more information, see Map object names.

      • Ignore Errors and Proceed: DTS skips the check for tables with the same name in the destination database.

        Warning

        If you select Ignore Errors and Proceed, data inconsistency may occur and pose risks to your business. For example:

        • If the table schemas are consistent and a record in the destination database has the same primary key value as a record in the source database, the record from the source database overwrites the record in the destination database.

        • If the table schemas are inconsistent, only some columns of data may be migrated or the migration may fail. Use this option with caution.

      Capitalization of Object Names in Destination Instance

      The capitalization of database names, table names, and column names in the destination instance. By default, DTS default policy is selected. You can select other options to make sure that the capitalization of object names is consistent with that of the source or destination database. For more information, see Specify the capitalization of object names in the destination instance.

      Source Objects

      Select one or more objects from the Source Objects section. Click the 向右小箭头 icon to add the objects to the Selected Objects section.

      Note

      You can select databases or tables as migration objects.

      Selected Objects

      • To change the name of a migration object in the destination instance, right-click the migration object in the Selected Objects box. For more information, see Map object names.

      • If you select Schema Migration for Migration Types, select tables as the migration objects, and need to set the number of buckets (bucket_count parameter), right-click a table to be migrated in the Selected Objects box. In the Parameter Settings section, set Enable Parameter Settings to Yes, set Value as needed, and then click OK.

      Note
      • To select the incremental SQL operations to be migrated at the database or table level, right-click the migration object in the Selected Objects box and select the desired SQL operations in the dialog box that appears.

      • To set WHERE conditions to filter 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 mapped object may fail to be migrated.

    2. Click Next: Advanced Settings to configure advanced settings.

      Configuration

      Note

      Dedicated Cluster for Task Scheduling

      By default, DTS schedules the data migration task to the shared cluster if you do not specify a dedicated cluster. If you want to improve the stability of data migration tasks, purchase a dedicated cluster. For more information, see What is a DTS dedicated cluster.

      Retry Time for Failed Connections

      The retry time range for failed connections. If the source or destination database fails to be connected after the data migration task is started, DTS immediately retries a connection within the retry time range. Valid values: 10 to 1,440. Unit: minutes. Default value: 720. We recommend that you set the parameter to a value greater than 30. If DTS is reconnected to the source and destination databases within the specified retry time range, DTS resumes the data migration task. Otherwise, the data migration task fails.

      Note
      • If you specify different retry time ranges for multiple data migration tasks that share the same source or destination database, the value that is specified later takes precedence.

      • When DTS retries a connection, you are charged for the DTS instance. We recommend that you specify the retry time range based on your business requirements. You can also release the DTS instance at the earliest opportunity after the source database and destination instance are released.

      Retry Time for Other Issues

      The retry time range for other issues. For example, if DDL or DML operations fail to be performed after the data migration task is started, DTS immediately retries the operations within the retry time range. Valid values: 1 to 1440. Unit: minutes. Default value: 10. We recommend that you set the parameter to a value greater than 10. If the failed operations are successfully performed within the specified retry time range, DTS resumes the data migration task. Otherwise, the data migration task fails.

      Important

      The value of the Retry Time for Other Issues parameter must be smaller than the value of the Retry Time for Failed Connections parameter.

      Enable Throttling for Full Data Migration

      Specifies whether to enable throttling for full data migration. During full data migration, DTS uses the read and write resources of the source and destination databases. This may increase the loads of the database servers. You can enable throttling for full data migration based on your business requirements. To configure throttling, you must configure the Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s) parameters. This reduces the loads of the destination database server.

      Note

      You can configure this parameter only if you select Full Data Migration for the Migration Types parameter.

      Enable Throttling for Incremental Data Migration

      Specifies whether to enable throttling for incremental data migration. To configure throttling, you must configure the RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s) parameters. This reduces the loads of the destination database server.

      Note

      You can configure this parameter only if you select Incremental Data Migration for the Migration Types parameter.

      Environment Tag

      You can select an environment tag to identify the instance. This parameter is optional.

      Whether to delete SQL operations on heartbeat tables of forward and reverse tasks

      Specifies whether to write SQL operations on heartbeat tables to the source database while the DTS instance is running. Valid values:

      • Yes: does not write SQL operations on heartbeat tables. In this case, a latency of the DTS instance may be displayed.

      • No: writes SQL operations on heartbeat tables. In this case, features such as physical backup and cloning of the source database may be affected.

      Configure ETL

      Specifies whether to enable the extract, transform, and load (ETL) feature. For more information, see What is ETL? Valid values:

      Monitoring and Alerting

      Specifies whether to configure alerting for the data migration task. If the task fails or the migration latency exceeds the specified threshold, the alert contacts receive notifications. Valid values:

    3. Optional: After you complete the preceding configuration, click Next: Configure Database and Table Fields to set the Primary Key Column, Distribution Key, and Engine for the destination tables.

      Note
      • This step is available only if you select Schema Migration for Migration Types when you configure the migration objects. You can set Definition Status to All and then modify the settings.

      • You can select multiple columns to form a composite primary key for Primary Key Column. You must select one or more columns from the Primary Key Column as the Distribution Key.

      • For tables that have no primary keys or UNIQUE constraints, you must set Engine to duplicate. Otherwise, the migration may fail or data may be lost.

  6. Save the task settings and run a precheck.

    • To view the parameters to be specified when you call the relevant API operation to configure the DTS task, move the pointer over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters.

    • If you do not need to view or have viewed the parameters, click Next: Save Task Settings and Precheck in the lower part of the page.

    Note
    • Before you can start the data migration task, DTS performs a precheck. You can start the data migration task only after the task passes the precheck.

    • If the task fails to pass the precheck, click View Details next to each failed item. After you analyze the causes based on the check results, troubleshoot the issues. Then, run a precheck again.

    • If an alert is triggered for an item during the precheck:

      • If an alert item cannot be ignored, click View Details next to the failed item and troubleshoot the issues. Then, run a precheck again.

      • If the alert item can be ignored, click Confirm Alert Details. In the View Details dialog box, click Ignore. In the message that appears, click OK. Then, click Precheck Again to run a precheck again. If you ignore the alert item, data inconsistency may occur, and your business may be exposed to potential risks.

  7. Purchase the instance.

    1. Wait until Success Rate becomes 100%. Then, click Next: Purchase Instance.

    2. On the Purchase Instance page, configure the Instance Class parameter for the data migration instance. The following table describes the parameters.

      Section

      Parameter

      Description

      New Instance Class

      Resource Group

      The resource group to which the data migration instance belongs. Default value: default resource group. For more information, see What is Resource Management?

      Instance Class

      DTS provides instance classes that vary in the migration speed. You can select an instance class based on your business scenario. For more information, see Instance classes of data migration instances.

    3. Read and agree to Data Transmission Service (Pay-as-you-go) Service Terms by selecting the check box.

    4. Click Buy and Start. In the message that appears, click OK.

      You can view the progress of the task on the Data Migration page.

      Note
      • If a data migration task cannot be used to migrate incremental data, the task automatically stops. The Completed is displayed in the Status section.

      • If a data migration task can be used to migrate incremental data, the task does not automatically stop. The incremental data migration task never stops or completes. The Running is displayed in the Status section.

Data type mappings

Category

Data types in PolarDB for MySQL

Data types in SelectDB

Numeric

TINYINT

TINYINT

TINYINT UNSIGNED

SMALLINT

SMALLINT

SMALLINT

SMALLINT UNSIGNED

INT

MEDIUMINT

INT

MEDIUMINT UNSIGNED

BIGINT

INT

INT

INT UNSIGNED

BIGINT

BIGINT

BIGINT

BIGINT UNSIGNED

LARGEINT

BIT(M)

INT

Decimal

Decimal

Note

Zerofill is not supported.

Numeric

Decimal

Float

Float

Double

DOUBLE

  • BOOL

  • BOOLEAN

BOOLEAN

DATE AND TIME

DATE

DATEV2

DATETIME[(fsp)]

DATETIMEV2

Timestamp[(fsp)]

DATETIMEV2

Time[(fsp)]

VARCHAR

YEAR[(4)]

INT

STRING

  • CHAR

  • VARCHAR

VARCHAR

Important

To prevent data loss, CHAR and VARCHAR(n) data is converted to VARCHAR(4*n) during migration to SelectDB.

  • If no length is specified, the default value is VARCHAR(65533).

  • Data longer than 65,533 characters is converted to STRING.

  • BINARY

  • VARBINARY

STRING

  • TINYTEXT

  • TEXT

  • MEDIUMTEXT

  • LONGTEXT

STRING

  • TINYBLOB

  • BLOB

  • MEDIUMBOLB

  • LONGBLOB

STRING

ENUM

STRING

SET

STRING

JSON

STRING

Additional column information

Note

The following table describes the additional columns that DTS automatically adds or that you need to manually add to the destination tables that use the Duplicate model.

Name

Data type

Default value

Description

_is_deleted

Int

0

Indicates whether the data is deleted.

  • Insert: The value is 0.

  • Update: The value is 0.

  • Delete: The value is 1.

_version

Bigint

0

  • For full data migration, the value is 0.

  • For incremental data migration, the value is the timestamp in seconds from the source binary log.

_record_id

Bigint

0

  • For full data migration, the value is 0.

  • For incremental data migration, the value is the record ID of the incremental log entry. This ID uniquely identifies the log entry.

    Note

    The ID is unique and auto-incrementing.