All Products
Search
Document Center

Data Transmission Service:Synchronize data from a self-managed PostgreSQL database to a PolarDB for PostgreSQL (Compatible with Oracle) cluster

Last Updated:Mar 28, 2026

Use Data Transmission Service (DTS) to synchronize data from a self-managed PostgreSQL database to a PolarDB for PostgreSQL (Compatible with Oracle) cluster. DTS supports schema synchronization, full data synchronization, and incremental data synchronization, so you can migrate to PolarDB with minimal downtime.

Prerequisites

Before you begin, make sure you have:

  • A running self-managed PostgreSQL database and a PolarDB for PostgreSQL (Compatible with Oracle) cluster

  • More available disk space in the destination cluster than the source database currently occupies

  • A source database account with superuser permission and a destination database account with database owner permission (see Required permissions)

To create a PolarDB for PostgreSQL (Compatible with Oracle) cluster, see Create a PolarDB for PostgreSQL (Compatible with Oracle) cluster. For supported source and destination database versions, see Overview of data synchronization solutions.

Limitations

Review these limitations before starting. Workarounds are noted inline where available.

Source database limits

LimitationDetail
Primary key or UNIQUE constraint requiredTables must have a primary key or a UNIQUE constraint with unique fields. Without one, the destination database may contain duplicate data. If the destination table is not created by DTS (that is, Schema Synchronization is not selected), the table must have the same primary key or non-null UNIQUE constraint as the source table.
Table limit for column mapping tasksIf you synchronize at the table level with column name mapping and the task includes more than 5,000 tables, split them into multiple tasks. Alternatively, configure the task to synchronize the entire database.
Database name cannot contain hyphensThe source database name must not contain hyphens (-). For example, dts-testdata is invalid.
WAL logs must be enabledSet wal_level to logical. Retain WAL logs for at least 24 hours for incremental-only tasks, or at least 7 days for tasks that include both full and incremental synchronization. You can reduce the retention period to more than 24 hours after the full synchronization phase completes. If DTS cannot obtain WAL logs or the retention period is shorter than required, any resulting data loss or inconsistency is not covered by the DTS Service-Level Agreement (SLA).
Replication slot parametersmax_wal_senders and max_replication_slots must each be greater than the sum of currently used replication slots and the number of DTS instances that use this database as the source.
Primary/secondary failoverIf a primary/secondary failover occurs in the source database, the synchronization task fails.
Long-running transactionsLong-running transactions prevent WAL log cleanup and can cause disk space exhaustion on the source. Run long-running transactions during off-peak hours.
Google Cloud SQL for PostgreSQLThe source database account must have cloudsqlsuperuser permission. Select only objects that this account can manage, or grant it owner permission on the objects to sync: GRANT <owner of the object> TO <source database account>. A cloudsqlsuperuser account cannot manage data owned by another cloudsqlsuperuser.
Incremental change sizeIf a single incremental change exceeds 256 MB, the sync instance fails and cannot recover. Reconfigure the instance.
No DDL during initial synchronizationDo not run DDL operations that change the schema during initial schema synchronization or full data synchronization. DTS queries the source during full synchronization, which creates metadata locks that block DDL operations.
Major version upgradeIf you perform a major version upgrade on the source while the sync instance is running, the instance fails and cannot recover. Reconfigure the instance.

Other limits

