This topic describes how to use Data Transmission Service (DTS) to migrate data from a user-created MySQL database to a Distributed Relational Database System (DRDS) instance. DTS supports schema migration, full data migration, and incremental data migration.

Prerequisites

  • The version of the user-created MySQL database is 5.1, 5.5, 5.6, 5.7, or 8.0.
  • The database in DRDS instance are created based on ApsaraDB RDS for MySQL instances that you purchased. DTS does not support databases that are created based on private ApsaraDB RDS for MySQL instances or Apsara PolarDB for MySQL clusters.
  • A DRDS instance is created based on a Relational Database System (RDS) instance. The available storage space of the RDS instance is larger than the total size of the data in the user-created MySQL database.

Background information

  • DTS does not support schema migration from a user-created MySQL database to a DRDS instance.
    Note The schema migration process migrates the schemas of the objects to be migrated such as tables to the destination database.
  • DTS uses read and write resources of the source and destination databases during full data migration. This may increase the database load. If the database performance is unfavorable, the specification is low, or the data volume is large, database services may become unavailable. For example, DTS occupies a large amount of read and write resources in the following cases: a large number of slow SQL queries are performed on the source database, the tables have no primary keys, or a deadlock occurs in the destination database. Before you migrate data, evaluate the performance of the source and destination databases. We recommend that you migrate data during off-peak hours. For example, you can migrate data when the CPU usage of the source and destination databases is less than 30%.
  • The source database must have PRIMARY KEY or UNIQUE constraints and all fields must be unique. Otherwise, duplicate data may exist in the destination database.
  • For columns whose data type is float or double, DTS uses the ROUND(COLUMN,PRECISION) function to read the values. If precision is not specified, a precision of 38 digits is set for float-type data and a precision of 308 digits is set for double-type data.
  • If a data migration task fails, DTS attempts to resume the task. In this case, before you switch your workloads to the destination database, you must stop or release the task. Otherwise, the data in the source database will overwrite the data in the destination database after the task is resumed.

Billing

Migration type Instance configurations Internet traffic
Schema migration and full data migration Free of charge. Charged only when data is migrated from Alibaba Cloud over the Internet. For more information, see Pricing.
Incremental data migration Charged. For more information, see Pricing.

Migration types

  • Full data migration
    DTS migrates full data of objects to be migrated from the user-created MySQL database to the destination DRDS instance.
    Note Concurrent insertions are performed during full data migration. This results in table fragmentation in the destination instance. After a full data migration task is completed, the tablespace of the destination instance is larger than that of the source instance.
  • Incremental data migration

    During full data migration, DTS reads the binary log of the user-created MySQL database. When the full data migration is complete, DTS synchronizes the incremental data to the destination DRDS instance. This feature allows you to migrate data without interrupting your services.

SQL operations that can be synchronized during incremental data migration

INSERT, UPDATE, DELETE, and REPLACE

Permissions required for database accounts

Database Full data migration Incremental data migration
User-created MySQL database SELECT privilege The REPLICATION SLAVE, REPLICATION CLIENT, SHOW VIEW, and SELECT permissions
DRDS instance Read and write permissions Read and write permissions

Preparation

  1. Configure the user-created MySQL database account and the binary log of the database. For more information, seeCreate an account for a user-created MySQL database and configure binary logging.
  2. Create a database and tables in the destination DRDS instance based on the schema to be migrated from the user-created MySQL database. For more information, see Create a DRDS database and Create a table.

