Migrate data from a PolarDB-X 2.0 database to an OceanBase database MySQL tenant

更新时间:
复制 MD 格式

This topic describes how to use Data Transmission Service (DTS) to migrate data from a PolarDB-X 2.0 database to an OceanBase database MySQL tenant.

Important

If a data migration task remains inactive for an extended period (with a status of Failed, Paused, or Completed), it may not be resumable due to factors such as the retention period of incremental logs. To reclaim resources, Data Transmission Service releases data migration tasks that have been inactive for more than three days. We recommend that you configure alerts for your tasks and handle any exceptions promptly.

Background information

PolarDB for Xscale (PolarDB-X) is a high-performance, cloud-native distributed database developed by Alibaba Cloud. It provides high throughput, large storage capacity, low latency, easy scalability, and high availability. For more information, see What is PolarDB for Xscale?.

Prerequisites

Limits

  • Operational restrictions on the source database

    During schema migration and full data migration, do not perform DDL operations that change the schema of databases or tables. Otherwise, the data migration task may fail.

  • DTS supports PolarDB-X 2.0 V5.4.x.

  • DTS does not support migrating TTL tables from a PolarDB-X 2.0 database to an OceanBase database MySQL tenant.

  • Tables to be migrated must have a primary key or a UNIQUE constraint to ensure that all rows are unique. Otherwise, data inconsistency may occur in the destination database.

  • DTS can only migrate objects whose database, table, and column names use ASCII characters and do not contain special characters. Special characters include line breaks, spaces, and the following: .|"'`()=;/&\.

  • DTS does not support triggers in the destination database. If triggers exist, the data migration may fail.

  • OceanBase databases do not support using an auto-increment column (`AUTO_INCREMENT`) as a partition key column. If a source table contains an `AUTO_INCREMENT` partition key column, you must manually modify the table creation statement.

Notes

  • If you migrate broadcast tables from a PolarDB-X 2.0 database, data loss may occur and data accuracy cannot be guaranteed.

  • If the source character set is UTF-8, you should use a compatible character set for the destination, such as UTF-8 or UTF-16. This prevents issues such as garbled text in the destination database because of character set incompatibility.

  • If the clocks between nodes are not synchronized, the reported latency for incremental or reverse incremental synchronization may be inaccurate.

    For example, if a node's clock is ahead of the standard time, the latency may appear as a negative value. If a node's clock is behind the standard time, the reported latency may be artificially high.

  • You should confirm that the migration precision for column types such as DECIMAL, FLOAT, or DOUBLE meets your requirements. If the precision of a destination column is less than the source column, data truncation may occur. This can cause data inconsistency between the source and destination databases.

  • By default, DTS sets the `lower_case_table_names` parameter to `1` for the destination database. This means that destination database objects are created with lowercase names.

  • The server that hosts the source PolarDB-X 2.0 database must have sufficient outbound bandwidth. Otherwise, data migration performance will be affected.

  • During full migration and incremental synchronization, DTS temporarily disables constraint checks and foreign key cascade operations at the session level. If the source database performs cascade updates or deletions, data inconsistency may occur between the source and destination databases.

  • If you switch the network type of the PolarDB-X 2.0 database during data migration, you must adjust the network connection information for the data migration task after the switch is complete.

  • If a data migration task is configured only for full migration, do not write new data to the source instance to prevent data inconsistency. To maintain real-time data consistency between the source and destination databases, select Schema Migration, Full Migration, and Incremental Synchronization when you configure the task.

  • To perform incremental synchronization, note the following about binary logs:

    • DTS only supports the single-stream binary log consumption and subscription feature provided by PolarDB-X 2.0. For more information, see Binary Log Service.

    • You must enable binary logs and set `binlog_row_image` to `full`. Otherwise, the precheck will report an error and the data migration task cannot be started.

    • If you select only Incremental Synchronization when you create the data migration task, the local incremental logs of the source database must be retained for more than 48 hours.

      If you select Full Migration and Incremental Synchronization, the local incremental logs of the source database must be retained for at least 7 days. Otherwise, DTS may fail to retrieve the incremental logs. This can cause the data migration task to fail and may lead to data inconsistency between the source and destination databases.

      Note

      After the full migration is complete, you can change the retention period of local incremental logs to more than 48 hours.

  • In a database and table aggregation scenario:

    • You can use matching rules to map the relationship between the source and destination.

    • You must create the table schemas in the destination database yourself. If you use DTS to create them, you must skip any failed objects during the schema migration step.

  • If the table schemas of the source and destination are not identical, data inconsistency may occur. The known scenarios are as follows:

    • If you manually create a table schema that is outside the supported scope of DTS, implicit conversion issues may occur. This can lead to inconsistent column types between the source and destination databases.

    • If a column's data length in the destination database is smaller than in the source database, data truncation may occur. This can lead to data inconsistency between the source and destination databases.

  • If the source or destination database is case-insensitive and contains table objects whose names differ only in case, the migration result may be unpredictable.