LimitationDetail
session_replication_roleFor full or incremental synchronization tasks with foreign keys, triggers, or event triggers, DTS temporarily sets session_replication_role to replica at the session level. This requires a privileged destination database account. If the account does not have this permission, set session_replication_role to replica manually before starting the task. After the task is released, reset it to origin. During this period, cascade update or delete operations on the source may cause data inconsistency.
SERIAL type fieldsIf a source table contains SERIAL type fields, the source database automatically creates a sequence for those fields. When configuring Source Objects, if you select Schema Synchronization, also select Sequence or synchronize the entire schema to avoid task failures.
One database per taskA single sync task can synchronize only one database. For multiple databases, create a separate task for each.
Unsupported table typesSynchronization of TimescaleDB extension tables and tables with cross-schema inheritance is not supported.
REPLICA IDENTITY FULL requirementRun ALTER TABLE schema.table REPLICA IDENTITY FULL; on tables before writing data in any of these cases: when the instance runs for the first time; when a new table is created or rebuilt (using RENAME) during schema-level synchronization; or when you modify the synchronization objects. Run this command during off-peak hours and do not hold table locks while running it. If you skip the related precheck item, DTS runs this command automatically during initialization.
Sequence validationDTS validates data content but does not validate metadata such as sequences. Validate sequences yourself. After switching traffic to the destination, new sequences do not continue from the maximum source sequence value. Update sequence values in the destination before switching. See Update sequence values in the destination database.
Temporary tables in the sourceDTS creates the following temporary tables in the source database: public.dts_pg_class, public.dts_pg_attribute, public.dts_pg_type, public.dts_pg_enum, public.dts_postgres_heartbeat, public.dts_ddl_command, public.dts_args_session, and public.aliyun_dts_instance. DTS also adds a heartbeat table named dts_postgres_heartbeat. Do not delete these tables during synchronization. They are removed automatically when the DTS instance is released.
Replication slotDTS creates a replication slot with the prefix dts_sync_ in the source database. This slot retains incremental logs for the past 15 minutes. DTS attempts to clean up the slot when the sync task fails or the instance is released. If you change the source database account password or remove DTS IP addresses from the source during synchronization, the slot cannot be cleaned up automatically — clean it up manually to prevent disk exhaustion. If a primary/secondary failover occurs, log on to the secondary database to perform the cleanup. Amazon slot查询信息
Source performanceFull data synchronization runs concurrent INSERT operations, which consumes read and write resources on both databases. Perform synchronization during off-peak hours. After initialization, the destination tablespace may be larger than the source due to fragmentation.
Writes to destination during syncDo not write data from sources other than DTS to the destination database during synchronization. Doing so causes data inconsistency.
Instance recoveryIf a DTS instance fails, DTS attempts to recover it within 8 hours. During recovery, DTS may restart the instance or adjust its parameters (DTS instance parameters only — source and destination database parameters are not changed).
Online DDL via DMSFor table-level synchronization with no non-DTS writes to the destination, you can use Data Management (DMS) to perform online DDL operations without locking tables. See Change schemas without locking tables. Do not allow other sources to write to the destination while running DMS online DDL — doing so can cause data loss.
During schema synchronization, DTS synchronizes foreign keys from the source to the destination. During full and incremental synchronization, DTS temporarily disables foreign key constraint checks and cascade operations at the session level. Cascade update or delete operations on the source during this period may cause data inconsistency.

Billing

Synchronization typeFee
Schema synchronization and full data synchronizationFree
Incremental data synchronizationCharged. See Billing overview.

Supported synchronization topologies

  • One-way one-to-one synchronization

  • One-way one-to-many synchronization

  • One-way cascade synchronization

  • One-way many-to-one synchronization

For topology details and usage notes, see Synchronization topologies.

Supported objects

ObjectsDetails
SCHEMA, TABLEIncludes PRIMARY KEY, UNIQUE KEY, FOREIGN KEY, DATATYPE (built-in data types), and DEFAULT CONSTRAINT.
Other objectsVIEW, PROCEDURE (PostgreSQL 11 or later), FUNCTION, RULE, SEQUENCE, EXTENSION, TRIGGER, AGGREGATE, INDEX, OPERATOR, DOMAIN

Supported SQL operations

TypeOperations
DMLINSERT, UPDATE, DELETE
DDLSee below

DDL synchronization is available only for tasks created after DDL support was introduced. The source database account must be a superuser, and the self-managed PostgreSQL minor version must be 20210228 or later.

Supported DDL statements:

  • CREATE TABLE, DROP TABLE

  • ALTER TABLE (including RENAME TABLE, ADD COLUMN, ADD COLUMN DEFAULT, ALTER COLUMN TYPE, DROP COLUMN, ADD CONSTRAINT, ADD CONSTRAINT CHECK, ALTER COLUMN DROP DEFAULT)

  • TRUNCATE TABLE (PostgreSQL 11 or later)

  • CREATE INDEX ON TABLE

