This topic describes how to use OceanBase Migration Service (OMS) Community Edition to migrate data from a TiDB database to OceanBase Database Community Edition.
Background information
OMS Community Edition allows you to create a data migration task from a source TiDB database to a target OceanBase database. You can migrate the existing business data and incremental data from the source database to OceanBase Database by using schema migration, full migration, and incremental synchronization.
The TiDB database is a converged distributed database, which supports Hybrid Transactional and Analytical Processing (HTAP). If you use a TiDB database of a version earlier than V4.x, select Bind Kafka Data Source when you create a TiDB data source. If you use a TiDB database of V4.x or later, you can leave Bind Kafka Data Source unselected and synchronize incremental data from the TiDB database to OceanBase Community Edition by using OMS Community Edition solely.
If you select Bind Kafka Data Source when you create a TiDB data source, you also need to deploy a TiCDC cluster and a Kafka cluster to synchronize incremental data from the TiDB database to OceanBase Community Edition. If incremental synchronization is not required for the data migration task, you do not need to deploy a TiCDC cluster and a Kafka cluster.

TiCDC is a tool used to synchronize incremental data of the TiDB database. The PD cluster, which is deployed to implement high availability, is the scheduling module of the TiDB cluster and generally consists of three PD nodes. The TiKV server sends change data to the TiCDC cluster in the form of change logs. The TiCDC tool synchronizes data to the Kafka cluster after it obtains data from multiple TiCDC processes and processes the data. The Kafka cluster stores the incremental logs converted by the TiCDC tool from the TiDB database, so that OMS can obtain the corresponding data from the Kafka cluster and real-time migrate the data to OceanBase Community Edition during incremental data synchronization.
Prerequisites
You have created database users for the source TiDB database and the target OceanBase database to migrate data, and granted the required permissions to the users. For more information, see Create a database user.
Limitations
The supported TiDB versions are V2.x, V3.x, V4.x, V5.x, V6.x, V7.x, and V8.x. The supported Kafka versions are V0.9, V1.0, and V2.x.
Notice
Only TiDB Binlog is supported for TiDB V2.x and V3.x.
If the target is a database, the OMS Community Edition does not support triggers in the target database. If triggers exist in the target database, the data migration may fail.
When you migrate data from the TiDB database to OceanBase Database, DDL synchronization is not supported.
OMS Community Edition does not support migrating unindexed tables or tables containing spaces from the TiDB database to OceanBase Database.
Data source identifiers and user accounts must be globally unique in OMS.
OMS only supports migrating databases, tables, and column objects with ASCII-compliant names that do not contain special characters (|"'`()=;/& or line breaks).
OMS Community Edition only supports TiCDC Open Protocol. If you use other protocols, an exception will be thrown, and a null pointer error will occur.
Make sure that
enable-old-value=trueis added to the configuration for synchronizing data from TiCDC to Kafka. Otherwise, data synchronization messages may be in an abnormal format. For more information, see Description of the configuration file for a synchronization task.
Considerations
We recommend that you migrate no more than 1,000 tables at a time to avoid affecting the operation of the data migration task.
If the source database has foreign keys with the same names, an error will be reported during schema migration. You can modify the foreign key constraint name and then resume the task.
If there are multiple foreign keys with the same name in the source, an error is returned during schema migration. You can change the foreign key constraint names and resume the task.
If the source character set is Latin1, for more information about garbled characters, see Garbled characters in the Latin1 character set.
During reverse increment from a TiDB database to OceanBase Community Edition V3.2.x or earlier, if the source table is a multi-partition table with a global unique index and you update the values of the partitioning key, data may be lost during migration.
Do not write data to the topic synchronized by TiCDC. Otherwise, the JDBC-Connector may fail with an error indicating a null pointer exception.
Make sure that the precision of columns such as DECIMAL, FLOAT, or DOUBLE is migrated as expected. If the precision of a target column is smaller than that of the corresponding source column, data truncation may occur, which results in inconsistent data between the source and target.
If you change the unique index of the target database, you must restart the incremental synchronization component. Otherwise, data may be inconsistent.
If the clocks between nodes or between the client and the server are out of synchronization, the latency (incremental synchronization or reverse increment) may be inaccurate.
For example, if the clock is earlier than the standard time, the latency may be negative. If the clock is later than the standard time, the latency may be positive.
In multi-table aggregation scenarios:
We recommend that you configure the mappings between the source and target databases by importing objects or specifying matching rules.
We recommend that you manually create schemas in the target database. If you use OMS Community Edition to create schemas, skip failed objects in the schema migration step.
A difference between the source and target 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 OMS Community Edition, implicit data type conversion may occur, which causes inconsistent column types between the source and target databases.
If the length of a column in the target database 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 target databases.
When you use TiDB Database V2.x, V3.x, or V4.x, note the following points. For more information about TiDB Binlog, see TiDB Binlog Cluster Overview.
TiDB Binlog does not send heartbeats. If no updates are made in the source database, the data timestamp will not be updated.
If no updates are made in the source database before the start of incremental synchronization, the task will fail and return the
data not existederror.For a table without a primary key, TiDB Binlog cannot obtain the other unique keys. The system treats all fields as the primary key. When an update operation is performed on the source table, it is deleted and inserted in the target table.
Set
source.cdcDataFormat=tidbBinlogin the Incr-Sync component to use thetidbBinlogdata format.
If you select only Incremental Synchronization when you create a data migration task, make sure that the local incremental logs in the source database are retained for more than 48 hours.
If you select Full Migration + Incremental Synchronization when you create a data migration task, make sure that the local incremental logs in the source database are retained for at least seven days. Otherwise, the data migration task may fail or the data in the source and target databases may be inconsistent because the incremental logs cannot be obtained.
Data type mappings
| TiDB database | OceanBase Database Community Edition |
|---|---|
| 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 |
| DATE | DATE |
| DATETIME | DATETIME |
| TIMESTAMP | TIMESTAMP |
| TIME | TIME |
| YEAR | YEAR |
Procedure
Create a data migration task.
Log in to the OMS Community Edition console.
In the left-side navigation pane, click Data Migration.
On the Data Migration page, click Create Task in the upper-right corner.
On the Select Source and Target page, configure the parameters.
Parameter Description Migration Task Name We recommend that you use a combination of Chinese characters, numbers, and English letters. The name must be 64 characters in length or less and must not contain spaces. Tag (Optional) Click the field and select the target tag from the drop-down list. You can also click Manage Tags to create, modify, or delete a tag. For more information, see Manage data migration tasks by using tags. Source If you have created a TiDB data source, select it from the drop-down list. If not, click New Data Source in the drop-down list and create a data source in the dialog box that appears. For more information, see Create a TiDB data source.
Note:- When the TiDB data source is not bound to a valid Kafka data source and topic, incremental synchronization is not supported.
- If consumer authentication is enabled for the Kafka server, specify
properties={"group.id":"Consumer (OMS Community Edition default is oms_jdbc_connector_null)"}"in thesourceof the incremental synchronization task configuration.
Target If you have created an OceanBase Community Edition data source, select it from the drop-down list. If not, click New Data Source in the drop-down list and create a data source in the dialog box that appears. For more information, see Create an OceanBase-CE data source. Click Next.
Click Noted in the message that appears.
Please note that full migration and full verification are supported for tables without primary keys or tables with non-null unique indexes in TiDB databases, but incremental synchronization is not supported.
On the Select Migration Type page, configure the parameters.
Migration Type includes Schema Migration, Full Migration, Incremental Synchronization, Full Verification, and Reverse Increment.
Migration Type Description Schema Migration After a schema migration task is created, OMS Community Edition migrates the data object definitions (tables, indexes, constraints, comments, and views) in the source database to the target database and automatically filters temporary tables. - Manual Table Schema Adjustment Required: OMS Community Edition allows you to customize the table schema. If you select this option, OMS Community Edition only obtains the table schema SQL file during the schema migration phase. After you modify the schema, OMS Community Edition starts the migration.
- Target Table Storage Type: If the OceanBase Community Edition version of the target database is V4.3.0 or later, and you select Schema Migration, this parameter is displayed.
The target table object storage type can be Default, Row Storage, Column Storage, or Hybrid Row-Column Storage. This parameter specifies the storage type of the target table objects during schema migration or incremental synchronization. For more information, see default_table_store_format.Note
The Default option is adaptive to other options based on the target parameters. This option specifies the storage type of the table objects during schema migration.
Full Migration After a full migration task is created, OMS Community Edition migrates the existing data in the source database tables to the corresponding tables in the target database. If you select Full Migration, we recommend that you run the ANALYZEstatement to collect statistics on the TiDB database before you migrate data.Incremental Synchronization After an incremental synchronization task is created, OMS Community Edition synchronizes the data that changes in the source database (new data, modified data, and deleted data) to the corresponding tables in the target database.
Incremental Synchronization specifies DML Synchronization operations, which includeInsert,Delete, andUpdate. You can select the required DML operation. For more information, see DML filtering.
If you use a version earlier than V4.x of TiDB, you cannot select Incremental Synchronization if you do not bind a Kafka data source when you create the TiDB data source.Full Verification After full migration is completed and incremental data is synchronized to the target database and is approximately synchronized with the source database, OMS Community Edition automatically initiates a full data verification task to verify the data tables in the source database and the target database. - If you select Full Verification, we recommend that you collect statistics on the TiDB database and OceanBase Community Edition before the full verification task is created. For more information, see Manually collect statistics.
- If you select Incremental Synchronization and do not select all DML operations in DML Synchronization, OMS Community Edition does not support full data verification in this scenario.
Reverse Increment After a reverse increment task is created, OMS Community Edition can synchronize the changes that occur in the target database after business switching to the source database. OMS Community Edition does not support the Reverse Increment option in the following scenarios: - Multi-table aggregation is involved.
- Mutiple source schemas is mapped to one target schema.
(Optional) Click Next. If you select Reverse Increment and the OceanBase Community Edition data source of the target database is not configured with Configurl, the username, and the password of the DRC user, the More about Data Sources dialog box appears, prompting you to configure the parameters. For more information, see Create an OceanBase-CE data source.
After you configure the parameters, click Test connectivity. If the test succeeds, click Save.
Click Next. On the Select Migration Objects page, select the migration object and the migration scope.
You can select the migration object in two ways: Specify Objects and Match Rules. This topic describes how to select the migration object in the Specify Objects mode. For more information about how to configure matching rules, see Configure matching rules for migration objects.
Note
The name of a table to be migrated and the names of columns in the table must not contain Chinese characters.
If the name of a database or a table contains the double dollar sign ($$), the data migration task cannot be created.
In the Select Migration Objects section, select Specify Objects.
In the Specify Migration Scope section, select the migration object in the Source Object(s) list. You can select one or more tables or views in one or more databases as the migration object.
Click > to add the migration object to the Target Object(s) list.
OMS Community Edition allows you to import objects, rename objects, set row filters, view column information, and remove objects.
Operation Procedure Import objects - In the Specify Migration Scope section, click Import Objects in the upper-right corner of the right-side list.
- In the dialog box that appears, click OK.
Note:
Importing objects will overwrite the previous operation selection. Proceed with caution. - In the Import Migration Object dialog box, import the migration object.
You can rename a database or a table by importing a CSV file. For more information, see Download and import the migration object configuration. - Click Validate.
- After the object is verified, click OK.
Rename objects OMS Community Edition allows you to rename the migration object. For more information, see Rename a database or a table. Set filters OMS Community Edition allows you to set WHEREconditions to filter rows. For more information, see Filter data by using SQL conditions.
You can also view column information of the migration object in the View Column section.Remove/Remove All OMS Community Edition allows you to remove one or more objects temporarily selected for the target database during data mapping. - Remove a single migration object
In the right-side list of the Specify Migration Scope section, hover over the target object and click Remove to remove the migration object. - Remove all migration objects
In the right-side list of the Specify Migration Scope section, click Remove All in the upper-right corner. In the dialog box that appears, click OK to remove all migration objects.
Click Next. On the Migration Type page, configure the parameters.
To view or modify parameters of the Full-Import or Full-Verification component, click Configuration Details in the upper-right corner of the Full Migration or Full Verification section. To view or modify parameters of the Incr-Sync or reverse increment component, click Store Configuration Details or Configuration Details of incr Increment in the upper-right corner of the Incremental Synchronization or Reverse Increment section. For more information about the parameters, see Component parameters.
Full migration
The following parameters are displayed only if you select Full Migration on the Select Migration Type page.
Parameter Description Concurrency The concurrency mode can be Stable, Normal, Fast, or Custom. The performance of full migration varies depending on the concurrency mode. The resources required for full migration tasks vary depending on the concurrency mode. If you select Custom, you can set Read Concurrency, Write Concurrency, and JVM Memory as needed. Target Object Existence Handling Strategy The handling strategy can be Ignore or Stop Migration: - If you select Ignore, when the target table object contains data, OMS Community Edition writes data to the target table object, and records the conflicting data in the log file.
Notice
If you select Ignore, full verification uses the IN mode to pull data, and cannot verify the data that exists in the target but does not exist in the source. The verification performance will be degraded to a certain extent.
- If you select Stop Migration, when the target table object contains data, full migration will report an error indicating that the migration is not allowed. Please handle the data in the target database and then continue the migration.
Notice
If you click Restore after the error occurs, OMS Community Edition will ignore this configuration option and continue to migrate the table data. Proceed with caution.
Write Mode The write mode can be SQL (data is written to the table by using the INSERTorREPLACEstatement) or Direct Load (data is written to the table by using direct load). For more information about direct load, see Overview of direct load.Allow Index Postponement You can set whether to create indexes after full data migration. Index postponement shortens the full migration time. If you select index postponement, note the following items. Notice
To enable this option, you must select both Schema Migration and Full Migration on the Select Migration Type page.
If you enable index postponement, we recommend that you adjust the parameters based on the hardware conditions and current business traffic of OceanBase Community Edition.
If you use OceanBase Community Edition V4.x, you can adjust the following sys tenant parameters and business tenant parameters by using the CLI tool.
Adjust the sys tenant parameters
// parallel_servers_target specifies the number of parallel queries per server. // If you want to ensure performance, we recommend that you set this parameter to a value greater than the number of physical CPU cores, for example, 1.5 times the number of physical CPU cores. We recommend that you do not set this parameter to a value greater than 64 to avoid the kernel lock contention issue in OceanBase Community Edition. set global parallel_servers_target = 64;Adjust the business tenant parameters
// The maximum size of the temporary file I/O area. alter system set _temporary_file_io_area_size = '10' tenant = 'xxx'; // 4.x disables throttling. alter system set sys_bkgd_net_percentage = 100;
If you use OceanBase Community Edition V3.x, you can adjust the following sys tenant parameters by using the CLI tool.
// parallel_servers_target specifies the number of parallel queries per server. // If you want to ensure performance, we recommend that you set this parameter to a value greater than the number of physical CPU cores, for example, 1.5 times the number of physical CPU cores. We recommend that you do not set this parameter to a value greater than 64 to avoid the kernel lock contention issue in OceanBase Community Edition. set global parallel_servers_target = 64; // data_copy_concurrency specifies the maximum number of concurrent data migration and replication tasks. alter system set data_copy_concurrency = 200;
- If you select Ignore, when the target table object contains data, OMS Community Edition writes data to the target table object, and records the conflicting data in the log file.
Incremental synchronization
The following parameters are displayed only if you select Incremental Synchronization on the Select Migration Type page.
Parameter Description Concurrency The concurrency mode can be Stable, Normal, Fast, or Custom. The performance of incremental synchronization varies depending on the concurrency mode. The resources required for incremental synchronization tasks vary depending on the concurrency mode. If you select Custom, you can set Read Concurrency, Write Concurrency, and JVM Memory as needed. Incremental Record Retention Period If you do not select Bind Kafka Data Source when you create the TiDB data source, this parameter is displayed. It specifies the period for which OMS Community Edition stores incremental parse files in the cache. The longer the retention period, the more disk space the OMS Community Edition Store component consumes. Incremental Synchronization Start Timestamp - If you select Full Migration when you select the migration type, this parameter is not displayed.
- If you do not select Bind Kafka Data Source when you create the TiDB data source and you do not select Full Migration but you select Incremental Synchronization, specify the data after a specific point in time in this field. The default value is the current system time. For more information, see Set the incremental synchronization timestamp.
Kafka Consumer group.id (Optional) This parameter is displayed if you select Bind Kafka Data Source when you create the TiDB data source. group.idis the unique identifier of the consumer group in Kafka.Full verification
The following parameters are displayed only if you select Full Verification on the Select Migration Type page.
Parameter Description Concurrency The concurrency mode can be Stable, Normal, Fast, or Custom. The resources consumed during full verification can be limited by configuring the resource allocation for the Full-Verification component. If you select Custom, you can set Read Concurrency, Write Concurrency, and JVM Memory as needed. Reverse increment
On the Select Migration Type page, select Reverse Increment to display the following parameters.
Parameter Description Concurrency Speed Valid values: Stable, Normal, Fast, and Custom. The performance of incremental synchronization varies, and the resources required for incremental synchronization tasks also vary. If you select Custom, you can set Read Concurrency, Write Concurrency, and JVM Memory as needed. Incremental Synchronization Start Timestamp - This parameter is displayed only when you select Reverse Increment as the migration type. Specify the data to be migrated after a certain point in time. The default value is the current system time. For more information, see Set the Incremental Synchronization Start Point.
Incremental Record Retention Time The duration for which incremental parsing files are cached in OMS Community Edition. The longer the retention time, the more disk space the OMS Community Edition Store component consumes.
Click Precheck to perform a precheck on the data migration task.
In the Precheck section, OMS Community Edition checks whether the database user has the read and write permissions and whether the database is connected to the network. You can start the data migration task only after all the precheck tasks are passed. If the precheck fails:
You can troubleshoot and resolve the issue and then perform the precheck again until the precheck succeeds.
You can click Skip in the operation column of the error precheck item. A dialog box appears, prompting you to skip the operation and confirming whether you want to proceed. If you confirm, click OK in the dialog box.
Click Start Task. If you do not need to start the task, click Save to go to the details page of the data migration task. You can manually start the task as needed.
OMS Community Edition allows you to modify the migration object during a data migration task. For more information, see View and modify the migration object. After the data migration task is started, it will be executed based on the selected migration type. For more information, see the "View details of a data migration task" section in View details of a data migration task.