All Products
Search
Document Center

ApsaraDB for OceanBase:Migrate data between OceanBase databases

Last Updated:Apr 03, 2024

This topic describes how to migrate data from an OceanBase Database tenant to another OceanBase Database tenant of the same type by using the data transmission service.

Important

A data migration project remaining in an inactive state (Failed, Paused, or Completed) for a long time may not be able to be resumed due to the retention period of incremental logs. The data transmission service automatically releases data migration projects that remain in an inactive state for more than 7 days to recycle resources. We recommend that you configure alerts for projects and handle project exceptions as soon as possible.

Background

You can create a data migration project in the data transmission console to migrate the existing business data and incremental data from one tenant to another tenant of the same mode in OceanBase Database through schema migration, full migration, and incremental synchronization.

Prerequisites

  • The data transmission service has the privilege to access cloud resources. For more information, see Grant privileges to roles for data transmission.

  • You have created dedicated database users for data migration in the source and destination OceanBase databases, and granted corresponding privileges to the users. For more information, see Create a database user.

  • You have created a corresponding schema in the destination tenant of OceanBase Database.

Limitations

  • Limitations on the source database

    Do not perform DDL operations for database or schema changes during schema migration or full data migration. Otherwise, the data migration project may be interrupted.

  • The data transmission service supports data migration only between OceanBase Database tenants of the same type.

    Specifically, you can migrate data from a MySQL tenant to another MySQL tenant, or from an Oracle tenant to another Oracle tenant.

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

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

Considerations

  • If the source uses the UTF-8 character set, we recommend that you use a character set compatible with that of the source, such as UTF-8 or UTF-16, for the destination. This is to avoid issues such as garbled characters in the destination due to incompatibility of character sets.

  • 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 a destination field type is lower than the precision of the corresponding source field type, the value with a higher precision may be truncated. This may result in data inconsistency between the source and destination fields.

  • If you modify a unique index at the destination when DDL synchronization is disabled, you must restart the data migration project to avoid data inconsistency.

  • If forward switchover is disabled for a data migration project, delete the unique indexes and pseudocolumns from the destination. If you do not delete the unique indexes and pseudocolumns, data cannot be written, and pseudocolumns are generated again when data is imported to the downstream system, causing conflicts with the pseudocolumns in the source.

    If forward switchover is enabled for the data migration project, the data transmission service automatically deletes hidden columns and unique indexes based on the type of the migration project. For more information, see Mechanisms for handling hidden columns.

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

    • We recommend that you configure the mappings between the source and destination databases by importing objects or 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.

  • In a data migration project where the source is an OceanBase database and DDL synchronization is enabled, if a RENAME operation is performed on a table in the source, we recommend that you restart the project to avoid data loss during incremental synchronization.

  • Take note of the following limitations on MySQL tenants of OceanBase Database:

    • When you migrate data between MySQL tenants of OceanBase Database, by default, lower_table_case_names is set to 1 in the destination, and the destination database objects are created with names in lowercase.

    • 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, if the data type of a column in the source is not supported by the data transmission service, implicit data type conversion may occur, which causes inconsistent column types between the source and destination.

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

  • Take note of the following limitations on Oracle tenants of OceanBase Database:

    • If you skip the database ROW_MOVEMENT check for the source primary database during migration, data inconsistency may occur when you synchronize tables whose ROW_MOVEMENT value is set to enable.

Supported source and destination instance types

In the following table, OB_MySQL stands for a MySQL tenant of OceanBase Database, and OB_Oracle stands for an Oracle tenant of OceanBase Database.

Source

Destination

OB_MySQL (OceanBase cluster instance)

OB_MySQL (OceanBase cluster instance)

OB_MySQL (OceanBase cluster instance)

OB_MySQL (self-managed database in a VPC)

OB_MySQL (self-managed database in a VPC)

OB_MySQL (OceanBase cluster instance)

OB_Oracle (OceanBase cluster instance)

OB_Oracle (OceanBase cluster instance)

OB_Oracle (OceanBase cluster instance)

OB_Oracle (self-managed database in a VPC)

OB_Oracle (self-managed database in a VPC)

OB_Oracle (OceanBase cluster instance)

