All Products
Search
Document Center

Data Transmission Service:Migrate data from a self-managed MySQL database to a PolarDB-X instance

Last Updated:Sep 05, 2024

This topic describes how to migrate data from a self-managed MySQL database to a PolarDB-X instance by using Data Transmission Service (DTS). DTS supports schema migration, full data migration, and incremental data migration. You can select all of the supported migration types to ensure service continuity when you migrate data from the self-managed Oracle database to the PolarDB-X instance.

Prerequisites

  • The version of the self-managed MySQL database is 5.1, 5.5, 5.6, 5.7, or 8.0.

  • The databases in the PolarDB-X instance are created based on ApsaraDB RDS for MySQL instances. DTS does not support DRDS databases that are created based on PolarDB for MySQL clusters.

  • The available storage space of the RDS instances in the PolarDB-X instance is larger than the total size of the data in the self-managed MySQL database.

Precautions

  • DTS does not support schema migration from a self-managed MySQL database to a PolarDB-X instance.

    Note

    During schema migration, DTS migrates the schemas of the required objects, such as tables, from the source database to the destination database.

  • DTS uses read and write resources of the source and destination databases during full data migration. This may increase the loads of the database servers. 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 impact of data migration on 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 utilization of the source and destination databases is less than 30%.

  • The tables to be migrated in the source database must have PRIMARY KEY or UNIQUE constraints and all fields must be unique. Otherwise, the destination database may contain duplicate data records.

  • DTS uses the ROUND(COLUMN,PRECISION) function to retrieve values from columns of the FLOAT or DOUBLE data type. If you do not specify a precision, DTS sets the precision for the FLOAT data type to 38 digits and the precision for the DOUBLE data type to 308 digits. You must check whether the precision settings meet your business requirements.

  • If a data migration task fails, DTS automatically resumes the task. Before you switch your workloads to the destination instance, stop or release the data migration task. Otherwise, the data in the source instance will overwrite the data in the destination instance after the task is resumed.

Billing

Migration type

Task configuration fee

Internet traffic fee

Full data migration

Free of charge.

Charged only when data is migrated from Alibaba Cloud over the Internet. For more information, see Billing overview.

Incremental data migration

Charged. For more information, see Billing overview.

Migration types

  • Full data migration

    DTS migrates historical data of the required objects from the self-managed MySQL database to the destination database in the PolarDB-X instance.

    Note

    During full data migration, concurrent INSERT operations cause fragmentation in the tables of the destination instance. After full data migration is complete, the tablespace of the destination instance is larger than that of the source database.

  • Incremental data migration

    After full data migration is complete, DTS retrieves binary log files from the self-managed MySQL database. Then, DTS synchronizes incremental data from the self-managed MySQL database to the destination PolarDB-X instance. Incremental data migration allows you to ensure service continuity when you migrate data from the self-managed MySQL database to the PolarDB-X instance.

SQL operations that can be synchronized during incremental data migration

INSERT, UPDATE, DELETE, and REPLACE operations

Permissions required for database accounts

Database

Full data migration

Incremental data migration

Self-managed MySQL database

The SELECT permission

The REPLICATION CLIENT, REPLICATION SLAVE, SHOW VIEW, and SELECT permissions

PolarDB-X

The read and write permissions

The read and write permissions

Before you begin

  1. Create an account for a self-managed MySQL database and configure binary logging.

  2. Create a database and tables in the destination PolarDB-X instance based on the schema of the self-managed MySQL database. For more information, see Create a DRDS database and Create a DRDS table.