Supported source and destination instance types

In the following table, an OceanBase database MySQL tenant is abbreviated as OB_MySQL.

Source

Destination

PolarDB-X 2.0 (Alibaba Cloud PolarDB-X 2.0 instance)

OB_MySQL (OceanBase cluster instance)

PolarDB-X 2.0 (Alibaba Cloud PolarDB-X 2.0 instance)

OB_MySQL (Serverless instance)

Data type mapping

PolarDB-X 2.0 database

OceanBase database MySQL tenant

INTEGER

INTEGER

TINYINT

TINYINT

MEDIUMINT

MEDIUMINT

BIGINT

BIGINT

SMALLINT

SMALLINT

DECIMAL

DECIMAL

NUMERIC

NUMERIC

FLOAT

FLOAT

REAL

REAL

DOUBLE PRECISION

DOUBLE PRECISION

BIT

BIT

CHAR

CHAR

VARCHAR

VARCHAR

BINARY

BINARY

VARBINARY

VARBINARY

BLOB

BLOB

TEXT

TEXT

ENUM

ENUM

SET

SET

JSON

JSON

DATE

DATE

DATETIME

DATETIME

TIMESTAMP

TIMESTAMP

TIME

TIME

YEAR

YEAR

Procedure

  1. Log on to the OceanBase Management Console and purchase a data migration task.

    For more information, see Purchase a data migration task.

  2. On the Data Transmission > Data Migration page, click Configure for your new data migration task.

    image.png

    To reference an existing task configuration, you can click Reference Configuration. For more information, see Reference a data migration task configuration.

  3. On the Select Source and Destination page, you can configure the parameters.

    Parameter

    Description

    Migration Task Name

    The name can contain Chinese characters, letters, and numbers. It cannot contain spaces and must be no more than 64 characters long.

    Source

    If you have created a PolarDB-X 2.0 data source, select it from the drop-down list. If not, click Create Data Source in the drop-down list to create one in the dialog box that appears. For more information about the parameters, see Create a PolarDB-X 2.0 data source.

    Destination

    If you have created a data source for the MySQL tenant of the OceanBase database, select it from the drop-down list. If not, click Create Data Source in the drop-down list to create one in the dialog box that appears. For more information about the parameters, see Create an OceanBase data source.

    Tags (Optional)

    Click the text box and select a tag from the drop-down list. You can also click Manage Tags to create, modify, or delete tags. For more information, see Manage data migration tasks using tags.

  4. Click Next. On the Select Migration Types page, select the required migration types.

    The migration types include Schema Migration, Full Migration, Incremental Synchronization, Full Verification, and Reverse Incremental Synchronization.

    image

    Migration Type

    Description

    Schema Migration

    After the schema migration task starts, DTS migrates the definitions of database objects from the source database to the destination database. These objects include tables, indexes, constraints, comments, and views. Temporary tables are automatically filtered out.

    The schema migration from a PolarDB-X 2.0 database to a MySQL tenant of an OceanBase database supports both DRDS and AUTO mode database and table schemas.

    Important

    When a table without a primary key in AUTO mode is migrated to an OceanBase database, it is converted into a non-partitioned table without a primary key. If partitioning is required, manually specify the primary key and partition key.

    Full Migration

    Before you perform data migration, evaluate the performance of the source and destination. Perform data migration during off-peak hours. Otherwise, DTS consumes some read and write resources of the source and destination during full migration, which may increase the database load. For more information about performance evaluation, see Performance evaluation for migration evaluation.

    After the full migration task starts, DTS migrates the existing data from the source tables to the corresponding tables in the destination database.

    Incremental Synchronization

    After the incremental synchronization task starts, DTS synchronizes the changed data (new, modified, or deleted) from the source database to the corresponding tables in the destination database.

    Incremental Synchronization supports DML Synchronization. You can customize the configuration as needed. For more information, see Customize DDL and DML operations.

    Full Verification

    After the full migration is complete and the incremental data is synchronized to the destination and is almost up-to-date with the source, DTS automatically starts a full data verification task for the configured source and destination tables.

    • If you select Incremental Synchronization but do not select all DML operations for DML Synchronization, DTS does not support full data verification in this scenario.

    • Before you perform data migration, evaluate the performance of the source and destination. Perform data migration during off-peak hours. Otherwise, DTS consumes some read resources of the source and destination during full verification, which may increase the database load.

    Reverse Incremental

    After the reverse incremental synchronization task starts, it can synchronize the data changes that occur in the destination database back to the source database in real time after a service switchover.

    By default, reverse incremental synchronization reuses the configuration of incremental synchronization. You can also customize the configuration as needed.

  5. Click Next. On the Select Migration Objects page, specify migration objects for the data migration task.

    You can select Specify Objects or Match Rules to specify the migration objects. This topic describes how to specify the migration objects by using Specify Objects. For information about matching rules, see Configure and modify matching rules.

    Important
    • The names of tables to be migrated, as well as the names of columns in the tables, must not contain Chinese characters.

    • If a database or table name contains double dollar signs ($$), you cannot create the migration task.

    image.png

    1. In the Select Migration Objects section, select Specify Objects.

    2. In the Source Object(s) list of the Specify Migration Scope section, select the objects to migrate. You can select tables and views of one or more databases.

    3. Click > to add them to the Target Object(s) list.

    Data Transmission Service lets you import objects from text files. It also lets you rename destination objects, set row filters, view column information, and remove a single object or all objects.

    Note

    When you select migration objects using the Matching Rules method, the matching rule syntax overrides the renaming capability, and the Actions section is limited to setting filter conditions. For more information, see Configure and modify matching rules.

    Operation

    Description

    Import Object

    1. In the list on the right of the selection area, click Import Object in the upper-right corner.

    2. In the dialog box that appears, click OK.

      Important

      The import operation overwrites previous selections. Proceed with caution.

    3. In the Import Migration Objects dialog box, import the objects to be migrated.

      You can import a CSV file to rename database tables, set row filtering conditions, and perform other operations. For more information, see Download and import migration object configurations.

    4. Click Check Validity.

      After you import the migration objects, check their validity first. Column field mapping is not currently supported.

    5. After the check is passed, click OK.

    Rename

    Data Transmission Service lets you rename migration objects. For more information, see Rename database and table objects.

    Settings

    Data Transmission Service supports row filtering using WHERE conditions. For more information, see Filter data with SQL conditions.

    You can also view the column information of migration objects in the View Columns area.

    Remove/Remove All

    Data Transmission Service lets you remove one or more objects that have been temporarily selected for the destination during data mapping.

    • Remove a single migration object

      In the list on the right of the selection area, hover over the target object and click the displayed Remove button to remove the migration object.

    • Remove all migration objects

      In the list on the right of the selection area, click Remove All in the upper-right corner. In the dialog box that appears, click OK to remove all migration objects.

  6. Click Next. On the Migration Options page, configure the parameters.

    • Full migration

      The following parameters are displayed only if you select Full Migration on the Select Migration Types page.

      image

      Parameter

      Description

      Read Concurrency

      This parameter specifies the number of concurrent threads for reading data from the source during full migration. The maximum value is 512. A high degree of concurrency may put excessive pressure on the source database and affect your business.

      Write Concurrency

      This parameter specifies the number of concurrent threads for writing data to the destination during full migration. The maximum value is 512. A high degree of concurrency may put excessive pressure on the destination database and affect your business.

      Full Migration Rate Limit

      You can enable the full migration rate limit as needed. If you enable it, set the RPS (maximum number of data rows that can be migrated to the destination per second during full migration) and BPS (maximum volume of data that can be migrated to the destination per second during full migration).

      Note

      The RPS and BPS settings only serve as throttling limits. The actual performance of full migration is affected by factors such as the source, destination, and instance specifications.

      Policy for Existing Records in Destination Table Objects

      The policies include Ignore and Stop Migration:

      • Select Ignore: If data exists in the destination table object and a conflict occurs between the original data and the data to be written, DTS logs the conflicting data and keeps the original data unchanged.

        Important

        If you select Ignore, full verification uses the IN mode to pull data. It cannot verify scenarios where the destination has data that the source does not. The verification performance is also degraded to some extent.

      • Select the default value Stop Migration: If data exists in the destination table object, full migration reports an error and is not allowed. Handle the data in the destination and then continue the migration.

        Important

        If you click Resume after an error occurs, DTS ignores this setting and continues to migrate table data. Proceed with caution.

      Allow index suffixes

      You can specify whether to allow index creation after full data migration is complete. This feature can shorten the time required for full migration. For notes on post-migration index creation, see the description below the table.

      Important
      • This parameter is displayed only if you select both Schema Migration and Full Migration on the Select Migration Types page.

      • Only non-unique key indexes support post-migration creation.

      • When an index is being created, if the destination OceanBase database reports one of the following errors, DTS ignores the error and considers the index successfully created. It will not attempt to create the index again.

        • The OceanBase database MySQL tenant reports a Duplicate key name error.

        • The OceanBase database Oracle tenant reports a name is already used by an existing object error.

      If the destination is an OceanBase database and you select Allow, configure the following parameters:

      • Concurrency for a single index DDL statement: A higher degree of parallelism consumes more resources and increases the migration speed.

      • Maximum number of concurrent index DDL statements: The maximum number of post-migration index DDL statements that the system can invoke at the same time.

      If you allow post-migration index creation, we recommend that you use a command-line client to adjust the following business tenant parameters based on the hardware and service traffic of the OceanBase database.

      // File memory buffer limit
      alter system set _temporary_file_io_area_size = '10' tenant = 'xxx'; 
      // V4.x disable throttling
      alter system set sys_bkgd_net_percentage = 100;  
    • Incremental synchronization

      The following parameters appear only if you select Incremental Synchronization on the Select Migration Types page.

      image

      Parameter

      Description

      Write Concurrency

      This parameter specifies the number of concurrent threads for writing data to the destination during incremental synchronization. The maximum value is 512. A high degree of concurrency may put excessive pressure on the destination and affect your services.

      Incremental Synchronization Rate Limit

      You can decide whether to enable the incremental synchronization rate limit as needed. If you enable it, set RPS (the maximum number of data rows that can be synchronized to the destination per second during incremental synchronization) and BPS (the maximum volume of data that can be synchronized to the destination per second during incremental synchronization).

      Note

      The RPS and BPS settings here only serve as a rate-limiting capability. The actual performance of incremental synchronization is affected by factors such as the source, destination, and instance specifications.

      Incremental Synchronization Start Offset

      • If you select Full Migration, this parameter is not displayed.

      • If you select Incremental Synchronization but not Full Migration, specify a point in time from which to start migrating data. The default value is the current system time. For more information, see Configure an incremental synchronization offset.

    • Reverse Incremental

      The parameters in this section appear only if you select Reverse Incremental Synchronization on the Select Migration Types page. By default, the Reuse Incremental Synchronization Configuration option is selected.

      image

      You can also clear this option and configure the parameters as needed.

      Parameter

      Description

      Write Concurrency

      This parameter specifies the number of concurrent threads for writing data to the source during reverse incremental synchronization. The maximum value is 512. A high degree of concurrency may put excessive pressure on the source database and affect your business.

      Reverse Incremental Synchronization Rate Limit

      You can enable the reverse incremental synchronization rate limit as needed. If you enable it, set the RPS (maximum number of data rows that can be synchronized to the source per second during reverse incremental synchronization) and BPS (maximum volume of data that can be synchronized to the source per second during reverse incremental synchronization).

      Note

      The RPS and BPS settings only serve as throttling limits. The actual performance of reverse incremental synchronization is affected by factors such as the source, destination, and instance specifications.

      Incremental Synchronization Start Offset

      • This parameter is not displayed if you select Full Migration as a migration type.

      • If you do not select Full Migration but select Incremental Synchronization, the start offset is based on the forward switchover (if any) by default and cannot be modified.

    • Advanced Options

      The parameters in this section appear only if the destination OceanBase database MySQL tenant is version 4.3.0 or later and you select Schema Migration on the Select Migration Types page.

      image

      The storage classes for destination table objects include Default, Row Store, Column Store, and Hybrid Row-Column Store. This setting specifies the storage class for destination table objects during schema migration. For more information, see default_table_store_format.

      Note

      The Default option automatically adapts to the parameter settings of the destination. During schema migration, table objects are written to the corresponding schema based on the specified storage class.

  7. Click Precheck to precheck the data migration task.

    In the Precheck step, Data Transmission Service checks whether items meet the requirements, such as the read and write permissions of the database user and the network connectivity of the database. You can start the data migration task only after all check items pass. If the precheck fails:

    • You can identify and troubleshoot the problem, and then run the precheck again until it succeeds.

    • You can also click Skip in the Actions column for a failed precheck item. A dialog box appears that describes the impact of skipping this operation. To proceed, click OK.

  8. After the precheck passes, click Start Task.

    If you do not want to start the task immediately, click Save. You can then start the task manually from the Data Migration Task List page or using batch operations. For more information about batch operations, see Batch Operations on Data Migration Tasks.

    Data Transmission Service lets you modify migration objects and their row filtering conditions while a data migration task is running. For more information, see View and modify migration objects and their filter conditions. After the data migration task starts, it performs the migration steps sequentially based on the selected migration types. For more information, see View migration details.

References