PolarDB is a next-generation relational database service that is developed by Alibaba Cloud. It is compatible with MySQL, PostgreSQL, and Oracle database engines. PolarDB provides superior performance in storage and computing to meet diverse requirements of enterprises. This topic describes how to configure one-way data synchronization between PolarDB-O clusters.
Prerequisites
- The source PolarDB-O cluster uses the latest version. For more information, see Upgrade the minor version.
- The tables to be synchronized contain primary keys or UNIQUE NOT NULL indexes.
- The value of the wal_level parameter is set to logical for the source PolarDB-O cluster. This setting ensures that logical decoding is supported in write-ahead logging (WAL). For more information, see Change the values of cluster parameters.
Precautions
- DTS uses read and write resources of the source and destination databases during initial full data synchronization. This may increase the database load. If the database performance is unfavorable, the specification is low, or the data volume is large, database services may become unavailable. For example, DTS occupies a large amount of read and write resources in the following cases: a large number of slow SQL queries are performed on the source database, the tables have no primary keys, or a deadlock occurs in the destination database. Before synchronizing data, you must evaluate the performance of the source and destination databases. We recommend that you synchronize data during off-peak hours. For example, you can synchronize data when the CPU usage of the source and destination databases is less than 30%.
- A single data synchronization task can synchronize data from only one database. To synchronize data from multiple databases, you must create a data synchronization task for each database.
- To ensure that the delay time of data synchronization is accurate, DTS adds a heartbeat
table named
dts_postgres_heartbeat
to the source database. The following figure shows the schema of the heartbeat table. - If you select a schema as the object to be synchronized and create a table in the
schema or run the RENAME command to rename the table, you must run the
ALTER TABLE schema.table REPLICA IDENTITY FULL;
command before you write data to the table.Note Replace theschema
andtable
in the preceding sample command with the actual schema name and table name.
SQL operations that can be synchronized
INSERT, UPDATE, and DELETE