Important

The following DDL statements are not synchronized:

  • Statements with CASCADE or RESTRICT options

  • Statements in sessions using SET session_replication_role = replica

  • DDL executed inside a function call

  • Transactions that mix DML and DDL in the same commit

  • DDL for objects outside the synchronization scope

  • DDL executed through the Server Programming Interface (SPI)

Important

Permissions required for database accounts

DatabaseRequired permissionHow to create and authorize
Self-managed PostgreSQLSuperuserUse CREATE USER and User Permission Management.
PolarDB for PostgreSQL (Compatible with Oracle)Database ownerSee Create a database account. The database owner is set when the database is created.

Prepare the source database

The following steps use a self-managed PostgreSQL database running on Linux as an example.

All PostgreSQL versions

  1. Log on to the server where the source PostgreSQL database is running.

  2. Query the number of currently used replication slots:

    SELECT count(1) FROM pg_replication_slots;
  3. Edit postgresql.conf and set the following parameters. max_wal_senders and max_replication_slots must each be greater than the sum of the replication slot count from step 2 and the number of DTS instances you plan to create with this source database. Example postgresql.conf configuration:

    ParameterRequired value
    wal_levellogical
    max_wal_sendersGreater than (current replication slots + DTS instances to create)
    max_replication_slotsGreater than (current replication slots + DTS instances to create)
    wal_level = logical
    max_wal_senders = 10
    max_replication_slots = 10

    Restart the database after saving the file for the changes to take effect.

  4. Add DTS server CIDR blocks to pg_hba.conf. Add only the CIDR blocks for DTS servers in the same region as the destination database. For the full list, see Add DTS server IP addresses to a whitelist. After saving pg_hba.conf, reload the configuration:

    SELECT pg_reload_conf();

    Alternatively, restart the database. Skip this step if pg_hba.conf already allows connections from 0.0.0.0/0. For reference, see The pg_hba.conf file.

    IP

  5. In the destination cluster, create the databases and schemas that correspond to the objects you plan to synchronize.

PostgreSQL 9.4.8 to 10.0 (additional steps)

If your source PostgreSQL version is between 9.4.8 and 10.0, you must also install the ali_decoding extension.

Step 1: Compile and install PostgreSQL from source

  1. Log on to the server where the source database is running.

  2. Download the PostgreSQL source code from the PostgreSQL official website matching your database version.

  3. Compile and install PostgreSQL:

    Important

    The OS version and GNU Compiler Collection (GCC) version must be compatible. If sudo ./configure fails with a readline error, run sudo ./configure --without-readline instead. If you use a different PostgreSQL installation method, compile ali_decoding in a test environment with the same OS and GCC version.

    sudo ./configure
    sudo make
    sudo make install

Step 2: Install the ali_decoding extension

  1. Download ali_decoding.

  2. Copy the ali_decoding directory into the contrib directory of the PostgreSQL installation from Step 1.

    contrib目录

  3. Replace the contents of the Makefile in the ali_decoding directory with the following:

    # contrib/ali_decoding/Makefile
    MODULE_big = ali_decoding
    MODULES = ali_decoding
    OBJS    = ali_decoding.o
    
    DATA = ali_decoding--0.0.1.sql ali_decoding--unpackaged--0.0.1.sql
    
    EXTENSION = ali_decoding
    
    NAME = ali_decoding
    
    #subdir = contrib/ali_decoding
    #top_builddir = ../..
    #include $(top_builddir)/src/Makefile.global
    #include $(top_srcdir)/contrib/contrib-global.mk
    
    #PG_CONFIG = /usr/pgsql-9.6/bin/pg_config
    #pgsql_lib_dir := $(shell $(PG_CONFIG) --libdir)
    #PGXS := $(shell $(PG_CONFIG) --pgxs)
    #include $(PGXS)
    
    # Run the following commands to install the source code.
    ifdef USE_PGXS
    PG_CONFIG = pg_config
    PGXS := $(shell $(PG_CONFIG) --pgxs)
    include $(PGXS)
    else
    subdir = contrib/ali_decoding
    top_builddir = ../..
    include $(top_builddir)/src/Makefile.global
    include $(top_srcdir)/contrib/contrib-global.mk
    endif
  4. From the ali_decoding directory, compile and install the extension:

    sudo make
    sudo make install
  5. Copy the generated files to the specified directories.

    指定位置

  6. In the destination cluster, create the databases and schemas that correspond to the objects you plan to synchronize.

