This topic describes how to use OceanBase Migration Service (OMS) Community Edition to migrate data from a MongoDB database to OceanBase Database Community Edition.
Limitations
Limitations on the source database
Do not perform DDL operations that modify database or table schemas during full migration. Otherwise, the data migration task may be interrupted.
Data migration tasks from a MongoDB database to OceanBase Database Community Edition currently support schema migration, full migration, incremental synchronization, full verification, and reverse incremental migration.
Currently supported MongoDB database versions are V3.x, V4.0.0, V4.4.6, V5.0.0, V6.0.0, V7.0.22, V8.0.15, and V8.0.29.
Data source identifiers and user accounts must be globally unique within the OMS system.
OMS Community Edition only supports migrating objects whose database, table, and column names are in ASCII and do not contain special characters (including line breaks, spaces, and |"'`()=;/&).
It is recommended that you do not migrate more than 1,000 tables at a time to avoid affecting the operation of the data migration task.
Oplog must be enabled for MongoDB incremental migration.
The MongoDB data source user must have read permission on the local database (for example, must have the read role applied to the local database) so that the incremental component can read from the local.oplog.rs file.
Note
Starting from version 7.0, MongoDB has stricter access controls for the local database. Even if a user has roles such as root, explicit read permission on local must be granted; otherwise, a "not authorized on local" error will be returned.
Data type mappings
MongoDB Database |
OceanBase Database Community Edition |
|---|---|
| double | double |
| string | string |
| object | text |
| array | text array |
| binary data | binary |
| objectId | varchar |
| boolean | tinyint |
| date | datetime |
| regular expression | varchar |
| JavaScript | text |
| timestamp | timestamp |
| integer | bigint |
| decimal | decimal |
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 Migration Tasks page, click Create Task in the upper-right corner.
On the Select Source and Target page, configure the parameters.
ParameterDescriptionMigration Task Name It is recommended to use a combination of Chinese characters, numbers, and letters. The name cannot contain spaces and must not exceed 64 characters. Tag 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 more information, see Manage data migration tasks by using tags. Source If you have created a MongoDB 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 parameter details, see Create a MongoDB data source. Destination If you have created an OceanBase Database Community Edition 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 parameter details, see Create an OceanBase-CE data source. Click Next.
On the Select Migration Type page, configure the parameters.
The Migration Type includes Schema Migration, Full Migration, Incremental Synchronization, and Reverse Increment.
Migration TypeDescriptionSchema Migration After a schema migration task starts, OMS Community Edition migrates the data object definitions (tables, indexes, etc.) from the source database to the destination database.
Manual Table Schema Adjustment Required: OMS Community Edition supports user-defined table structures. Select this option if you need to manually adjust the table structure. In this case, only the SQL for the table structure is obtained during schema migration. Execution begins after you modify the table structure.Full Migration After a full migration task starts, OMS Community Edition migrates the existing data from the source database tables to the corresponding tables in the destination database. Incremental Synchronization After an incremental synchronization task starts, OMS Community Edition synchronizes the changed data (inserts, modifications, or deletions) from the source database to the corresponding tables in the destination database.
The DML Synchronization option of Incremental Synchronization includesInsert,Delete, andUpdate. You can choose as needed. For more information, see Filter DML operations.Full Verification After full migration is completed, incremental data is synchronized to the destination and is roughly caught up with the source, OMS Community Edition automatically initiates a full data verification task for the data tables configured in the source and destination databases. - If you select Full Verification, we recommend that you collect statistics from OceanBase Database Community Edition on both the source and destination before full verification starts. For more information, see Manually collect statistics.
- If you selected Incremental Synchronization and not all DML operations are selected for the DML Synchronization option, OMS Community Edition does not support full data verification in this scenario.
Reverse Increment After a reverse increment task starts, it can continuously flow back the changed data generated in the destination database after the business switchover to the source database. Click Next. On the Select Migration Objects page, select the migration objects and scope.
You can select migration objects through two methods: Specify Objects and Match Rules. This topic describes how to select migration objects using the Specify Objects method. For details on configuring match rules, see Configure match rules for migration objects.
Note
The names of tables to be migrated and the column names within them must not contain Chinese characters.
If the database name or table name contains the character "$$", it will affect the creation of the data migration task.
In the Select Migration Objects section, select Specify Objects.
In the Specify Migration Scope section, select the objects to be migrated from the Source Object(s) list.
Click > to add it to the Target Object(s) list.
When migrating data from a MongoDB database to OceanBase Database Community Edition, OMS Community Edition supports importing objects via text, renaming object names, and removing single or all migration objects.
OperationStepImport Objects - In the right-side list of the Specify Migration Scope section, 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 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 Community Edition supports renaming migration object names. For more information, see Rename a database or table. Settings You can select columns to exclude in the Settings > View Column section so that they are not migrated later. Remove/Remove All OMS Community Edition allows you to remove one or more objects temporarily selected for migration to the target during data mapping. - Remove a single migration object
In the right-side list of the Specify Migration Scope section, hover the mouse over the target object and click the displayed 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, click OK to remove all migration objects.
Configure global field mappings.
At the bottom of the Select Migration Objects page, OMS Community Edition provides the Global Configuration Field Mapping - Forward section for configuring the field mapping relationship between the source and target.
Write Mongo _id to a column in the target table: This option is selected by default. If you clear this option, the _id field is not synchronized. It must be retained when you select reverse incremental migration.
Mongo _id column name: Specifies the column name in the target table that stores the Mongo _id. The default value is
id.Document written as JSON in one column: If you select this option, the target table contains only the _id column and the document column (the entire document is stored in JSON format). After you select this option, field mappings and table-level renaming do not take effect, and the _id field is retained by force.
Convert camelCase column names at the source to underscore case and write them to the target: If you select this option, camelCase column names at the source (such as
userName) are automatically converted to underscore case names (such asuser_name) before being written to the target.Custom field mapping: Click Add Mapping to manually configure the mapping relationship between source field names and target field names. This applies to scenarios where the field names at the source and target are inconsistent.
Click Next. On the Migration Type page, configure the parameters.
To view or modify the parameters of the full migration component, click Configuration Details in the upper-right corner of the Full Migration section. To view or modify the parameters of the incremental synchronization or reverse incremental migration component, click Store Configuration Details in the upper-right corner of the Incremental Synchronization section or Configuration Details of incr Increment as needed. For parameter descriptions, see the documentation in the Component parameters module.
Full Migration
Note
The following parameters are displayed only if you have selected Full Migration on the Select Migration Type page.
ParameterDescriptionConcurrency Speed Valid values: Stable, Normal, Fast, and Custom. Different full migration speeds result in different performances and resource requirements. When you select Custom, you can set Read Concurrency, Write Concurrency, and JVM Memory based on your actual situation. Processing Strategy When Target Object Has Records Valid values: Ignore and Stop Migration: - If you select Ignore, when data exists in the target table object and conflicts with the data to be written, OMS Community Edition logs the conflicting data and retains the original data unchanged.
Note
If you select Ignore, full verification will pull data in IN mode, which cannot verify scenarios where the target has data not present in the source, and verification performance will be degraded to some extent.
- If you select Stop Migration, when data exists in the target table object, full migration will report an error indicating that migration is not allowed. Please handle the data at the target before continuing the migration.
Note
If you click Resume after an error occurs, OMS Community Edition will ignore this configuration option and continue migrating table data. Proceed with caution.
Write Method Valid values: SQL (writes to the table using INSERTorREPLACE) and Direct Load (writes via direct load). Currently, writing vector-type data via direct load is not supported.- If you select Ignore, when data exists in the target table object and conflicts with the data to be written, OMS Community Edition logs the conflicting data and retains the original data unchanged.
Incremental Synchronization
The following parameters are displayed only if you have selected Incremental Synchronization on the Select Migration Type page.
ParameterDescriptionConcurrency Speed Includes Stable, Normal, Fast, and Custom. The performance and required resources for incremental synchronization vary with the speed. When you select Custom, you can set Read Concurrency, Write Concurrency, and JVM Memory based on your actual situation. 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.
Incremental Record Retention Time The duration for which incremental parsed files are cached in OMS Community Edition. A longer configured retention time requires more disk space for the OMS Community Edition Store component. Full Verification
The following parameters are displayed only if Full Verification is selected on the Select Migration Type page.
ParameterDescriptionConcurrency Speed Includes Stable, Normal, Fast, and Custom. Resource configuration for the Full-Verification component limits resource consumption during the full verification phase of a task. When you select Custom, you can set Read Concurrency, Write Concurrency, and JVM Memory based on your actual situation. Reverse Incremental
The following parameters are displayed only if Reverse Increment is selected on the Select Migration Type page.
ParameterDescriptionConcurrency Speed Includes Stable, Normal, Fast, and Custom. The performance of reverse incremental varies, as does the resources required for a reverse incremental task. When you select Custom, you can set Read Concurrency, Write Concurrency, and JVM Memory based on your actual situation.
Click Precheck to have the system perform a precheck on the data migration task.
During the Precheck step, OMS Community Edition checks whether the database's network connection meets requirements. The data migration task can only start after all checks 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 erroneous precheck item. A dialog box appears, explaining the specific impact of skipping this operation. After confirming it is okay to skip, 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 later.
OMS Community Edition supports modifying migration objects during the execution of a data migration task. For details, see View and modify migration objects. After a data migration task is started, it is executed sequentially according to the selected migration type. For details, see the content in the "View migration details" section of View details of a data migration task.