This topic describes how to migrate data from a PolarDB-O database to an Oracle tenant of OceanBase Database by using the data transmission service.
A data migration task remaining in an inactive state for a long time may fail to be resumed depending on the retention period of incremental logs. Inactive states are Failed, Stopped, and Completed. The data transmission service releases data migration tasks remaining in an inactive state for more than 3 days to reclaim related resources. We recommend that you configure alerting for data migration tasks and handle task 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 a privileged account for data migration in the PolarDB-O database. For more information, see PolarDB-O data source.
You have created a dedicated database user for data migration in the Oracle tenant of OceanBase Database and granted required privileges to the user. 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.
The data transmission service supports PolarDB-O 1.x and 2.x databases.
The data transmission service does not support triggers in the target database. If triggers exist in the target database, the data migration may fail.
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: . | " ' ` ( ) = ; / & \.
When you migrate data from a PolarDB-O 1.0 database, do not add tables containing generated columns as objects for incremental synchronization. Otherwise, parsing of incremental data will fail due to the failure to parse schemas of generated columns or obtain data of generated columns. This causes exceptions to incremental synchronization tasks.
Considerations
If the UTF-8 character set is used in the source database, we recommend that you use a compatible character set, such as UTF-8 or UTF-16, in the target database to avoid garbled characters.
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 the target field type is lower than that of the source field type, the value with a higher precision may be truncated. This may result in data inconsistency between the source and target fields.
If you modify a unique index at the target, you must restart the data migration task to avoid data inconsistency.
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.
Take note of the following considerations if you want to aggregate multiple tables:
We recommend that you configure the mappings between the source and target databases by specifying matching rules.
We recommend that you manually create schemas at the target. If you create a schema by using the data transmission service, skip the failed objects in the schema migration step.
If you select only Incremental synchronization when you create the data migration task, the data transmission service requires that the local incremental logs of the source database be retained for at least 48 hours.
If you select Full Data Migration and Incremental Synchronization when you create the data migration task, the data transmission service requires that the local incremental logs of the source database be retained for at least seven days. If the data transmission service cannot obtain incremental logs, the data migration task may fail or even the data between the source and target databases may be inconsistent after migration.
If the source or target database contains table objects that differ only in letter cases, the data migration results may not be as expected due to case insensitivity in the source or target database.
Supported source and target instance types
A PolarDB-O data source can be an Alibaba Cloud PolarDB-O instance, a self-managed database in a virtual private cloud (VPC), or a self-managed database with a public IP address. In the following table, OB_Oracle stands for an Oracle tenant of OceanBase Database.
Source | Target |
PolarDB-O | OB_Oracle (OceanBase cluster instance) |
PolarDB-O | OB_Oracle (self-managed database in a VPC) |
Data type mappings
PolarDB-O database | Oracle tenant of OceanBase Database |
int2 | NUMBER(5) |
int4 | NUMBER(10) |
int8 | NUMBER(20) |
numeric | NUMBER |
float4 | BINARY_FLOAT |
float8 | BINARY_DOUBLE |
smallserial | NUMBER(5) |
serial4 | NUMBER(10) |
bigserial | NUMBER(20) |
timestamp | TIMESTAMP(6) |
timestamptz | TIMESTAMP(6) WITH TIME ZONE |
time | TIMESTAMP(6) |
timetz | TIMESTAMP(6) WITH TIME ZONE |
bool | NUMBER(1) |
bytea | BLOB |
text | CLOB |
bpchar(n) | CHAR(n CHAR) Note The data type is converted to VARCHAR2(n CHAR) if the following condition is met: n × 4 > 2000. |
varchar(n) | VARCHAR2(n CHAR) Note The data type is converted to CLOB if the following condition is met: n × 4 > 32767L. |
numeric(p, s) | Number(p, s) PolarDB-O databases support a wider numeric precision range than Oracle tenants of OceanBase Database. During data migration from a PolarDB-O database to an Oracle tenant of OceanBase Database, if the numeric precision exceeds the limits of the Oracle tenant, the following conversion rules apply:
|
Procedure
Log on to the ApsaraDB for OceanBase console and purchase a data migration task.
For more information, see Purchase a data migration task.
Choose Data Transmission > Data Migration. On the page that appears, click Configuration for the data migration task.
If you want to reference the configurations of an existing task, click Reference Configuration. For more information, see Reference the configuration of a data migration task.
On the Select Source and Destination page, configure the parameters.
Parameter
Description
Data Migration Task 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.
Source
If you have created a PolarDB-O data source, select it from the drop-down list. Otherwise, click New Data Source in the drop-down list and create one in the dialog box that appears on the right. For more information, see Create a PolarDB-O data source.
Destination
If you have created an Oracle tenant in OceanBase Database as a data source, select it from the drop-down list. Otherwise, click New Data Source in the drop-down list and create one in the dialog box that appears on the right. For more information about the parameters, see Create an OceanBase data source.
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 tasks.
Click Next. On the Select Migration Type page, specify migration types for the current data migration task.
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 target database and automatically filters out temporary tables.
Full migration
After a full migration task is started, the data transmission service migrates existing data from tables in the source database to corresponding tables in the target database.
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 target 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 a DDL operation adds a new column, define the column as nullable to prevent potential disruptions to data migration.
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 target databases.
If you have selected Incremental synchronization but did not select all DML operations in the DML synchronization section, you cannot select Full Verification.
Reverse incremental migration
Data changes made in the target 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 migration objects for the data migration task.
You can select Specify Objects or Match Rules to specify the migration objects. This topic describes how to select migration objects by using the Specify Objects option. For more information about how to configure matching rules, see Configure matching rules.
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 task.
If you have selected DDL synchronization on the Select Migration Type page, we recommend that you select migration objects by using the Match Rules option. This way, all new objects that meet the migration rules will be synchronized. If you select migration objects by using the Specify Objects option, new or renamed objects will not be synchronized.
In the Select Migration Objects section, select Specify Objects.
In the Source Object(s) list of the Specify Migration Scope section, select the objects to migrate. You can select tables and views of one or more databases.
Click > to add them to the Target Object(s) list.
The data transmission service allows you to import objects from text files, rename target 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
Step
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 objects
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.
Click Next. 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 Bidirectional Synchronization and 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 target during full migration. The maximum value is 512. A high write concurrency may incur excessive stress on the target, 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 target per second during full migration, and the BPS specifies the maximum amount of data in bytes migrated to the target 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 target and the instance specifications.
Processing Strategy When Destination Table Has Records
Valid values are Ignore and Stop Migration.
If you select Ignore, when the data to be inserted conflicts with existing data of a target 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 target contains data that does not exist in the source, and the verification performance is downgraded.
If you select Stop Migration and a target table contains records, an error prompting migration unsupported is reported during full migration. In this case, you must process the data in the target table before continuing 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 data migration is completed. Post-indexing can shorten the time required for full data 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 target OceanBase database returns the following error during index creation, the data transmission service ignores the error and determines that the index is successfully created, without creating it again.
Error message in a MySQL tenant of OceanBase Database:
Duplicate key name
.Error message in an Oracle tenant of OceanBase Database:
name is already used by an existing object
.
If you select Allow, set the following parameters:
Single index DDL concurrency configuration: the maximum number of concurrent DDL operations allowed for a single index. A larger value indicates higher resource consumption and faster data migration.
Maximum concurrent index DDL quantity configuration: the maximum number of post-indexing DDL operations that the system can call at a time.
If post-indexing is allowed, we recommend that you use a CLI client to modify the following parameters for business tenants based on the hardware conditions of OceanBase Database and your current business traffic:
// 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;
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 target during incremental synchronization. The maximum value is 512. A high write concurrency may incur excessive stress on the target, 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 target per second during incremental synchronization, and the BPS specifies the maximum amount of data in bytes synchronized to the target 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 target and the instance specifications.
Incremental Synchronization Start Timestamp
This parameter is displayed only if you did not select Full Data Migration on the Select Migration Type page. When you migrate data from a PolarDB-O database, you cannot specify this parameter. By default, the start timestamp is the start time of incremental synchronization.
Reverse incremental migration
This section is displayed only if you have selected Incremental synchronization 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.
Reverse Increment Rate Limit
You can choose whether to limit the reverse incremental migration 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 target and the instance specifications.
Incremental Synchronization Start Timestamp
This parameter is not displayed if you have selected Full Data Migration on the Select Migration Type page.
If you have selected Incremental synchronization but not Full Data Migration, the forward switchover start timestamp (if any) is used by default. This parameter cannot be modified.
Advanced parameters
This section is displayed only if you have selected Schema Migration or DDL synchronization for Incremental synchronization on the Select Migration Type page when you migrate data to an Oracle tenant of OceanBase Database V4.3.0 or later.
The storage types supported for target 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 target. 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 task.
During the precheck, the data transmission service checks the read and write privileges of the database users and the network connections of the databases. A data migration task 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 Task.
If you do not need to start the task now, click Save. You can start the task later on the Migration Tasks page or by performing batch operations. For more information about batch operations, see Perform batch operations on data migration tasks. After the data migration task is started, it will be executed based on the selected migration types. For more information, see View the details of a data migration task.
The data transmission service allows you to remove migration objects when the data migration task is running. For more information, see View and modify migration objects.
NoteYou cannot add migration objects during the running of a task for migrating data from a PolarDB-O database to an Oracle tenant of OceanBase Database.