Synchronize data from an ApsaraDB RDS for PostgreSQL instance to an Oracle tenant of OceanBase Database

Updated at: 2025-02-26 03:12

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 target Oracle tenant of OceanBase Database and granted corresponding privileges to the user. For more information, see Create a database user.

  • If you need to perform incremental synchronization, perform the following operations first:

    • The data transmission service does not support automatic synchronization of DDL statements during incremental synchronization. If you need to perform DDL operations on a table to be synchronized, execute the corresponding DDL statements first in the target, and then in the source ApsaraDB RDS for PostgreSQL instance.

      To correctly parse incremental DML operations performed after the DDL statement is executed, you must create a corresponding trigger and a table for recording the DDL statement. For more information, see Create a trigger.

    • If you have selected Incremental Synchronization, you must 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.

  • The data transmission service supports incremental synchronization only from the primary database.

Considerations

  • If you have selected Incremental Synchronization, the table-level REPLICA IDENTITY option must 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 table-level REPLICA IDENTITY option 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 target 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.

    Note

    If 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 task 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 target, duplicate data may exist if the target table does not have a primary key or not-null unique key.

  • 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 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 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 synchronization 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.

    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.

  • If you select only Incremental Synchronization when you create a data synchronization task, the data transmission service requires that the local incremental logs in the source database be retained for at least 48 hours.

    If you select Full Synchronization and Incremental Synchronization when you create a data synchronization task, the data transmission service requires that the local incremental logs in the source database be retained for at least seven days. Otherwise, the data synchronization task may fail or the data in the source and target databases may be inconsistent because the data transmission service cannot obtain incremental logs.

  • 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

In the following table, OB_Oracle stands for an Oracle tenant of OceanBase Database.

Source

Target

Source

Target

PostgreSQL (ApsaraDB RDS instance)

OB_Oracle (OceanBase cluster instance)

PostgreSQL (ApsaraDB RDS instance)

OB_Oracle (self-managed database in a VPC)

Data type mappings

ApsaraDB RDS for PostgreSQL instance

Oracle tenant of OceanBase Database

ApsaraDB RDS for PostgreSQL instance

Oracle tenant of OceanBase Database

int

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 CHAR data type are 1 byte and 2,000 bytes.

varchar

VARCHAR2(n)

text

CLOB

timestamp

TIMESTAMP(p)

timestamp with 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

  1. Log on to the ApsaraDB for OceanBase console and purchase a data synchronization task.

    For more information, see Purchase a data synchronization project.

  2. Choose Data Transmission > Data Synchronization. On the page that appears, click Configuration for the data synchronization task.

    image.png

    If you want to reference the configurations of an existing task, click Reference Configuration. For more information, see Reference and clear the configuration of a data synchronization task.

  3. On the Select Source and Target page, configure the parameters.

    Parameter

    Description

    Parameter

    Description

    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 PostgreSQL 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 PostgreSQL data source.

    Target

    If you have created an OceanBase 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 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 synchronization projects.

  4. Click Next. On the Select Synchronization Type page, specify the synchronization types for the current data synchronization task.

    image

    The supported synchronization types are Schema Synchronization, Full Synchronization, and Incremental Synchronization. At present, only DML Synchronization is supported for Incremental Synchronization. The supported DML operations are INSERTDELETE, and UPDATE. You can select operations as needed. For more information, see Configure DDL/DML synchronization.

  5. Click Next. On the Select Synchronization Objects page, select the synchronization objects.

    You can use the Specify Objects or Match Rules option to specify synchronization objects. This topic describes how to specify synchronization objects by using the Specify Objects option. For information about how to configure matching rules, see the "Wildcard patterns for data migration/synchronization between databases" section in the Configure and modify matching rules topic.

    Important
    • The 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 task.

    image.png

    1. In the Select Synchronization Objects section, select Specify Objects.

    2. 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.

    3. Click > to add them to the Target Object(s) list.

    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.

    Note

    When 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 filter conditions. For more information, see Configure and modify matching rules.

    Operation

    Description

    Operation

    Description

    Import objects

    1. In the list on the right, click Import Objects in the upper-right corner.

    2. In the dialog box that appears, click OK.

      Important

      This operation will overwrite previous selections. Proceed with caution.

    3. 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.

    4. Click Validate.

    5. After the validation succeeds, click OK.

    Rename objects

    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.

    1. In the list on the right, hover over the object that you want to set.

    2. Click Settings.

    3. 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.

    4. Click OK.

    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 synchronization object

      In the list on the right, hover 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.

  6. Click Next. On the Synchronization Options page, configure the parameters.

    • Full synchronization

      The following table describes the full synchronization parameters, which are displayed only if you have selected Full Synchronization on the Select Synchronization Type page.

      image

      Parameter

      Description

      Parameter

      Description

      Read Concurrency

      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

      The concurrency for writing data to the target during full synchronization. The maximum value is 512. A high write concurrency may incur excessive stress on the target, 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 target per second during full synchronization, and the BPS specifies the maximum amount of data in bytes synchronized to the target per second during full synchronization.

      Note

      The 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 target and the instance specifications.

      Handle Non-empty Tables in Target Database

      • 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.

        Important

        If you select Ignore, data is pulled in IN mode for 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.

        Important

        If you click Restore 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.

      image

      Parameter

      Description

      Parameter

      Description

      Write Concurrency

      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.

      Note

      The 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 unavailable when the source is a PostgreSQL database. The default value is the time when incremental synchronization is started.

    • Advanced parameters

      • The following parameters are displayed only if Schema Synchronization is not selected on the Select Synchronization Type page.

        image

        Parameter

        Description

        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 target.

        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 target table.

        When you specify Specify Field Name, make sure that this field exists in the schemas of all involved tables in the target.

        Sync Custom Data

        You can synchronize a custom field value as a string to the specified field of the table to be synchronized in the target.

        Important

        The 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 target is an Oracle tenant of OceanBase Database V4.3.0 or later and you have selected Schema Synchronization on the Select Synchronization Type page.

        image

        This parameter specifies the storage type for target table objects during schema synchronization or incremental synchronization. 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.

        Note

        The value Default means that other parameters are automatically set based on the parameter configurations of the target. Table objects in schema synchronization are written to the corresponding schemas based on the specified storage type.

  7. Click Precheck.

    During the precheck, the data transmission service detects the connection between the source and target. 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.

  8. After the precheck succeeds, click Start Task.

    If you do not need to start the task now, click Save. You can manually start the task on the Synchronization Tasks 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 task is started, it will be executed based on the selected synchronization types. For more information, see View details of a data synchronization task.

    The data transmission service allows you to remove synchronization objects during data synchronization. For more information, see View and modify synchronization objects.

    Important

    You 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 task encounters an execution exception due to a network failure or slow startup of processes, you can click Restore on the Synchronization Tasks or Details page of the synchronization task.

References

  • On this page (0, O)
  • Prerequisites
  • Limitations
  • Considerations
  • Supported source and target instance types
  • Data type mappings
  • Procedure
  • References
Feedback