This topic describes how to use OceanBase Migration Service (OMS) to migrate data from a MySQL database to the MySQL-compatible mode of OceanBase Database (including physical data sources, public cloud data sources, and standalone data sources).
Background information
You can create a data migration task in the OMS console to seamlessly migrate existing business data and incremental data from a self-managed MySQL database to the MySQL-compatible mode of OceanBase Database through schema migration, full migration, and incremental synchronization.
MySQL databases support single-primary, single-standby, and primary-standby modes. When migrating data from a MySQL database to the MySQL-compatible mode of OceanBase Database, the operations supported by different types of data sources also vary.
Type |
Supported operations |
|---|---|
| Single Primary Database | Schema migration + Full data migration + Incremental synchronization + Reverse incremental migration |
| Primary/Standby Database | Schema migration + Full data migration |
| Primary/Standby Database | Primary database: Supports incremental synchronization and reverse incremental synchronization. Standby database: Supports schema migration and full migration. |
Prerequisites
Binlog has been enabled for the self-managed MySQL database. For more information, see Enable Binlog for a MySQL database.
A dedicated database user for the data migration task has been created for both the source self-managed MySQL database and the target OceanBase Database in MySQL-compatible mode, and the relevant privileges have been granted. For more information, see Create a database user.
Limitations
Limitations on the source database
Do not perform DDL operations that modify database or table schemas during schema migration or full migration. Otherwise, the data migration task may be interrupted.
Currently, MySQL Database versions V5.5, V5.6, V5.7, and V8.0 are supported. Additionally, OMS only supports the MySQL InnoDB storage engine; other types of engines cannot use the data migration feature.
If the primary key is of the FLOAT or DOUBLE type, the precheck will fail. It is strongly recommended that you do not use these types as primary keys.
OMS does not support triggers (Trigger) at the target. If triggers exist, data migration may fail.
OMS does not support index fields in MySQL databases that exceed 16,000 bytes (4,000 characters).
Data source identifiers and user accounts must be globally unique within the OMS system.
OMS only supports migrating objects whose database, table, and column names are ASCII-compliant and do not contain special characters (including line breaks, spaces, and
.|"'`()=;/&\).OceanBase Database MySQL-compatible mode V3.2.0 does not support using both
changeandmodify columnin the same statement.OMS does not support migrating cascade foreign keys from the source MySQL database.
Ensure the clocks of the source and target databases are synchronized.
Considerations
The host of the MySQL database must have sufficient outbound bandwidth. Insufficient outbound bandwidth affects log parsing and data migration speed, potentially increasing synchronization latency.
If the collations of the source and target databases are different:
Data synchronization may become inconsistent. For example, two data entries 'A' and 'A ' under the source utf8mb4_0900_ai_ci collation may not all be written to the target database with the utf8mb4_general_ci collation, leading to data loss.
Data verification for tables with VARCHAR as the primary key will be inconsistent.
Clock desynchronization between nodes, or between the client terminal and the server, can cause inaccurate latency measurements during incremental synchronization or reverse incremental synchronization.
For example, if a clock is ahead of standard time, the latency may be negative. If a clock is behind standard time, it may cause latency.
During reverse incremental migration from a MySQL database to the MySQL-compatible mode of OceanBase Database, if OceanBase Database in MySQL-compatible mode is a version earlier than V3.2.x and involves a multi-partitioned table with a global unique index, updating the value of the partitioning key for the table may result in data loss during migration.
If incremental parsing is required for a MySQL database, the
server_idmust be set on the source MySQL server.If you modify a unique index on the target side without enabling DDL synchronization, you need to restart the incremental synchronization component; otherwise, data inconsistency may occur.
Please verify whether the migration precision of column types such as DECIMAL, FLOAT, and DOUBLE by OMS meets your expectations. If the precision of the target field type is lower than that of the source field type, truncation may occur, leading to data inconsistency between the source and target.
In database/table consolidation scenarios:
It is recommended that you use matching rules to map the relationship between the source and target.
It is recommended that you manually create the table structure on the target side. If you use OMS to create it, skip failed objects in the schema migration step.
If the table structures at the source and target are not identical, data inconsistency may occur. Known scenarios include:
When manually creating a table structure, implicit conversion issues may arise due to exceeding OMS's support scope, leading to inconsistent column types between the source and target.
If the data length on the target side is shorter than on the source side, data truncation may occur, causing inconsistency between the source and target data.
If you configure only Incremental Synchronization when creating a data migration task, OMS requires that archive logs in the source database be retained for more than 48 hours.
If you configure both Full Migration and Incremental Synchronization when creating the task, OMS requires that archive logs in the source database be retained for at least 7 days. Otherwise, the migration task may fail or cause data inconsistency between the source and target due to inability to obtain incremental logs.
For MySQL databases with dual-primary or multi-primary architectures, enable the
log_slave_updatesparameter; otherwise, there is a risk of data loss if the data source does not receive all Binlogs.If table objects differing only in case exist at the source or target, the migration result may not meet expectations due to case-insensitivity at the source or target.
Current data migration tasks support tables with non-null unique keys. However, task restarts or other exceptions may lead to data duplication. It is recommended to configure a non-null unique key for all tables.
If you perform incremental synchronization with OceanBase Database as the source, or reverse incremental migration with OceanBase Database as the target, and the database table objects contain UDT columns, the incremental synchronization task may fail due to unsupported UDT columns.
Data type mappings
MySQL database |
MySQL-compatible mode 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
NoticeThis data type is supported in OceanBase Database in MySQL-compatible mode V2.2.0 and later. |
| SET | SET
NoticeThis data type is supported in OceanBase Database MySQL mode V2.2.0 and later. |
| JSON | JSON
NoticeThis data type is supported in OceanBase Database MySQL mode V3.2.2 and later. |
| DATE | DATE |
| DATETIME | DATETIME |
| TIMESTAMP | TIMESTAMP |
| TIME | TIME |
| YEAR | YEAR |
| GEOMETRY | GEOMETRY
NoticeThis data type is supported in OceanBase Database in MySQL-compatible mode V3.2.4 and later. |
| POINT | POINT
NoticeThis data type is supported in OceanBase Database MySQL mode V3.2.4 and later. |
| LINESTRING | LINESTRING
NoticeThis data type is supported in OceanBase Database in MySQL-compatible mode V3.2.4 and later. |
| POLYGON | POLYGON
NoticeThis data type is supported in OceanBase Database MySQL mode V3.2.4 and later. |
| MULTIPOINT | MULTIPOINT
NoticeThis data type is supported in OceanBase Database in MySQL-compatible mode V3.2.4 and later. |
| MULTILINESTRING | MULTILINESTRING
NoticeThis data type is supported in OceanBase Database in MySQL-compatible mode V3.2.4 and later. |
| MULTIPOLYGON | MULTIPOLYGON
NoticeThis data type is supported in OceanBase Database in MySQL mode starting from V3.2.4. |
| GEOMETRYCOLLECTION | GEOMETRYCOLLECTION
NoticeThis data type is supported in OceanBase Database in MySQL mode V3.2.4 and later. |
Procedure
Create a data migration task.
Log in to the OMS 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 Create Task page, customize the name of the migration task.
We recommend that you use a combination of Chinese characters, numbers, and letters. The name must not contain spaces and must not exceed 64 characters in length.
Notice
The task name is a unique identifier within the OMS system. Please choose an appropriate name.
In the Select Source and Target step, configure the parameters.
ParameterDescriptionSource 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. For details, see Create a MySQL data source.
Note:- If you selected Allow OMS to automatically write heartbeat data to this instance during incremental synchronization to resolve high latency issues at the source when no business data is being written when adding the MySQL data source, OMS will create and update the
drc.heartbeattable for the corresponding MySQL database. The MySQL database user must have the privileges to create and write to the table. For details, see Create and update the heartbeat table. You can select a MySQL data source of the primary database only or primary database + standby database type. This topic uses the primary database + standby database type as an example.
Destination If you have created an OceanBase Database data source in MySQL-compatible mode (including physical data sources, public cloud data sources, and standalone data sources), 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. For details, see Create a physical OceanBase data source, Create a public cloud OceanBase data source, or Create a standalone OceanBase data source. Tag (Optional) Click the text box and select a target tag from the drop-down list. You can also click Manage Tags to create, modify, or delete tags. For details, see Manage data migration tasks by using tags. - If you selected Allow OMS to automatically write heartbeat data to this instance during incremental synchronization to resolve high latency issues at the source when no business data is being written when adding the MySQL data source, OMS will create and update the
Click Next. In the Select Migration Type step, select One-way Synchronization for Synchronization Topology.
OMS supports One-way Synchronization and Bidirectional Synchronization. This topic describes how to perform one-way synchronization. For more information about two-way synchronization, see Configure a two-way synchronization task.
In the Migration Options section, select the migration type for the current data migration task.
Migration Type includes Schema Migration, Full Migration, Incremental Synchronization, and Reverse Increment.
Migration typeLimitationsSchema migration After a schema migration task starts, OMS migrates data object definitions (such as tables, indexes, constraints, comments, and views) from the source database to the target database and automatically filters out temporary tables. Schema migration from a MySQL database to an OceanBase Database in MySQL-compatible mode supports automatically creating databases that do not exist at the target. Full migration After a full migration task starts, OMS migrates the existing data of tables from the source database to the corresponding tables in the target database. If you select Full Migration, we recommend that you collect statistics from the MySQL database using the ANALYZEstatement before migrating data.Incremental synchronization After an incremental synchronization task starts, OMS synchronizes changed data (inserts, modifications, or deletions) from the source database to the corresponding tables in the target database.
Incremental Synchronization includes DML synchronization and DDL synchronization. You can configure them according to your needs. For details, see Configure DDL/DML synchronization. The limitations for Incremental Synchronization are as follows:- If you select Incremental Synchronization, the source MySQL database must have Binlog enabled with
binlog_row_imageset to full andbinlog_formatset to row. - If you select Incremental Synchronization, the retention period for MySQL Binlog logs must be at least 24 hours. Otherwise, the incremental data migration may be interrupted and cannot be resumed due to missing Binlog logs.
- If you select DDL synchronization, there is a risk of data migration interruption when the source database performs a DDL operation that OMS does not support.
- If the DDL operation is to add a column, it is recommended to set the column's attribute to Null, as there is still a risk of data migration interruption.
Reverse incremental After a reverse incremental task starts, it can continuously flow back the changed data generated in the target database after the business switchover to the source database in real time.
Typically, reverse incremental reuses the configuration of incremental synchronization, but you can also customize it based on actual requirements. The following situations do not support selecting Reverse Increment:- Multiple table aggregation is present.
- More than one-to-one schema mapping exists.
- If you select Incremental Synchronization, the source MySQL database must have Binlog enabled with
(Optional) Click Next.
If you selected Reverse Increment but the corresponding parameters were not configured for the target OceanBase Database in MySQL-compatible mode data source, the Add Data Source Information dialog box will pop up, reminding you to configure the parameters. For parameter details, see Create an OceanBase physical data source, Create an OceanBase public cloud data source, or Create an OceanBase standalone data source.
After completing the supplementary information, click Test connectivity. After the connection test succeeds, click Save.
Click Next. In the Select Migration Objects step, select the objects that need to be migrated for the current data migration task.
You can select migration objects through two options: Specify Objects and Match by Rule. This topic describes how to select migration objects by specifying objects. For details on configuring matching rules, see Configure matching rules.
Note
When selecting migration objects by specifying objects, do not select tables named "*_ghc".
When selecting migration objects by matching rules, be sure to configure the Exclude Objects Rule to
{database_name}.*_ghc.If the database name or table name contains the "$$" character, it will affect the creation of the data migration task.
If you have checked DDL Synchronization in the Select Migration Type step, it is recommended to select migration objects by matching rules to ensure all newly added objects that meet the migration object rules are synchronized. If you select objects by specifying objects, newly added objects or renamed objects will not be synchronized.
OMS automatically filters out unsupported objects. For the SQL statement to query objects, see Query database objects.
In the Select Migration Objects step, select Specify Objects.
In the Source Object(s) list, select the objects to be migrated. You can choose tables or views from one or more databases as migration objects.
Click > to add them to the Target Object list.
OMS supports importing objects via text and allows operations such as renaming target objects, setting row filters, selecting partitions and columns, and removing individual or all migration objects.
Note
When selecting migration objects by using the Matching Rules method, the renaming capability is overridden by the matching rule syntax, and only filtering conditions can be set at the operation field. For details, see Configure matching rules.
OperationStepImport objects - In the Target Objects list, click Import Objects in the upper-right corner.
- In the dialog box, click OK.
Note:
The import will overwrite previous operation selections. Proceed with caution. - In the Import Migration Objects dialog box, import the objects to be migrated.
You can rename databases and tables, set row filter conditions, and perform other operations by importing a CSV file. For more information, see Download and import migration object configurations. - Click Validate.
- After passing the legality validation, click OK.
Rename OMS supports renaming migration objects. For more information, see Rename a database or table. Settings OMS supports configuring row filtering, partition selection, and columns to migrate. - In the right-side list of the selection area, hover the mouse over the target object.
- Click the displayed Settings.
- In the Settings dialog box, you can perform the following operations.
-
In the text box of the Row Filters section, enter a WHERE clause from a standard SQL statement to configure row filtering. For more information, see Filter data with SQL conditions.
- In the drop-down list of the Partition section, select the specified partition data you need to retrieve during the full migration phase. After making the selection, click OK.
- In the Select Columns section, select the columns to migrate. For more information, see Column filtering.
Remove/Remove All OMS supports removing one or more temporarily selected objects to the target during data mapping. - Remove a single migration object
In the Target Objects list, hover the mouse over the target object and click the displayed Remove to remove that migration object. - Remove all migration objects
In the Target Objects list, click Remove All in the upper-right corner. In the dialog box, click OK to remove all migration objects.
Change Database OMS supports changing the target database for tables during data migration. Select the objects whose database needs to be changed in the selected area, click Change Database below, enter the target database name in the pop-up window, and click OK. After configuration, you can view the actual migration effect in the selected area. Click Next. In the Migration Options step, configure the parameters.
Schema migration
The following parameters are displayed only if you have selected One-way Synchronization > Schema Migration in the Select Migration Type step.
ParameterDescriptionAutomatically proceed to the next stage upon completion When you select schema migration along with any other migration type, you can configure whether to automatically proceed to the next stage after schema migration is complete. The default value is Yes. You can also view and modify this setting on the Schema Migration tab of the data migration task details page. Regular index migration method Refers to the migration method for non-unique key indexes associated with table objects after migration. Valid values: Do Not Migrate, Migrate with Schema, and Post-Full-Migration (This option is displayed only when Full Migration is selected). Full migration
The following parameters are displayed only if you have selected One-way Synchronization > Full Migration in the Select Migration Type step.
ParameterDescriptionFull Migration Rate Limit You can decide whether to enable the full migration rate limit based on your actual needs. If enabled, set the RPS (the maximum number of data rows that can be migrated to the target per second during the full migration phase) and BPS (the maximum amount of data that can be migrated to the target per second during the full migration phase). Note
The RPS and BPS set here are only for throttling. The actual achievable performance during full migration is limited by factors such as the source, target, and instance specifications.
Full Migration Resource Configuration You can select the default read concurrency, write concurrency, and memory for Small, Medium, or Large. You can also customize the resource configuration for full migration. By configuring resources for the Full-Import component, you can limit the resource consumption of a task during the full migration phase. Notice
For custom configurations, the minimum value is 1, and only integers are supported.
Handling Strategy When Target Table Has Records The handling strategies include Ignore and Stop Migration: - If Ignore is selected, when data exists in the target table and conflicts with the data to be written, OMS logs the conflicting data and retains the original data unchanged.
- If Stop Migration is selected, an error is reported during full migration if the target table contains data, indicating that migration is not allowed. In this case, you must handle the data in the target table before continuing the migration.
Notice
If you click Resume after an error occurs, OMS will ignore this configuration option and continue migrating table data. Proceed with caution.
</ ul>
Incremental Synchronization
The following parameters are displayed only if you have selected One-way Synchronization > Incremental Synchronization in the Select Migration Type step.
ParameterDescriptionIncremental Synchronization Rate Limit You can decide whether to enable the incremental synchronization rate limit based on your actual needs. If enabled, set the RPS (the maximum number of data rows that can be synchronized to the target per second during incremental synchronization) and BPS (the maximum amount of data that can be synchronized to the target per second during incremental synchronization). Note
The RPS and BPS set here are only for throttling. The actual achievable performance during incremental synchronization is limited by factors such as the source, target, and instance specifications.
Incremental Log Pull Resource Configuration You can select the default memory for Small, Medium, or Large. You can also customize the resource configuration for incremental log pull. By configuring resources for the Store component, you can limit the resource consumption for log pulling during the incremental synchronization phase. Notice
For custom configurations, the minimum value is 1, and only integers are supported.
Incremental Data Write Resource Configuration You can select the default write concurrency and memory for Small, Medium, or Large. You can also customize the resource configuration for incremental data write. By configuring resources for the Incr-Sync component, you can limit the resource consumption for data writing during the incremental synchronization phase. Notice
For custom configurations, the minimum value is 1, and only integers are supported.
Incremental Record Retention Time The duration for which incremental parsed files are cached in OMS. A longer configured retention time requires more disk space for the Store component. Incremental Synchronization Start Timestamp - If Full Migration was selected as the migration type, this parameter is not displayed.
- If Full Migration was not selected but Incremental Synchronization was selected, specify a point in time after which data should be migrated. The default is the current system time. For details, see Set an incremental synchronization timestamp.
Adapt to Online DDL Tools After enabling this feature, when the database uses an Online DDL tool to perform lock-free schema changes, data migration will filter out temporary table objects, improving the stability of the data migration task. For details, see Introduction to Online DDL tools.</main id="notice" type='explain'> Note
Currently, adapting to Online DDL tools is only supported when the source is a MySQL database and Alibaba Cloud DMS, gh-ost, or pt-osc is used for lock-free schema change operations.
Reverse Incremental
The parameters in this section are displayed only if you have selected One-way Synchronization > Reverse Increment in the Select Migration Type step. The configuration parameters for reverse incremental are the same as those for incremental synchronization. You can select Reuse Incremental Synchronization Configuration in the upper-right corner.
Advanced Options
When the target OceanBase Database MySQL-compatible mode is V4.3.0 or later, and Select Migration Type > One-way Synchronization > Schema Migration or Incremental Synchronization > DDL synchronization is selected, the parameters in this section are displayed.
The storage types for table objects at the target include Default, Row Storage, Column Storage, and Hybrid Row-Column Storage. This configuration determines the storage type for table objects during schema migration or incremental synchronization. For more information, see default_table_store_format.
Note
The Default option adapts to other options based on the target parameters. It writes the corresponding structure for table objects during schema migration or newly added table objects during incremental DDL according to the set storage type.
The following parameters are displayed only if you did not select One-way Synchronization > Schema Migration or One-way Synchronization > Reverse Increment in the Select Migration Type step.
Synchronize Data is disabled by default. After enabling it, you can write specified data (such as source schemas or values of other custom fields) to specified fields in the target.
ParameterDescriptionSynchronize Database Name If you choose to synchronize the database name, specify the field name and ensure all tables to be synchronized at the target have this field. Synchronize Custom Data After enabling this option, enter the Specify Field Name and Field Value. You can synchronize a custom value as a string to a specified field in the target table.
If the page's configuration parameters do not meet your needs, you can click Parameter Configuration at the bottom of the page for more specific configurations. If you have configured task templates or component templates, you can also reference them here.
Click Precheck to have the system perform a precheck on the data migration task.
During the Precheck phase, OMS checks whether the database user's read/write permissions, database network connectivity, and other requirements are met. The data migration task can only be started after all check items pass. If the precheck reports an error:
You can troubleshoot and resolve the issue, then re-execute the precheck until it succeeds.
You can also click Skip in the Actions column for the failed precheck item. A dialog box will pop up explaining the specific impact of skipping this operation. After confirming you can skip it, click OK in the dialog box.
Click Start Task. If you do not need to start the task immediately, click Save to go to the data migration task details page, where you can start it manually as needed.
You can click Configure Validation Task in the upper-right corner of the data migration details page to compare data differences between the source and target databases. For more information, see Create a data verification task.
OMS supports modifying migration objects during the execution of a data migration task. For more information, see View and modify migration objects. After a data migration task is started, it is executed sequentially according to the selected migration type. For more information, see the "View migration details" section in View details of a data migration task.