Create a sync task

Step 1: Go to the Data Synchronization page

Use either the DTS console or the DMS console.

DTS console

  1. Log on to the DTS console.

  2. In the left-side navigation pane, click Data Synchronization.

  3. In the upper-left corner of the page, select the region in which the data synchronization task resides.

DMS console

Note

The actual operations may vary based on the mode and layout of the DMS console. For more information, see Simple mode and Customize the layout and style of the DMS console.

  1. Log on to the DMS console.

  2. In the top navigation bar, move the pointer over Data + AI and choose DTS (DTS) > Data Synchronization.

  3. From the drop-down list to the right of Data Synchronization Tasks, select the region in which the data synchronization instance resides.

Step 2: Create a task

Click Create Task to open the task configuration page.

Step 3: Configure the source and destination databases

SectionParameterDescription
N/ATask NameA name for the DTS task. DTS generates one automatically. Specify a descriptive name for easier identification. The name does not need to be unique.
Source DatabaseSelect Existing ConnectionSelect a registered database instance from the drop-down list. DTS auto-fills the following parameters. If no registered instance is available, fill in the parameters manually. In the DMS console, select from Select a DMS database instance.
Database TypeSelect PostgreSQL.
Connection TypeSelect CEN (Cloud Enterprise Network).
Instance RegionSelect the region of the source self-managed PostgreSQL database.
Cross-accountSelect No if synchronizing within the same Alibaba Cloud account.
Source Database VPCSelect the VPC connected to the source database.
IP AddressEnter the IP address of the source database server.
PortEnter the port for the source database. Default: 5432.
Database NameEnter the name of the source database containing the objects to synchronize.
Database AccountEnter the database account for the source database. See Required permissions.
Database PasswordEnter the password for the source database account.
EncryptionSelect Non-encrypted or SSL-encrypted based on your requirements. For SSL-encrypted connections, upload CA Certificate, Client Certificate, and Private Key of Client Certificate as needed, and specify Private Key Password of Client Certificate. For ApsaraDB RDS for PostgreSQL SSL configuration, see SSL encryption.
Destination DatabaseSelect Existing ConnectionSelect a registered database instance from the drop-down list. DTS auto-fills the following parameters. If no registered instance is available, fill in the parameters manually.
Database TypeSelect PolarDB (Compatible with Oracle).
Connection TypeSelect Leased Line/VPN Gateway/Smart Gateway.
Instance RegionSelect the region of the destination PolarDB for PostgreSQL (Compatible with Oracle) cluster.
VPC Connected To Source DatabaseSelect the VPC connected to the destination cluster.
DNS Or IP AddressEnter the endpoint of the primary node of the destination cluster. Run ping against the direct connection endpoint to get the IP address.
PortEnter the service port for the destination database. Default: 1521.
Database NameEnter the name of the destination database.
Database AccountEnter the database account for the destination cluster. See Required permissions.
Database PasswordEnter the password for the destination database account.

Step 4: Test connectivity

Click Test Connectivity and Proceed at the bottom of the page.

Make sure DTS server CIDR blocks are added to the security settings of both the source and destination databases. See Add DTS server IP addresses to a whitelist. If the source or destination is a self-managed database with an access method other than Alibaba Cloud Instance, click Test Connectivity in the CIDR Blocks of DTS Servers dialog box.

Step 5: Configure synchronization objects

In the Configure Objects step, configure the following:

ConfigurationDescription
Synchronization TypesIncremental Data Synchronization is selected by default. Also select Schema Synchronization and Full Data Synchronization. DTS synchronizes the historical data of selected objects to the destination cluster as the baseline for subsequent incremental synchronization.
Processing Mode of Conflicting TablesPrecheck and Report Errors: Checks whether the destination database has tables with the same names as source tables. If identical names exist, the precheck fails and the task cannot start. To rename destination tables, use the object name mapping feature. See Map object names. Ignore Errors and Proceed: Skips the precheck for identical table names.
Warning

