This topic describes how to migrate incremental data from an Amazon RDS for PostgreSQL instance to an ApsaraDB RDS for PostgreSQL instance by using Data Transmission Service (DTS). DTS supports schema migration, full data migration, and incremental data migration. You can select all of the supported migration types to ensure service continuity.
Prerequisites
- The version of the Amazon RDS for PostgreSQL instance is 10.4 to 12.
- The Public accessibility option of the Amazon RDS for PostgreSQL instance is set to Yes. This ensures that DTS can access the instance over the Internet.
- The value of the rds.logical_replication parameter is set to 1. This ensures that DTS can read incremental data from the Amazon RDS for PostgreSQL instance.
- An ApsaraDB RDS for PostgreSQL instance is created. For more information, see Create an ApsaraDB RDS for PostgreSQL instance.
Note
- The version of the ApsaraDB RDS for PostgreSQL instance is 10 or 11. To migrate data between different database versions, create a pay-as-you-go instance to verify compatibility.
- The available storage space of the ApsaraDB RDS for PostgreSQL instance must be larger than the total size of the data in the Amazon RDS for PostgreSQL instance.
Precautions
- DTS uses read and write resources of the source and destination databases during full data migration. This may increase the loads of the database servers. 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 you migrate data, evaluate the impact of data migration on the performance of the source and destination databases. We recommend that you migrate data during off-peak hours. For example, you can migrate data when the CPU utilization of the source and destination databases is less than 30%.
- The objects to be migrated must have PRIMARY KEY or UNIQUE constraints and all fields must be unique. Otherwise, the destination database may contain duplicate data records and data migration may fail.
- A single data migration task can migrate data from only one database. To migrate data from multiple databases, you must create a data migration task for each database.
- In this scenario, DTS can migrate only data manipulation language (DML) operations, such as INSERT, DELETE, and UPDATE.
- During data migration, DTS creates a replication slot for the Amazon RDS for PostgreSQL
instance. The replication slot is prefixed with
dts_sync_
. DTS automatically clears historical replication slots every 90 minutes to reduce storage usage.Note If the data migration task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the Amazon RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot. - If a data migration task fails, DTS automatically resumes the task. Before you switch your workloads to the destination instance, stop or release the data migration task. Otherwise, the data in the source instance will overwrite the data in the destination instance after the task is resumed.
Billing
Migration type | Task configuration fee | Internet traffic fee |
---|---|---|
Schema migration and full data migration | Free of charge. | Charged only when data is migrated from Alibaba Cloud over the Internet. For more information, see Pricing. |
Incremental data migration | Charged. For more information, see Pricing. |
Migration types
- Schema migration
DTS migrates the schemas of the required objects to the ApsaraDB RDS for PostgreSQL instance. DTS supports schema migration for the following types of objects: table, trigger, view, sequence, function, user-defined type, rule, domain, operation, and aggregate.Note DTS does not migrate functions that are written in the C programming language.
- Full data migration
DTS migrates historical data of the required objects from the Amazon RDS for PostgreSQL instance to the ApsaraDB RDS for PostgreSQL instance.
- Incremental data migration
After full data migration is complete, DTS synchronizes incremental data from the Amazon RDS for PostgreSQL instance to the ApsaraDB RDS for PostgreSQL instance. Incremental data migration allows you to ensure service continuity when you migrate data between PostgreSQL databases.
Permissions required for database accounts
Database | Schema migration | Full data migration | Incremental data migration |
---|---|---|---|
Amazon RDS for PostgreSQL | The USAGE permission on pg_catalog | The SELECT permission on the objects to be migrated | The rds_superuser permission |
ApsaraDB RDS for PostgreSQL | The CREATE and USAGE permissions on the objects to be migrated | The permissions of the schema owner | The permissions of the schema owner |
Data migration process
To prevent data migration failures caused by dependencies between objects, DTS migrates the schemas and data of the source PostgreSQL database in the following order: