Migrate from PolarDB-X 2.0 to PolarDB-X 1.0

Updated at:

This topic describes how to use Data Transmission Service (DTS) to migrate data from a PolarDB-X 2.0 instance to a PolarDB-X 1.0 instance.

Important

This feature is in beta testing and is available only to some users.

Prerequisites

  • You have created a target PolarDB-X 1.0 instance with a storage space larger than the data size of the source PolarDB-X 2.0 instance. For more information, see Create an instance.

  • You have created a database and tables in the target PolarDB-X 1.0 instance to store the migrated data. For more information, see Create a database and Execute basic SQL operations.

    Note

    Keep the names of the database and tables in the destination instance the same as the names in the source PolarDB-X 2.0 instance. If you use different names, you must use the object name mapping feature in the Selected Objects section of the Configure Objects page.

Notes

Type

Description

Source database limits

  • Bandwidth requirements: The server that hosts the source database must have sufficient outbound bandwidth. Otherwise, the data migration speed is affected.

  • Read-only instances of PolarDB-X 2.0 Enterprise Edition are not supported as the source.

  • Migration object requirements:

    • Migration of tables with uppercase letters in their names is not supported.

    • Migration of table groups and databases or tables that have the Locality property is not supported.

    • Migration of tables whose names are reserved words, such as select, is not supported.

    • The tables to be migrated must have primary keys or UNIQUE constraints, and the fields must be unique. Otherwise, duplicate data may appear in the destination database.

    • If you migrate data at the table level and need to edit the tables, such as mapping column names, a single data migration task supports a maximum of 1,000 tables. If you exceed this limit, an error is reported when you submit the task. In this case, split the tables into multiple batches and configure a separate task for each batch, or configure a task to migrate the entire database.

  • PolarDB-X 2.0 instances have binary logging (Binlog) enabled by default. To migrate incremental data, ensure that the binlog_row_image parameter is set to full. Otherwise, error messages are returned during the precheck and the data migration task fails to be started. For more information, see Parameter Settings.

  • During the schema migration and full migration phases, do not perform DDL operations that change the database or table structure. Otherwise, the data migration task will fail.

    Note

    During the full migration phase, DTS queries the source database. This creates a metadata lock that may block DDL operations on the source database.

  • If you perform only a full data migration, do not write new data to the source database. Otherwise, the data in the source and destination databases will become inconsistent. To maintain data consistency in real time, select both full data migration and incremental data migration.

  • If the network information of the PolarDB-X 2.0 instance changes, the migration instance may experience latency for a period of time.

  • In a PolarDB-X 2.0 instance, synchronization of database partitions in DRDS mode is not supported.

Other limits

  • DTS periodically attempts to execute the CREATE DATABASE IF NOT EXISTS `test` command on the source database to create the test database and writes heartbeat data to advance the Binlog offset. If you set the Whether to delete SQL operations on heartbeat tables of forward and reverse tasks option to Yes when you configure the migration instance (or if the source database account used by the migration instance does not have the permissions to create databases), and no DML operations are performed on the source database for an extended period, the latency information may be inaccurate.

    Note

    If the migration instance shows a long latency, you can perform a DML operation on the source database to update the latency information.

  • During full data migration, DTS consumes read and write resources on the source and destination databases. This may increase the database load. Therefore, evaluate the performance of the source and destination databases before migration. Migrate data during off-peak hours, for example, when the CPU load of the source and destination databases is below 30%.

  • Full data migration involves concurrent INSERT operations. This causes fragmentation in the tables of the destination database. As a result, the storage space used by the tables in the destination database is larger than that in the source database after full migration is complete.

  • During the migration, if data is written to the destination database from a data source other than DTS, data inconsistency may occur between the source and destination databases. This may even cause the migration instance to fail.

  • If the task fails, DTS technical support will attempt to recover it within 8 hours. During the recovery process, operations such as restarting the task or adjusting its parameters may be performed.

    Note

    When parameters are adjusted, only DTS task parameters are modified. Database parameters remain unchanged.The parameters that may be modified include but are not limited to those described in Modify instance parameters.

Billing

Migration type

Link configuration fee

Data transfer cost

Full data migration

Free of charge.

This example is free of charge. If you set Access Method for the destination database to Public IP Address, you are charged for data transfer over the Internet.

Incremental data migration

Charged. For more information, see Billing overview.

SQL operations supported by incremental migration

Operation type

SQL operation statement

DML

INSERT, UPDATE, DELETE

DDL

CREATE TABLE, RENAME TABLE, ALTER TABLE, DROP TABLE, TRUNCATE TABLE, CREATE INDEX, DROP INDEX

Note
  • Only CREATE TABLE operations for single tables can be migrated. CREATE TABLE operations for sharded databases and tables cannot be migrated.

  • CREATE INDEX operations cannot be migrated if the source database is a PolarDB-X 2.0 Enterprise Edition instance.

  • A RENAME TABLE operation may cause data inconsistency. For example, if you select only one table as the migration object and rename the table in the source instance during migration, the data of this table is not migrated to the destination database. To prevent this issue, select the entire database to which the table belongs as the migration object 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 both included in the migration objects.

Required permissions for database accounts

Database

Full migration

Incremental migration

Source PolarDB-X 2.0

SELECT permission.

REPLICATION SLAVE, REPLICATION CLIENT, and SELECT permissions on the objects to be migrated.

Destination PolarDB-X 1.0 instance

Read and write permissions.

To create and grant permissions to a database account:

Procedure

  1. Go to the migration task list page of the destination region. You can use one of the following methods.

    From the DTS console

    1. Log on to the Data Transmission Service (DTS) console.

    2. In the navigation pane on the left, click Data Migration.

    3. In the upper-left corner of the page, select the region where the migration instance is located.

    From the DMS console

    Note

    The actual operations may vary based on the mode and layout of the DMS console. For more information, see Simple mode console and Customize the layout and style of the DMS console.

    1. Log on to the Data Management (DMS) console.

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

    3. To the right of Data Migration Tasks, select the region where the migration instance is located.

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

  3. Configure the source and destination databases.

    Category

    Configuration

    Description

    None

    Task Name

    DTS automatically generates a task name. We recommend that you specify a descriptive name for easy identification. The name does not need to be unique.

    Source Database

    Select Existing Connection

    • To use a database instance that has been added to the system (created or saved), select the desired database instance from the drop-down list. The database information below will be automatically configured.

      Note

      In the DMS console, this parameter is named Select a DMS database instance..

    • If you have not registered the database instance with the system, or do not need to use a registered instance, manually configure the database information below.

    Database Type

    Select PolarDB-X 2.0.

    Access Method

    Select Alibaba Cloud Instance.

    Instance Region

    Select the region of the source PolarDB-X 2.0 instance.

    Replicate Data Across Alibaba Cloud Accounts

    In this example, a database instance under the current Alibaba Cloud account is used. Select No.

    Instance ID

    Select the ID of the source PolarDB-X 2.0 instance.

    Database Account

    Enter the database account of the source PolarDB-X 2.0 instance. For information about the required permissions, see Required permissions for database accounts.

    Database Password

    Enter the password for the database account.

    Destination Database

    Select Existing Connection

    • To use a database instance that has been added to the system (created or saved), select the desired database instance from the drop-down list. The database information below will be automatically configured.

      Note

      In the DMS console, this parameter is named Select a DMS database instance..

    • If you have not registered the database instance with the system, or do not need to use a registered instance, manually configure the database information below.

    Database Type

    Select PolarDB-X 1.0.

    Access Method

    Select Alibaba Cloud Instance.

    Instance Region

    Select the region of the destination PolarDB-X 1.0 instance.

    Instance ID

    Select the ID of the destination PolarDB-X 1.0 instance.

    Database Account

    Enter the database account of the destination PolarDB-X 1.0 instance. For information about the required permissions, see Required permissions for database accounts.

    Database Password

    Enter the password for the database account.

  4. After you complete the configuration, click Test Connectivity and Proceed at the bottom of the page.

    Note

    Ensure that the DTS service IP address segments are 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 task objects.

    1. On the Configure Objects page, configure the objects to be migrated.

      Configuration

      Description

      Migration Types

      • If you only need to perform a full migration, select Full Data Migration.

      • To perform a migration with no downtime, select both Full Data Migration and Incremental Data Migration.

      Note

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

      Incremental CDC Type

      Select an option based on the log engine of your PolarDB-X 2.0 instance.

      Note
      • This parameter is available only if you select Incremental Data Migration for Migration Types.

      • If you want to select Multi-stream CDC, make sure that multi-stream is enabled for your PolarDB-X 2.0 instance. For more information, see Enable multi-stream.

      Processing Mode of Conflicting Tables

      • Precheck and Report Errors: Checks whether tables with the same names exist in the destination database. If no tables with the same names exist, the precheck item is passed. If tables with the same names exist, an error is reported during the precheck phase, and the data migration task does not start.

        Note

        If a table in the destination database has the same name but cannot be easily deleted or renamed, you can change the name of the table in the destination database. For more information, see Object name mapping.

      • Ignore Errors and Proceed: Skips the check for tables with the same names.

        Warning

        Selecting Ignore Errors and Proceed may cause data inconsistency and business risks. 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:

          • During full migration, DTS keeps the record in the destination cluster. The record from the source database is not migrated to the destination database.

          • During incremental migration, DTS does not keep the record in the destination cluster. 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. Proceed with caution.

      Source Objects

      In the Source Objects box, click the objects to migrate, and then click 向右小箭头 to move them to the Selected Objects box.

      Note

      You can select objects at the database or table level.

      Selected Objects

      • To set the name of a migration object in the destination instance, or to specify the object that receives data in the destination instance, right-click the migration object in the Selected Objects box to make changes. For more information, see Object name mapping.

      • To remove a selected migration object, click the object in the Selected Objects box, and then click image to move it to the Source Objects box.

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

      • To set a WHERE clause to filter data, right-click the table to migrate in the Selected Objects box and set the filter condition in the dialog box that appears. For more information about how to set the condition, see Set filter conditions.

      • To select the SQL operations for incremental migration, right-click the migration object in the Selected Objects box and select the desired SQL operations in the dialog box that appears.

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

      Configuration

      Description

      Dedicated Cluster for Task Scheduling

      By default, DTS schedules tasks on a shared cluster. You do not need to select one. If you want more stable tasks, you can purchase a dedicated cluster to run DTS migration tasks.

      Retry Time for Failed Connections

      After the migration task starts, if the connection to the source or destination database fails, DTS reports an error and immediately starts continuous retry attempts. The default retry duration is 720 minutes. You can also customize the retry time within a range of 10 to 1440 minutes. We recommend that you set it to more than 30 minutes. If DTS reconnects to the source and destination databases within the set time, the migration task automatically resumes. Otherwise, the task fails.

      Note
      • For multiple DTS instances that share the same source or destination, the network retry time is determined by the setting of the last created task.

      • Because you are charged for the task during the connection retry period, we recommend that you customize the retry time based on your business needs, or release the DTS instance as soon as possible after the source and destination database instances are released.

      Retry Time for Other Issues

      After the migration task starts, if other non-connectivity issues occur in the source or destination database (such as a DDL or DML execution exception), DTS reports an error and immediately starts continuous retry attempts. The default retry duration is 10 minutes. You can also customize the retry time within a range of 1 to 1440 minutes. We recommend that you set it to more than 10 minutes. If the related operations succeed within the set retry time, the migration task automatically resumes. Otherwise, the task fails.

      Important

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

      Enable Throttling for Full Data Migration

      During the full migration phase, DTS consumes some read and write resources of the source and destination databases, which may increase the database load. As needed, you can choose whether to set speed limits for the full migration task. You can set Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s) to reduce the pressure on the destination database.

      Note
      • This configuration item is available only if you select Full Data Migration for Migration Types.

      • You can also adjust the full migration speed after the migration instance is running.

      Enable Throttling for Incremental Data Migration

      As needed, you can also choose whether to set speed limits for the incremental migration task. You can set RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s) to reduce the pressure on the destination database.

      Note
      • This configuration item is available only if you select Incremental Data Migration for Migration Types.

      • You can also adjust the incremental migration speed after the migration instance is running.

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

      Choose whether to write heartbeat SQL information to the source database when the DTS instance is running.

      • Yes: Heartbeat SQL information is not written to the source database. This may cause the DTS instance to report a delay.

      • No: Writes heartbeat SQL information to the source database. This may interfere with features such as physical backup and cloning of the source database.

      Environment Tag

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

      Monitoring and Alerting

      Select whether to set alerts and receive alert notifications based on your business needs.

      • No: Does not set an alert.

      • Yes: Sets an alert. You must also set the alert threshold and alert contacts. The system sends an alert notification if the migration fails or the latency exceeds the threshold.

    3. Click Next: Data Validation to configure a data validation task.

      For more information about the data validation feature, see Configure data validation.

  6. Save the task and run a precheck.

    • To view the parameters for configuring this instance when you call the API operation, move the pointer over the Next: Save Task Settings and Precheck button and click Preview OpenAPI parameters in the bubble.

    • If you do not need to view or have finished viewing the API parameters, click Next: Save Task Settings and Precheck at the bottom of the page.

    Note
    • Before the migration task starts, a precheck is performed. The task starts only after it passes the precheck.

    • If the precheck fails, click View Details next to the failed check item, fix the issue based on the prompt, and then run the precheck again.

    • If a warning is reported during the precheck:

      • For check items that cannot be ignored, click View Details next to the failed item, fix the issue based on the prompt, and then run the precheck again.

      • For check items that can be ignored and do not need to be fixed, you can click Confirm Alert Details, Ignore, OK, and Precheck Again to skip the alert item and run the precheck again. If you choose to shield an alert item, it may cause issues such as data inconsistency and pose risks to your business.

  7. Purchase the instance.

    1. When the Success Rate is 100%, click Next: Purchase Instance.

    2. On the Purchase page, select the link specification for the data migration instance. For more information, see the following table.

      Category

      Parameter

      Description

      New Instance Class

      Resource Group Settings

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

      Instance Class

      DTS provides migration specifications with different performance levels. The link specification affects the migration speed. You can select a specification based on your business scenario. For more information, see Data migration link specifications.

    3. After the configuration is complete, read and select Data Transmission Service (Pay-as-you-go) Service Terms.

    4. Click Buy and Start, and in the OK dialog box that appears, click OK.

      You can view the progress of the migration instance on the Data Migration Tasks list page.

      Note
      • If the migration instance does not include an incremental migration task, it stops automatically. After the instance stops, its Status is Completed.

      • If the migration instance includes an incremental migration task, it does not stop automatically, and the incremental migration task continues to run. While the incremental migration task is running normally, the Status of the instance is Running.