All Products
Search
Document Center

ApsaraDB for OceanBase:Migrate data from a PolarDB-X 2.0 database to a MySQL tenant of OceanBase Database

Last Updated:Dec 12, 2024

This topic describes how to use the data transmission service to migrate data from a PolarDB-X 2.0 database to a MySQL tenant of OceanBase Database.

Important

A data migration task remaining in an inactive state for a long time may fail to be resumed depending on the retention period of incremental logs. Inactive states are Failed, Stopped, and Completed. The data transmission service releases data migration tasks remaining in an inactive state for more than 3 days to reclaim related resources. We recommend that you configure alerting for data migration tasks and handle task exceptions in a timely manner.

Background

PolarDB-X is a cloud-based high-performance distributed database service that is independently developed by Alibaba Group. PolarDB-X provides high throughput, large storage capacity, low latency, high scalability, and high availability to meet your business requirements in the cloud era. For more information, see What is PolarDB for Xscale?

Prerequisites

Limitations

  • Limitations on the source database

    Do not perform DDL operations that modify database or table schemas during schema migration or full data migration. Otherwise, the data migration task may be interrupted.

  • The data transmission service supports PolarDB-X 2.0 databases of version 5.4.x.

  • When you migrate data from a PolarDB-X 2.0 database to a MySQL tenant of OceanBase Database, you cannot migrate tables of the time to live (TTL) type.

  • A table to be migrated must have a PRIMARY KEY or UNIQUE constraint and contain unique fields to avoid data inconsistency between the source and destination databases.

  • The data transmission service supports the migration of an object only when the following conditions are met: the database name, table name, and column name of the object are ASCII-encoded without special characters. The special characters are line breaks, spaces, and the following characters: . | " ' ` ( ) = ; / & \.

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

  • OceanBase Database does not support using an auto-increment column as the partitioning column. If a source table contains an auto-increment column, manually modify the table creation statement.

Considerations

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

  • If the UTF-8 character set is used in the source, we recommend that you use a compatible character set, such as UTF-8 or UTF-16, in the destination to avoid garbled characters.

  • If the clocks between nodes or between the client and the server are out of synchronization, the latency may be inaccurate during incremental synchronization or reverse incremental migration.

    For example, if the clock is earlier than the standard time, the latency can be negative. If the clock is later than the standard time, the latency can be positive.

  • Check whether the migration precision of the data transmission service for columns of data types such as DECIMAL, FLOAT, and DOUBLE is as expected. If the precision of the destination field type is lower than that of the source field type, the value with a higher precision may be truncated. This may result in data inconsistency between the source and destination fields.

  • The default configuration lower_case_table_names = 1 of the destination database is used. Database objects are created in lowercase in the destination database.

  • The server where the source PolarDB-X 2.0 database resides must have sufficient outbound bandwidth to ensure the data migration efficiency.

  • During full data migration and incremental synchronization, the data transmission service temporarily disables constraint checks and cascade operations on foreign keys at the session level. Cascade update or delete operations performed in the source database may cause data inconsistency between the source and destination databases.

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

  • If only full data migration is configured for the data migration task, to avoid data inconsistency between the source and destination databases, do not write new data to the source instance during the migration. To ensure real-time data consistency, we recommend that you select schema migration, full data migration, and incremental synchronization when you configure a data migration task.

  • If you need to perform incremental synchronization, take note of the following points about binlogs:

    • The data transmission service supports only binlog consumption and subscription in a single flow in PolarDB-X 2.0. For more information, see Binary logs.

    • You must enable binlogs and set binlog_row_image to full. Otherwise, errors will be returned during the precheck and the data migration task cannot be started.

    • If you select only Incremental Synchronization when you create the data migration task, the data transmission service requires that the local incremental logs of the source database be retained for at least 48 hours.

      If you select Full Data Migration and Incremental Synchronization when you create the data migration task, the data transmission service requires that the local incremental logs of the source database be retained for at least seven days. If the data transmission service cannot obtain incremental logs, the data migration task may fail or even the data between the source and destination databases may be inconsistent after migration.

      Note

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

  • Take note of the following considerations if you want to aggregate multiple tables:

    • We recommend that you configure the mappings between the source and destination databases by specifying matching rules.

    • We recommend that you manually create schemas at the destination. If you create a schema by using the data transmission service, skip the failed objects in the schema migration step.

  • A difference between the source and destination table schemas may result in data consistency. Some known scenarios are described as follows:

    • When you manually create a table schema at the destination, if the data type of any column is not supported by the data transmission service, implicit data type conversion may occur at the destination, which causes inconsistent column types between the source and destination databases.

    • If the length of a column at the destination is shorter than that in the source database, the data of this column may be automatically truncated, which causes data inconsistency between the source and destination databases.

  • If the source or destination database contains table objects that differ only in letter cases, the data migration results may not be as expected due to case insensitivity in the source or destination database.