Procedure

  1. Log on to the DTS console.
  2. In the left-side navigation pane, click Data Migration.
  3. At the top of the Migration Tasks page, select the region where the destination RDS instance resides.Select a region
  4. In the upper-right corner of the page, click Create Migration Task.
  5. Configure the source and destination databases. Configure Source and Destination Databases
    Section Parameter Description
    N/A Task Name DTS generates a random task name. However, we recommend that you specify an informative name to ease management.
    Source Database Instance Type Select User-Created Database with Public IP Address.
    Instance Region When the instance type is set to User-Created Database with Public IP Address, you do not need to set Instance Region.
    Note If a whitelist is configured for the user-created SQL Server database, you must manually add the IP addresses of DTS servers to the whitelist of the user-created SQL Server database. You can click the Get IP Address Segment of DTS link next to the Instance Region parameter to obtain the IP addresses of DTS servers. Then add the IP addresses to obtain the IP addresses of DTS servers.
    Database Type Select MySQL.
    Hostname or IP Address Enter the hostname or IP address that is used to access the user-created MySQL database. In this example, enter the public IP address.
    Port Number Enter the port number configured for the user-created MySQL database. The default port number is 3306.
    Database Account Enter the user-created MySQL database account. For more information about permissions required for the database account, see Permissions required for database accounts.
    Database Password Enter the password of the user-created MySQL database account.
    Note After you specify the source database parameters, click Test Connectivity next to Database Password to verify whether the specified parameters are valid. If the specified parameters are valid, the Passed message appears. If the Failed message appears, click Check next to Failed. Modify the source database parameters based on the check results.
    Destination Database Instance Type Select DRDS instance.
    Instance Region Select the region to which the destination instance belongs.
    DRDS Instance ID Select the destination DRDS instance ID.
    Database Name Select the destination database name.
    Database Account Enter the account of the destination database under the DRDS instance. For more information about permissions required for the database account, see Permissions required for database accounts.
    Database Password Enter the password of the database account.
    Note After you specify the destination database parameters, click Test Connectivity next to Database Password to verify whether the parameters are valid. If the specified parameters are valid, the Passed message appears. If the Failed message appears, click Check next to Failed. Modify the destination database parameters based on the check results.
  6. Click Set Whitelist and Next in the lower-right corner of the page.
    Note The IP addresses of DTS servers are automatically added to the whitelist of the destination DRDS instance. Then, DTS servers can connect to the destination DRDS instance.
  7. Configure migration types and objects. Configure Migration Types and Objects
    Item Description
    Migration types
    • To perform only full data migration, select Full Data Migration.
    • If you want to migrate data without disruptions to your business, select Full Data Migration and Incremental Data Migration.
    Note If Incremental Data Migration is not selected, do not write data into the source database during full data migration. This ensures data consistency between the source and destination databases.
    Objects to be migrated

    Select the objects to be migrated in the Available section and click > icon to move them to the Selected section.

    Note
    • Objects to be migrated can be databases, tables, or columns.
    • By default, the selected objects are not renamed after the migration. If you want to rename the objects migrated to the destination instance, you can use the object name mapping feature provided by DTS. For more information, see Object name mapping.
    • If you use the object name mapping feature for an object, objects that depend on the object may fail to be migrated.
  8. In the lower-right corner of the page, click Precheck.
    Note
    • Before you can start the data migration task, a precheck is performed. You can start the data migration task only after the task passes the precheck.
    • If the task fails to pass the precheck, click the Info icon icon next to each failed item to view details. Troubleshoot the issues based on the causes and run the precheck again.
  9. After the task passes the precheck, click Next.
  10. In the Confirm Settings dialog box, specify the Channel Specification and select the Data Transmission Service (Pay-As-You-Go) Service Terms.
  11. Click Buy and Start to start the migration task.
    • Full data migration

      Do not manually stop a task during full data migration. Otherwise, data migrated to the destination database will be incomplete. Wait until the migration task automatically stops.

    • Incremental data migration

      An incremental data migration task does not automatically stop. You must manually stop the migration task.

      Note Select an appropriate time to manually stop the migration task. For example, you can stop the migration task during off-peak hours or before you switch your workloads to the destination instance.
      1. Wait until Incremental Data Migration and The migration task is not delayed appear in the progress bar of the migration task. Then, stop writing data to the source database for a few minutes. The delay time of incremental data migration may be displayed in the progress bar.
      2. After the status of incremental data migration changes to The migration task is not delayed, manually stop the migration task.The migration task is not delayed
  12. Switch your workloads to the DRDS instance.

What to do next

To ensure database security, after the data migration is complete, you must delete the accounts of both the user-created MySQL database and database in the DRDS instance.