This topic describes how to use the data transmission service to migrate data from a MySQL database to a MySQL tenant of OceanBase Database.
Suppose a data migration project remains inactive for an extended period (project status is Failed, Paused, or Completed). In that case, it may not be recoverable due to factors such as incremental log retention duration. To reclaim resources, data transmission will automatically release data migration projects that have been inactive for more than 7 days. We recommend configuring alerts for the project and addressing any related exceptions in a timely manner.
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 MySQL database and the destination MySQL tenant of OceanBase Database and granted required privileges to the users. For more information, see Create a database user.
Binlogs have been enabled. For more information about binlogs in an ApsaraDB RDS for MySQL instance, see Manage binary log files. For more information about binlogs in a PolarDB for MySQL instance, see Enable binary logging.
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 project may be interrupted.
The data transmission service supports MySQL 5.5, 5.6, 5.7, and 8.0.
The data transmission service supports only the MySQL InnoDB storage engine and is unavailable for other engines.
NoteIt supports the InnoDB and X-Engine storage engines for RDS for MySQL instances.
The data transmission service does not support an index field greater than 767 bytes (or 191 characters) in length in MySQL databases.
The data transmission service does not support CASCADE foreign key migration for the source MySQL database.
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 precheck fails if the primary key is of the FLOAT or DOUBLE data type. We recommend that you do not specify a column of such a data type as the primary key.
The data transmission service does not support triggers in the destination database. If triggers exist in the destination database, the data migration may fail.
The clock of the source database must be synchronized with that of the destination database.
The RDS for MySQL database and the VPC in which the self-managed database is located must be in the same region as the OceanBase database.
Considerations
The host of the MySQL database must have sufficient outbound bandwidth. Insufficient outbound bandwidth on the host will slow down log parsing and data migration, which may increase the latency of data synchronization.
Take note of the following considerations if the source and destination databases use different collations:
The data in the destination database may be inconsistent with that in the source database after data synchronization. For example, if the collation for the source database is utf8mb4_0900_ai_ci and that for the destination database is utf8mb4_general_ci, two data records
A
andA
cannot be both written to the destination database, causing data loss.Data inconsistency will be detected during verification for a table that uses a column of the VARCHAR type as the primary key.
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.
If incremental parsing is required for the MySQL database, you must specify the ID of the MySQL server.
If you modify a unique index in the destination when DDL synchronization is disabled, you must restart the data migration project to avoid data inconsistency.
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 the source instance is a read-only RDS for MySQL database, the precheck displays a prompt, which indicates the risk of incremental log consumption.
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 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.
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 in the destination, if the data type of any column is not supported by the data transmission service, implicit data type conversion may occur in 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 at the source database, the data of this column may be automatically truncated, which causes data inconsistency between the source and destination databases.
If you have selected only Incremental Synchronization when you created the data migration project, the data transmission service requires that the local incremental logs of the source database be retained for more than 48 hours.
If you have selected Full Migration and Incremental Synchronization when you created the data migration project, the data transmission service requires that the local incremental logs of the source database be retained for at least 7 days. If the data transmission service cannot obtain incremental logs, the data migration project may fail or even the data between the source and destination databases may be inconsistent after migration.
Supported source and destination instance types
In the following table, OB_MySQL stands for a MySQL tenant of OceanBase Database, which can be an OceanBase cluster instance or an OceanBase Database tenant instance.
Source | Destination |
MySQL (ApsaraDB RDS instance) | OB_MySQL |
MySQL (PolarDB instance) | OB_MySQL |
MySQL (self-managed database in a VPC) | OB_MySQL |
MySQL (database gateway) | OB_MySQL |
MySQL (self-managed database with a public IP address) | OB_MySQL |
Data type mappings
MySQL 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
Log on to the ApsaraDB for OceanBase console and purchase a data migration project.
For more information, see Purchase a data migration project.
Choose Data Transmission > Data Migration. On the page that appears, click Configuration for the data migration project.
If you want to reference the configurations of an existing project, click Reference Configuration. For more information, see Reference and clear the configuration of a data migration project.
On the Select Source and Destination page, configure the parameters.
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 a MySQL data source, select it from the drop-down list. If not, click New Data Source in the drop-down list to create one in the dialog box on the right side. For more information about the parameters, see Create a MySQL 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 to create one in the dialog box on the right side. For more information about the parameters, see Create an OceanBase data source.
ImportantIf the destination is a MySQL tenant of OceanBase Database, Instance Type cannot be set to Self-Managed Database in VPC.
Scenario type
Valid values: Tables with Unique Key and All Tables.
A table with a unique key is one that has a primary key or a non-null unique key. If you select Tables with Unique Key, the data transmission service automatically filters out tables without unique keys.
If you select All Tables, tables with a primary key or a unique key and those without a unique key, except for temporary tables, are included. The data transmission service supports full verification only for tables with a primary key or non-null unique key.
Click Next.
If you have selected Tables with Unique Key for Scenario, click OK in the dialog box that appears.
On the Select Migration Type page, specify migration types for the current data migration project.
Options for Migration Type are Schema Migration, Full Data Migration, Incremental Synchronization, Full Verification, and Reverse Increment.
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.
In a project that migrates schemas from a MySQL database to a MySQL tenant of OceanBase Database, the database that does not exist in the destination can be automatically created.
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 Data Migration, we recommend that you use the
ANALYZE
statement to collect the statistics of the MySQL database before 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 operations as needed. For more information, see Configure DDL/DML synchronization. Incremental Synchronization has the following limitations:
If you select DDL Synchronization, when you perform a DDL operation that is not supported by the data transmission service in the source database, the data migration may be interrupted.
If the DDL operation is ADD COLUMN, we recommend that you set the column to a NULL column. Otherwise, the 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 the MySQL database and the MySQL tenant of OceanBase Database before full verification.
If you have selected Incremental Synchronization but did not select all DML operations in the DML Synchronization section, you cannot select Full Verification.
The data transmission service supports full verification only for tables with a primary key or non-null unique key.
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.
Click Next. On the Select Migration Objects page, specify the migration objects for the migration project.
You can select Specify Objects or Match Rules to specify the migration objects.
ImportantThe 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 select migration objects by using the Specify Objects option, the DDL operations take effect only for 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.
NoteWhen 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.
Operation
Description
Import objects
In the list on the right, click Import Objects in the upper-right corner.
In the dialog box that appears, click OK.
ImportantThis operation will overwrite previous selections. Proceed with caution.
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.
Click Validate.
After you import the migration objects, check their validity. Column field mapping is not supported at present.
After the validation succeeds, click OK.
Rename an object
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.
Click Next.
If you select All Tables for Scenario, click Next in the dialog box that appears.
On the Migration Options page, configure the parameters.
Full migration
The following table describes the parameters for full migration, which are displayed only if you have selected Full Data Migration on the Select Migration Type page.
Parameter
Description
Read Concurrency Configuration
The concurrency for reading data from the source during full 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 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 migration rate as needed. If you choose to limit the full 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 migration, and the BPS specifies the maximum amount of data in bytes migrated to the destination per second during full migration.
NoteThe RPS and BPS values specified here are only for throttling. The actual full 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: 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.
ImportantIf 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 migration. In this case, you must process the data in the destination table and then continue with the migration.
ImportantIf 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.
ImportantThis 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 post-indexing is allowed, we recommend that you adjust the parameters based on the hardware conditions of your OceanBase database and the current business traffic.
If you use OceanBase Database V4.x, adjust the following parameters of the sys tenant and business tenants by using a CLI client.
Modify the parameters 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;
Modify the parameters of a user tenant
// 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;
If you use OceanBase Database V3.x, modify 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;
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.
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.
NoteThe RPS and BPS values 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.
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.
Incremental Synchronization Rate Limit
You can choose whether to limit the incremental synchronization 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.
NoteThe RPS and BPS values 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 or Incremental Synchronization > DDL Synchronization on the Select Migration Type page.
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.
NoteThe 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.
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. 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.
After the precheck succeeds, 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.