This option may cause data inconsistency. If the same primary key or unique key value exists in both databases: during full synchronization, the existing destination record is kept; during incremental synchronization, the destination record is overwritten. If schemas differ, initialization may fail or only partial columns are synchronized.

Source ObjectsSelect one or more objects and click the arrow icon to add them to Selected Objects. Select schemas or tables. If you select tables, non-table objects (views, triggers, stored procedures) are not synchronized. If a table contains SERIAL data type and Schema Synchronization is selected, also select Sequence or synchronize the entire schema.
Selected ObjectsTo rename an object in the destination, right-click it. See Map the name of a single object. To rename multiple objects at once, click Batch Edit. See Map multiple object names at a time. Right-click an object to select specific SQL operations or set a WHERE filter condition. See Set filter conditions.

Click Next: Advanced Settings and configure the following:

ConfigurationDescription
Dedicated Cluster for Task SchedulingBy default, DTS schedules the task to the shared cluster. To improve stability, purchase a dedicated cluster. See What is a DTS dedicated cluster.
Retry Time for Failed ConnectionsHow long DTS retries when the source or destination connection fails after the task starts. Valid values: 10–1440 minutes. Default: 720 minutes. Set this to a value greater than 30 minutes. If DTS reconnects within this period, the task resumes; otherwise, it fails. If multiple tasks share the same source or destination, the shortest retry period applies. DTS charges for the instance during retries.
Retry Time for Other IssuesHow long DTS retries when DDL or DML operations fail after the task starts. Valid values: 1–1440 minutes. Default: 10 minutes. Set this to a value greater than 10 minutes, and always less than Retry Time for Failed Connections.
Enable Throttling for Full Data SynchronizationThrottles the full synchronization phase to reduce database load. Configure Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s). Available only if Full Data Synchronization is selected.
Enable Throttling for Incremental Data SynchronizationThrottles the incremental synchronization phase. Configure RPS of Incremental Data Synchronization and Data synchronization speed for incremental synchronization (MB/s).
Environment TagOptional. Select an environment tag to label the instance.
Configure ETLSelect Yesalert notification settings to use the extract, transform, and load (ETL) feature and enter data processing statements. See Configure ETL in a data migration or data synchronization task. Select No to skip.
Monitoring and AlertingSelect Yes to configure alerts when the task fails or synchronization latency exceeds the threshold. Specify alert thresholds and notification contacts. See Configure monitoring and alerting when you create a DTS task.

Click Next Step: Data Verification to configure data verification. See Configure a data verification task.

Step 6: Run the precheck

Click Next: Save Task Settings and Precheck.

To view the API parameters for this task configuration, hover over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters before proceeding.

DTS runs a precheck before the task can start. If any item fails:

  • Click View Details next to the failed item, fix the issue, then click Precheck Again.

  • If an alert item can be safely ignored, click Confirm Alert Details > View Details > Ignore > OK, then click Precheck Again. Ignoring alert items may cause data inconsistency.

Step 7: Purchase and start the instance

  1. Wait for the Success Rate to reach 100%, then click Next: Purchase Instance.

  2. On the purchase page, configure the following:

    SectionParameterDescription
    New Instance ClassBilling MethodSubscription: Pay upfront for a fixed term. More cost-effective for long-term use. Pay-as-you-go: Billed hourly. Suitable for short-term use. Release the instance when no longer needed to reduce costs.
    Resource Group SettingsThe resource group for the sync instance. Default: default resource group. See What is Resource Management?.
    Instance ClassDTS provides instance classes with different synchronization speeds. Select based on your requirements. See Instance classes of data synchronization instances.
    Subscription DurationAvailable when Subscription is selected. Options: 1–9 months, 1 year, 2 years, 3 years, or 5 years.
  3. Read and accept Data Transmission Service (Pay-as-you-go) Service Terms.

  4. Click Buy and Start, then click OK in the dialog box.

The task appears in the task list. Monitor its progress there.

What's next