Supported source and destination instance types

In the following table, OB_MySQL stands for the MySQL tenant of OceanBase Database.

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 mappings

PolarDB-X 2.0 database

MySQL tenant of OceanBase Database

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 ApsaraDB for OceanBase console and purchase a data migration task.

    For more information, see Purchase a data migration task.

  2. Choose Data Transmission > Data Migration. On the page that appears, click Configuration for the data migration task.

    image.png

    If you want to reference the configurations of an existing task, click Reference Configuration. For more information, see Reference the configuration of a data migration task.

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

    Parameter

    Description

    Migration Task Name

    We recommend that you set it to a combination of digits and letters. It must not contain any spaces and cannot exceed 64 characters in length.

    Tag (Optional)

    Click the field and select a target tag from the drop-down list. You can also click Manage Tags to create, modify, and delete tags. For more information, see Use tags to manage data migration tasks.

    Source

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

    Destination

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

    Important

    For the MySQL tenant of OceanBase Database at the destination, Instance Type must be set to OceanBase Cluster Instance or Serverless Instance.

  4. Click Next. On the Select Migration Type page, specify migration types for the current data migration task.

    Options available for Migration Type are Schema Migration, Full Data Migration, Incremental Synchronization, Full Verification, and Reverse Incremental Migration.

    image

    Migration type

    Description

    Schema migration

    After a schema migration task is started, the data transmission service migrates the definitions of database objects (such as tables, indexes, constraints, comments, and views) from the source database to the destination database and automatically filters out temporary tables.

    Schema migration from a PoarDB-X 2.0 database to a MySQL tenant of OceanBase Database supports the DRDS and AUTO modes.

    Important

    In AUTO mode, a table without a primary key is converted into a non-partitioned table without a primary key after it is migrated to OceanBase Database. If you want to create partitions, manually specify the primary key and partitioning key.

    Full data migration

    Before data migration, assess the performance of the source and destination databases. We recommend that you perform data migration in off-peak hours. During full data migration, the data transmission service consumes some read and write resources in the source and destination databases. This may increase the loads of the databases. For information about performance assessment, see Performance assessment of migration assessment.

    After a full data migration task is started, the data transmission service migrates existing data of tables in the source database to corresponding tables in the destination database.

    Incremental synchronization

    After an incremental synchronization task is started, the data transmission service synchronizes changed data (data that is added, modified, or removed) from the source database to corresponding tables in the destination database.

    DML Synchronization is supported for Incremental Synchronization. You can select operations as needed. For more information, see Configure DDL/DML synchronization.

    Full verification

    After the full data migration and incremental synchronization tasks are completed, the data transmission service automatically initiates a full verification task to verify the tables in the source and destination databases.

    • If you have selected Incremental Synchronization but did not select all DML operations in the DML Synchronization section, you cannot select Full Verification.

    • Before data migration, assess the performance of the source and destination databases. We recommend that you perform data migration in off-peak hours. During full verification, the data transmission service consumes some read resources in the source and destination databases. This may increase the loads of the databases.

    Reverse incremental migration

    Data changes made in the destination database after the business database switchover are synchronized to the source database in real time through reverse incremental migration.

    Generally, incremental synchronization configurations are reused for reverse incremental migration. You can also customize the configurations for reverse incremental migration as needed.

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

    You can select Specify Objects or Match Rules to specify the migration objects.

    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.

    • If you select Specify Objects, select the objects to be migrated on the left and click > to add them to the list on the right. You can select tables and views of one or more databases as the migration objects.

      The data transmission service allows you to import objects from text files, rename destination objects, set row filters, view column information, and remove a single migration object or all migration objects.

      Note

      When you select Match Rules to specify migration objects, object renaming is implemented based on the syntax of the specified matching rules. In the operation area, you can only set filtering conditions. For more information, see Configure matching rules.

      image.png

      Operation

      Description

      Import objects

      1. In the list on the right, click Import Objects in the upper-right corner.

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

        Important

        This operation will overwrite previous selections. Proceed with caution.

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

        You can import CSV files to rename databases or tables and set row filtering conditions. For more information, see Download and import the settings of migration objects.

      4. Click Validate.

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

      5. After the validation succeeds, click OK.

      Rename objects

      The data transmission service allows you to rename migration objects. For more information, see Rename a database table.

      Configure settings

      The data transmission service allows you to filter rows by using WHERE conditions. For more information, see Use SQL conditions to filter data.

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

      Remove one or all objects

      The data transmission service allows you to remove a single object or all migration objects that are added to the right-side list during data mapping.

      • Remove a single migration object

        In the list on the right, move the pointer over the object that you want to remove, and click Remove to remove the migration object.

      • Remove all migration objects

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

    • Select Match Rules. For more information, see Configure matching rules.

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

    • Full data migration

      The following table describes the parameters for full data migration, which are displayed only if you have selected Full Data Migration on the Select Migration Type page.

      image

      Parameter

      Description

      Read Concurrency Configuration

      The concurrency for reading data from the source during full data migration. The maximum value is 512. A high read concurrency may incur excessive stress on the source, affecting the business.

      Write Concurrency Configuration

      The concurrency for writing data to the destination during full data migration. The maximum value is 512. A high write concurrency may incur excessive stress on the destination, affecting the business.

      Full Data Migration Rate Limit

      You can choose whether to limit the full data migration rate as needed. If you choose to limit the full data migration rate, you must specify the records per second (RPS) and bytes per second (BPS). The RPS specifies the maximum number of data rows migrated to the destination per second during full data migration, and the BPS specifies the maximum amount of data in bytes migrated to the destination per second during full data migration.

      Note

      The RPS and BPS values specified here are only for throttling. The actual full data migration performance is subject to factors such as the settings of the source and destination and the instance specifications.

      Processing Strategy When Destination Table Has Records

      Valid values are Ignore and Stop Migration.

      • If you select Ignore, when the data to be inserted conflicts with existing data of a destination table, the data transmission service logs the conflicting data while retaining the existing data.

        Important

        If you select Ignore, data is pulled in IN mode during full verification. In this case, verification is inapplicable if the destination contains data that does not exist in the source, and the verification performance is downgraded.

      • If you select Stop Migration and a destination table contains records, an error prompting migration unsupported is reported during full data migration. In this case, you must process the data in the destination table and then continue with the migration.

        Important

        If you click Resume in the dialog box prompting the error, the data transmission service ignores this error and continues to migrate data. Proceed with caution.

      Whether to Allow Post-indexing

      Specifies whether to create indexes after the full data migration is completed. Post-indexing can shorten the time required for full data migration. For more information about the considerations on post-indexing, see the description below.

      Important
      • This parameter is displayed only if both Schema Migration and Full Data Migration are selected on the Select Migration Type page.

      • Only non-unique key indexes can be created after the migration is completed.

      • If the Duplicate key name error occurs in the destination MySQL tenant of OceanBase Database during indexing, the data transmission service ignores the error and determines that the index is created, without creating an index again.

      If you select Allow, set the following parameters:

      • Single Index DDL Concurrency Configuration: the maximum number of concurrent DDL operations allowed for a single index. A larger value indicates higher resource consumption and faster data migration.

      • Maximum concurrent index DDL quantity configuration: the maximum number of post-indexing DDL operations that the system can call at a time.

      If post-indexing is allowed, we recommend that you use a CLI client to modify the following parameters for business tenants based on the hardware conditions of OceanBase Database and your current business traffic:

      // Specify the limit on the file memory buffer size.
      alter system set _temporary_file_io_area_size = '10' tenant = 'xxx'; 
      // Disable throttling in OceanBase Database V4.x.
      alter system set sys_bkgd_net_percentage = 100;  
    • Incremental synchronization

      The following table describes the parameters for incremental synchronization, which are displayed only if you have selected Incremental Synchronization on the Select Migration Type page.

      image

      Parameter

      Description

      Write Concurrency Configuration

      The concurrency for writing data to the destination during incremental synchronization. The maximum value is 512. A high write concurrency may incur excessive stress on the destination, affecting the business.

      Incremental Synchronization Rate Limit

      You can choose whether to limit the incremental synchronization rate as needed. If you choose to limit the incremental synchronization rate, you must specify the RPS and BPS. The RPS specifies the maximum number of data rows synchronized to the destination per second during incremental synchronization, and the BPS specifies the maximum amount of data in bytes synchronized to the destination per second during incremental synchronization.

      Note

      The RPS and BPS specified here are only for throttling. The actual incremental synchronization performance is subject to factors such as the settings of the source and destination and the instance specifications.

      Incremental Synchronization Start Timestamp

      • If you have set the migration type to Full Data Migration, this parameter is not displayed.

      • If you have selected Incremental Synchronization but not Full Data Migration, specify a point in time after which the data is to be synchronized. The default value is the current system time. For more information, see Set an incremental synchronization timestamp.

    • Reverse incremental migration

      The following table describes the parameters for reverse incremental migration, which are displayed only if you have selected Reverse Increment on the Select Migration Type page. By default, incremental synchronization configurations are reused for reverse incremental migration.

      image

      You can choose not to reuse the incremental synchronization configurations and configure reverse incremental migration as needed.

      Parameter

      Description

      Write Concurrency Configuration

      The concurrency for writing data to the source during reverse incremental migration. The maximum value is 512. A high concurrency may incur excessive stress on the source, thereby affecting the business.

      Reverse Increment Rate Limit

      You can choose whether to limit the reverse incremental migration rate as needed. If you choose to limit the reverse incremental migration rate, you must specify the RPS and BPS. The RPS specifies the maximum number of data rows synchronized to the source per second during reverse incremental migration, and the BPS specifies the maximum amount of data in bytes synchronized to the source per second during reverse incremental migration.

      Note

      The RPS and BPS specified here are only for throttling. The actual reverse incremental migration performance is subject to factors such as the settings of the source and destination and the instance specifications.

      Incremental Synchronization Start Timestamp

      By default, the forward switchover start timestamp (if any) prevails. This parameter cannot be modified.

    • Advanced migration configuration

      This section is displayed only if the destination is a MySQL tenant of OceanBase Database V4.3.0 or later and you have selected Schema Migration on the Select Migration Type page.

      image

      This parameter specifies the storage type for destination table objects during schema migration or incremental synchronization. The storage types supported for destination table objects are Default, Row storage, Column storage, and Hybrid columnar storage. For more information, see default_table_store_format.

      Note

      The value Default means that other parameters are automatically set based on the parameter configurations of the destination. For table objects in schema migration or new table objects in incremental DDL synchronization, the schemas are subject to the specified storage type.

  7. Click Precheck to start a precheck on the data migration task.

    During the precheck, the data transmission service checks the read and write privileges of the database users and the network connections of the databases. A data migration task can be started only after it passes all check items. If an error is returned during the precheck, you can perform the following operations:

    • Identify and troubleshoot the problem and then perform the precheck again.

    • Click Skip in the Actions column of the failed precheck item. In the dialog box that prompts the consequences of the operation, click OK.

  8. After the precheck succeeds, click Start Task.

    If you do not need to start the task now, click Save. You can start the task later on the Migration Tasks page or by performing batch operations. For more information about batch operations, see Perform batch operations on data migration tasks.

    The data transmission service allows you to modify the migration objects when a migration task is running. For more information, see View and modify migration objects and their filter conditions. After the data migration task is started, it is executed based on the selected migration types. For more information, see View migration details.

References