Procedure

  1. (Optional) To migrate a table without a primary key, create a user in the corresponding tenant.

    For more information about how to create a user, see Create a database user. To migrate a table with a primary key, skip this step.

    • When you migrate data from a MySQL tenant of OceanBase Database, create the __oceanbase_inner_drc_user user.

    • When you migrate data from an Oracle tenant of OceanBase Database, create the __OCEANBASE_INNER_DRC_USER user.

  2. Log on to the ApsaraDB for OceanBase console and purchase a data migration project.

    For more information, see Purchase a data migration project.

  3. Choose Data Transmission > Data Migration. On the page that appears, click Configure for the data migration project.

    image.png

    If you want to reference the configurations of an existing project, click Reference Configuration. For more information, see Reference and clear data migration project configurations.

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

    image.png

    Parameter

    Description

    Migration Project 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 projects.

    Source

    If you have created an OceanBase 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 the parameters, see Create an OceanBase data source.

    Destination

    If you have created an OceanBase 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.

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

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

    image.png

    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.

    Full migration

    After a full migration task is started, the data transmission service migrates existing data of tables in the source database to corresponding tables in the destination database. If you select Full Migration, we recommend that you collect the statistics of the source OceanBase database before the data migration.

    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.

    Options for Incremental Synchronization are DML Synchronization and DDL Synchronization. You can select the operations as needed. For more information about DDL synchronization, see DDL synchronization between MySQL tenants of OceanBase Database or DDL synchronization between Oracle tenants of OceanBase Database. Incremental Synchronization has the following limitations:

    • If you select DDL Synchronization, when you perform a DDL operation for synchronization that is not supported by the data transmission service in the source database, data migration may fail.

    • If the DDL operation is ADD COLUMN, we recommend that you set the column to a NULL column. Otherwise, data migration may be interrupted.

    Full verification

    After the full 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 select Full Verification, we recommend that you collect the statistics of both the source and destination OceanBase databases before full verification.

    • If you select Incremental Synchronization but do not select all DML statements in the DML Synchronization section, the data transmission service does not support full verification.

    Reverse incremental migration

    Data changes made in the destination database after the business database switchover are applied to the source database in real time.

    Note

    This feature is available for a limited-time free trial.

  6. (Optional) Click Next.

    If the source is a self-managed OceanBase data source in VPC, and you have selected Scheme Migration or Incremental Synchronization, you must provide the following information as needed: username, password, oblogproxy IP address, and oblogproxy port number. To migrate tables without unique keys from the OceanBase data source, you must specify the password of the OCEANBASE_INNER_DRC_USER user for the source.

    If no related parameters are configured for the source or destination database, the More about Data Sources dialog box appears when you create a migration project, prompting you to configure related parameters. For more information about the parameters, see Create an OceanBase data source.

  7. Click Next. On the Select Migration Objects page, specify the migration objects for the data migration project.

    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 project.

    • After you specify the migration objects by using the Specify Objects option, the DDL operations take effect only for the selected objects, and table creation is not supported.

    • 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.

      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 settings of migration objects.

      4. Click Validate.

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

      5. After the validation succeeds, click OK.

      Rename

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

      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/Remove All

      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.

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

    image.png

    Parameter

    Description

    Incremental Synchronization Start Timestamp

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

    • If you have selected Incremental Synchronization but not Full 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.

    Processing Strategy When Destination Table Has Records

    The processing strategy adopted when a destination table contains records. This parameter is displayed only when Full Migration is selected on the Select Migration Type page. Valid values: Ignore and Stop Migration.

    • If you select Ignore, when the data to be inserted conflicts with the existing data of a destination table, the data transmission service retains the existing data and records the conflict data.

      Important

      If you select Ignore, data is pulled by using the IN mode during full verification. In this case, verification is inapplicable if the destination has a large amount of data, 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 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 migration is completed. Post-indexing can shorten the time required for full 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 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 or the name is already used by an existing object error occurs in the destination Oracle 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 post-indexing is allowed, we recommend that you adjust the parameter settings based on the hardware conditions of OceanBase Database and the business traffic.

    • If you use OceanBase Database V4.x, adjust the settings of the following parameters of the sys tenant and business tenants by using a command-line interface (CLI) client.

      • Adjust the parameter settings of the sys tenant

        // parallel_servers_target specifies the queue condition for parallel queries on each server. 
        // To maximize performance, we recommend that you set this parameter to a value greater than, for example, 1.5 times, the number of physical CPU cores. In addition, make sure that the value does not exceed 64, to prevent database kernels from contending for locks. 
        set global parallel_servers_target = 64; 
      • Adjust the parameter settings of a business tenant

        // Specify the limit on the file memory buffer size.
        alter system set _temporary_file_io_area_size = '10' tenant = 'xxx'; 
        // Disable throttling in V4.x.
        alter system set sys_bkgd_net_percentage = 100;
    • If you use OceanBase Database V3.x, adjust the settings of the following parameters of the sys tenant by using a CLI client.

      // parallel_servers_target specifies the queue condition for parallel queries on each server. 
      // To maximize performance, we recommend that you set this parameter to a value greater than, for example, 1.5 times, the number of physical CPU cores. In addition, make sure that the value does not exceed 64, to prevent database kernels from contending for locks. 
      set global parallel_servers_target = 64; 
      // data_copy_concurrency specifies the maximum number of concurrent data migration and replication tasks allowed in the system. 
      alter system set data_copy_concurrency = 200;
  9. Click Precheck to start a precheck on the data migration project.

    During the precheck, the data transmission service checks the read and write privileges of the database users and the network connections of the databases. The data migration project can be started only after it passes all check items. Take note of the following items if an error is returned during the precheck:

    • You can identify and troubleshoot the error and then perform the precheck again.

    • You can also click Skip in the Actions column of the failed precheck item. A dialog box appears, prompting you for the impact. If you want to skip this operation, click OK.

  10. After the precheck is passed, click Start Project.

    If you do not need to start the project now, click Save. After that, you can only manually start the project or start it in a batch operation on the Migration Projects page. For more information about batch operations, see Perform batch operations on data migration projects.

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

References