This topic describes how to synchronize data from an ApsaraDB RDS for PostgreSQL instance to an Oracle tenant of OceanBase Database.
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 dedicated privileged account for data synchronization in the source ApsaraDB RDS for PostgreSQL instance. For more information, see PostgreSQL data source.
You have created a dedicated database user for data synchronization in the destination Oracle tenant of OceanBase Database and granted corresponding privileges to the user. For more information, see Create a database user.
The following settings are complete before you perform incremental synchronization:
The data transmission service does not support automatic incremental synchronization of DDL statements. If you need to perform DDL operations on a table to be synchronized, execute the corresponding DDL statements first in the destination, and then in the source ApsaraDB RDS for PostgreSQL instance.
To ensure that incremental DML operations performed after the DDL statement is executed can be correctly parsed, you must create a corresponding trigger and a table for recording the DDL statement. For more information, see Create a trigger.
After you select Incremental Synchronization, set the
wal_level
parameter to logical. For more information, see Change the log level for an ApsaraDB RDS for PostgreSQL instance.
Limitations
Only instances of ApsaraDB RDS for PostgreSQL V11.x and V12.x are supported.
The data transmission service supports the synchronization 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 data transmission service does not support synchronization of views, partitioned tables, unlogged tables, temporary tables, FOREIGN KEY constraints, or check constraints from an ApsaraDB RDS for PostgreSQL instance to an Oracle tenant of OceanBase Database.
You can synchronize data only from the primary database during incremental synchronization.
Considerations
After you select Incremental Synchronization, you must make sure that the
REPLICA IDENTITY
parameter for tables meet the following requirements:If you select Specify Objects, the specified table must contain a primary key, or the
REPLICA IDENTITY
parameter for the table must be set to FULL. Otherwise, the operation to update or delete the business data fails.If you select Match Rules, the source ApsaraDB RDS for PostgreSQL instance must subscribe to all tables of the selected database, including selected tables, unselected tables, and new tables, and all the tables must contain primary keys, or the
REPLICA IDENTITY
parameter for the tables must be set to FULL. Otherwise, the operation to update or delete the business data fails.
You can execute the following statement to set the
REPLICA IDENTITY
parameter for a table to FULL:ALTER TABLE table_name REPLICA IDENTITY FULL;
When you synchronize schemas or incremental DDL operations from an ApsaraDB RDS for PostgreSQL instance to an Oracle tenant of OceanBase Database, table names and field names are converted into uppercase letters based on the default strategies of the data transmission service. For example, the source table name a is converted into A at the destination by default. You can specify a table name or field name in the format of a, A, or "A", but not "a".
The Incr-Sync component of an ApsaraDB RDS for PostgreSQL instance automatically creates publications and slots, but you must monitor the disk usage of the instance logs. By default, the data transmission service notifies the instance, at an interval of 10 minutes, to update the
confirmed_flush_lsn
value of a slot to the latest log sequence number (LSN) of 10 minutes ago. Therefore, each Incr-Sync component retains at least 10 minutes of logs of the ApsaraDB RDS for PostgreSQL instance.NoteIf you want to modify the notification interval, or the retention period of generated log files of the ApsaraDB RDS for PostgreSQL instance, contact OceanBase Technical Support.
If logs of the ApsaraDB RDS for PostgreSQL instance cannot be cleared during data synchronization due to the existence of slots, you must delete the data synchronization project and then clear the logs. The smallest
slot restart_lsn
value among all slots determines whether the log files of the ApsaraDB RDS for PostgreSQL instance can be recycled. If the smallest value is within the log file range, the log files are not recycled.When you synchronize data to the destination, duplicate data may exist if the destination table does not have a primary key or not-null unique key.
If the UTF-8 character set is used in the source, we recommend that you use a compatible character set, such as UTF-8 or UTF-16, in the destination to avoid garbled characters.
Check whether the synchronization precision of the data transmission service for columns of the DECIMAL, FLOAT, and DOUBLE data types is as expected. If the precision of the destination field type is lower than the precision of the 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 you modify a unique index at the destination, you must restart the data synchronization project to avoid data inconsistency.
Clock desynchronization between nodes, or between the computer terminal and the server, can result in inaccurate incremental synchronization latency.
For example, if the clock is ahead of the standard time, it may result in a negative latency. Conversely, if the clock is behind the standard time, it may result in an increased latency.
Supported source and destination instances
In the following table, OB_Oracle stands for an Oracle tenant of OceanBase Database.
Source | Destination |
PostgreSQL (ApsaraDB RDS instance) | OB_Oracle (OceanBase cluster instance) |
Data type mappings
ApsaraDB RDS for PostgreSQL instance | Oracle tenant of OceanBase Database |
Integer | NUMBER(10) |
smallint | NUMBER(5) |
bigint | NUMBER(20) |
decimal | NUMBER(p,s) |
Numeric | NUMBER(p,s) |
real | BINARY_FLOAT |
double precision | BINARY_DOUBLE |
smallserial | NUMBER(5) |
serial | NUMBER(10) |
bigserial | NUMBER(20) |
char | CHAR(n) Note The default length and maximum length of a column of the |
Varchar | VARCHAR2(n) |
text | CLOB |
timestamp | TIMESTAMP(p) |
timestamp without time zone | TIMESTAMP [(p)] WITH TIME ZONE |
time | DATE |
time with time zone | TIMESTAMP [(p)] WITH TIME ZONE |
boolean | NUMBER(1) |
bytea | BLOB |
citext | CLOB |
tsvector | CLOB |
Procedure
Log on to the ApsaraDB for OceanBase console and purchase a data synchronization project.
For more information, see Purchase a data synchronization project.
Choose Data Transmission > Data Synchronization. On the page that appears, click Configuration for the data synchronization 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 synchronization project.
On the Select Source and Destination page, configure the parameters.
Parameter
Description
Synchronization 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 Manage data synchronization projects by using tags.
Source
If you have created a PostgreSQL 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, see Create a PostgreSQL data source.
Destination
If you have created an OceanBase 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, see OceanBase data source.
ImportantIf the destination is an Oracle tenant of OceanBase Database, Instance Type cannot be set to Self-Managed Database in VPC.
Click Next. On the Select Synchronization Type page, specify the synchronization type for the current data synchronization project.
The supported synchronization types include Schema Synchronization, Full Synchronization, and Incremental Synchronization. At present, only DML Synchronization is supported for Incremental Synchronization. The supported DML operations are
Insert
,Delete
, andUpdate
. You can select operations as needed. For more information, see Configure DDL/DML synchronization.Click Next. On the Select Synchronization Objects page, select the synchronization objects.
You can select Specify Objects or Match Rules to specify the synchronization objects.
ImportantThe name of a table to be synchronized, as well as the names of columns in the table, must not contain Chinese characters.
If a database or table name contains a double dollar sign ($$), you cannot create the synchronization project.
Select Specify Objects. Then select the objects to be synchronized on the left and click > to add them to the list on the right. You can select tables of one or more databases as the synchronization objects.
The data transmission service allows you to import objects by using text. It also allows you to rename objects, set objects, and remove a single object or all objects.
NoteWhen you select Match Rules to specify synchronization 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 Synchronization Objects dialog box, import the objects to be synchronized. 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 synchronization objects.
Click Validate.
After the validation succeeds, click OK.
Rename an object
The data transmission service allows you to rename synchronization objects. For more information, see Rename a database table.
Configure settings
You can use the
WHERE
clause to filter data by row and view column information of synchronization objects.In the list on the right, move the pointer over the object that you want to set.
Click Settings.
In the Settings dialog box, you can perform the following operations:
In the Row Filters section, specify a standard SQL
WHERE
clause to filter data by row. For more information, see Use SQL conditions to filter data.You can also view column information about synchronization objects in the View Columns section.
Click OK.
Remove one or all objects
The data transmission service allows you to remove a single object or all synchronization objects that are added to the right-side list during data mapping.
Remove a single synchronization object
In the list on the right, move the pointer over the object that you want to remove, and click Remove to remove the synchronization object.
Remove all synchronization 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 synchronization objects.
Select Match Rules. For more information, see Configure matching rules.
Click Next. On the Synchronization Options page, configure the parameters.
Full synchronization
The following table describes the parameters for full synchronization, which are displayed only if you have selected Full Synchronization on the Select Synchronization Type page.
Parameter
Description
Read Concurrency Configuration
The concurrency for reading data from the source during full synchronization. The maximum value is 512. A high concurrency may incur excessive stress on the source, thereby affecting the business.
Write Concurrency Configuration
The concurrency for writing data to the destination during full synchronization. The maximum value is 512. A high write concurrency may incur excessive stress on the destination, affecting the business.
Full Synchronization Rate Limit
You can choose whether to limit the full synchronization rate as needed. If you choose to limit the full synchronization rate, you must specify the records per second (RPS) and bytes per second (BPS). The RPS specifies the maximum number of data rows synchronized to the destination per second during full synchronization, and the BPS specifies the maximum amount of data in bytes synchronized to the destination per second during full synchronization.
NoteThe RPS and BPS values specified here are only for throttling. The actual full synchronization 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
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 for 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.
Incremental synchronization
The following table describes the incremental synchronization parameters, which are displayed only if you have selected Incremental Synchronization on the Select Synchronization 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
This parameter will not be displayed if you have selected Full Synchronization.
If you have selected Incremental Synchronization but not Full Synchronization, specify a point in time after which data is to be synchronized. The default value is the current system time. For more information, see Set an incremental synchronization timestamp.
Advanced parameters
The following parameters are displayed only if Schema Synchronization is not selected on the Select Synchronization Type page.
Parameter
Description
Synchronize Data
After you select this parameter, you can write specified data, such as the schema and other custom field values of the source, to specified fields in the destination.
Sync Schema Name
The data transmission service obtains the schema name of the source and writes it as a string into the specified field in the destination table.
When you specify Specify Field Name, make sure that this field exists in the schemas of all involved tables in the destination.
Sync Custom Data
You can synchronize a custom field value as a string to the specified field of the target table in the destination.
ImportantThe data transmission service does not verify the type of the field specified by Specify Field Name, verify the validity of the value specified by Field Value, or escape special characters. Make sure that the field type and value meet the requirements.
This section is displayed only if the destination is an Oracle tenant of OceanBase Database V4.3.0 or later and you have selected Schema Synchronization on the Select Synchronization Type page.
This parameter specifies the storage type for destination table objects during schema synchronization 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 synchronization, the schemas are subject to the specified storage type.
Click Precheck.
During the precheck, the data transmission service detects the connection with the destination data source. 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. You can manually start the project on the Synchronization Projects page or by performing batch operations later. For more information about batch operations, see Perform batch operations on data synchronization projects. After the data synchronization project is started, it will be executed based on the selected synchronization types. For more information, see View synchronization details.
The data transmission service allows you to remove synchronization objects during data synchronization. For more information, see Remove synchronization objects.
ImportantYou cannot add synchronization objects during data synchronization from an ApsaraDB RDS for PostgreSQL instance to an Oracle tenant of OceanBase Database.
If the data synchronization project encounters a running exception due to a network failure or slow startup of processes, you can click Recover on the Synchronization Projects page or on the Details page of the synchronization project.