Procedure

  1. Log on to the DTS console.

    Note

    If you are redirected to the Data Management (DMS) console, you can click the old icon in the image to go to the previous version of the DTS console.

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

  3. In the upper part of the Migration Tasks page, select the region in which the RDS instance resides.

  4. In the upper-right corner of the page, click Create Migration Task.

  5. Configure the source and destination databases. Configure the source and destination databases

    Section

    Parameter

    Description

    N/A

    Task Name

    DTS automatically generates a task name. We recommend that you specify an informative name for easy identification. You do not need to use a unique task name.

    Source Database

    Instance Type

    Select an instance type based on the deployment of the source database. In this example, select User-Created Database with Public IP Address.

    Note

    If you select other instance types, you must deploy the network environment for the self-managed database. For more information, see Preparation overview.

    Instance Region

    If the instance type is set to User-Created Database with Public IP Address, you do not need to specify the instance region.

    Note

    If a whitelist is configured for the self-managed MySQL database, you must add the CIDR blocks of DTS servers to the whitelist of the database. You can click Get IP Address Segment of DTS next to Instance Region to obtain the CIDR blocks of DTS servers.

    Database Type

    Select MySQL.

    Hostname or IP Address

    Enter the endpoint that is used to connect to the self-managed MySQL database. In this example, enter the public IP address.

    Port Number

    Enter the service port number of the self-managed MySQL database. The default port number is 3306.

    Database Account

    Enter the account of the self-managed MySQL database. For more information about the permissions that are required for the account, see Permissions required for database accounts.

    Database Password

    Enter the password of the database account.

    Note

    After you specify the information about the source database, you can click Test Connectivity next to Database Password to check whether the information is valid. If the information is valid, the Passed message appears. If the Failed message appears, click Check next to Failed. Then, modify the information based on the check results.

    Destination Database

    Instance Type

    Select DRDS Instance.

    Instance Region

    Select the region where the destination PolarDB-X instance resides.

    DRDS Instance ID

    Select the ID of the destination PolarDB-X instance.

    Database Name

    Select the name of the destination database.

    Database Account

    Enter the database account of the destination PolarDB-X instance. For more information about the permissions that are required for the account, see Permissions required for database accounts.

    Database Password

    Enter the password of the database account.

    Note

    After you specify the information about the RDS instance, you can click Test Connectivity next to Database Password to check whether the information is valid. If the information is valid, the Passed message appears. If the Failed message appears, click Check next to Failed. Then, modify the information based on the check results.

  6. In the lower-right corner of the page, click Set Whitelist and Next.

    Note

    DTS adds the CIDR blocks of DTS servers to the whitelist of the destination PolarDB-X instance. This ensures that DTS servers can connect to the destination PolarDB-X instance.

  7. Select the migration types and the objects to be migrated. Select the migration types and the objects to be migrated

    Setting

    Description

    Select the migration types

    • To perform only full data migration, select only Full Data Migration.

    • To ensure service continuity during data migration, select both Full Data Migration and Incremental Data Migration.

    Note

    If Incremental Data Migration is not selected, do not write data to the source database during full data migration. This ensures data consistency between the source and destination databases.

    Select the objects to be migrated

    Select one or more objects from the Available section and click the Right arrow icon to move the objects to the Selected section.

    Note
    • You can select columns, tables, or databases as the objects to be migrated. If you select tables or columns as the objects to be migrated, DTS does not migrate other objects such as views, triggers, or stored procedures to the destination database.

    • By default, after an object is migrated to the destination database, the name of the object remains unchanged. You can use the object name mapping feature to rename the objects that are migrated to the destination database. For more information, see Object name mapping.

    • If you use the object name mapping feature to rename an object, other objects that are dependent on the object may fail to be migrated.

    Specify whether to rename object names

    You can use the object name mapping feature to change the names of the objects that are synchronized to the destination instance. For more information, see Object name mapping.

    Specify the retry time for failed connections to the source or destination database

    By default, if DTS fails to connect to the source or destination database, DTS retries within the next 12 hours. You can specify the retry time based on your needs. If DTS reconnects to the source and destination databases within the specified time, DTS resumes the data migration task. Otherwise, the data migration task fails.

    Note

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

    Specify whether to copy temporary tables to the destination database when DMS performs online DDL operations on the source table

    In this scenario, DTS does not migrate DDL operations. You must set this parameter to No.

    However, DTS may support DDL operations for this scenario in the future. In this case, if you use Data Management (DMS) to perform online DDL operations on the source database, you can specify whether to migrate temporary tables generated by the operations.

    • Yes: DTS migrates the data of temporary tables generated by online DDL operations.

      Note

      If online DDL operations generate a large amount of data, the migration task may be delayed.

    • No: DTS does not migrate the data of temporary tables generated by online DDL operations. Only the original DDL data of the source database is migrated.

      Note

      If you select No, the tables in the destination database may be locked.

  8. Click Precheck.

    Note
    • A precheck is performed before the migration task starts. The migration task only starts after the precheck succeeds.

    • If the precheck fails, click the Note icon next to each failed check item to view the related details. Fix the issues as instructed and run the precheck again.

  9. Click Next.

  10. In the Confirm Settings dialog box, configure the Channel Specification parameter. Then, read and select Data Transmission Service (Pay-as-you-go) Service Terms.

  11. Click Buy and Start to start the data migration task.

    • Full data migration

      Do not manually stop a full data migration task. If you manually stop a full data migration task, the data that is migrated to the RDS instance may be incomplete. You can wait until the data migration task automatically stops.

    • Incremental data migration

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

      Note

      We recommend that you manually stop an incremental data migration task at an appropriate point in time. For example, you can stop the task during off-peak hours or before you switch your workloads over to the ApsaraDB RDS for MySQL instance.

      1. Wait until Incremental Data Migration and The data migration task is not delayed are displayed in the progress bar of the data migration task. Then, stop writing data to the source database for a few minutes. The latency of incremental data migration may be displayed in the progress bar.

      2. Wait until the status of Incremental Data Migration changes to The data migration task is not delayed again. Then, manually stop the migration task.无延迟

  12. Switch your workloads to the destination PolarDB-X instance.

What to do next

The database accounts that are used for data migration have the read and write permissions. After data migration is complete, you must delete the accounts of both the self-managed MySQL database and the PolarDB-X instance to ensure security.