This topic describes how to migrate incremental data from an Amazon RDS for PostgreSQL database to an ApsaraDB RDS for PostgreSQL database 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 database is 10.4-R1 to 11.4-R1.
- The Public accessibility option of Amazon RDS for PostgreSQL is set to Yes. This ensures that DTS can access Amazon RDS for PostgreSQL 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 database.
- An ApsaraDB RDS for PostgreSQL instance is created. For more information, see Create an RDS for PostgreSQL instance.
Note
- The version of the ApsaraDB RDS for PostgreSQL database 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 database is larger than the total size of the data in the Amazon RDS for PostgreSQL database.
Notes
- DTS uses read and write resources of the source and destination databases during full data migration. 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 you migrate data, evaluate 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 usage 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, duplicate data may exist in the destination database and 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.
- Only data manipulation language (DML) operations, such as INSERT, UPDATE, DELETE, and UPDATE operations, can be migrated.
- During data migration, DTS creates a replication slot for the Amazon RDS for PostgreSQL
database. The replication slot is prefixed with
dts_sync_
. DTS automatically clears historical replication slots every 90 minutes to prevent them from occupying disk space.Note If a migration task is released or fails, DTS automatically clears the replication slot. After a switchover between primary and secondary Amazon RDS for PostgreSQL databases, you must log on to the secondary database to manually clear the replication slot. - DTS automatically resumes a failed data migration task. Before switching your workloads to the destination instance, you must stop or release the data migration task. Otherwise, the data from the source database will overwrite the data in the destination instance after the task is resumed.
Billing
Migration type | Instance configurations | Internet traffic |
---|---|---|
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 database. DTS supports schema migration for the following types of objects: table, trigger, view, sequence, function, user-defined type, rule, domain, operation, and aggregate.Note Functions that are written in the C programming language cannot be migrated.
- Full data migration
DTS migrates historical data of the required objects from the Amazon RDS for PostgreSQL database to the ApsaraDB RDS for PostgreSQL database.
- Incremental data migration
After full data migration is complete, DTS synchronizes incremental data from the Amazon RDS for PostgreSQL database to the ApsaraDB RDS for PostgreSQL database. 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 database | The usage permission for pg_catalog | The SELECT permission for the objects to be migrated | The rds_superuser permission |
ApsaraDB RDS for PostgreSQL database | The create and usage permissions for the objects to be migrated | The owner permission for schemas | The owner permission for schemas |
Data migration process
To avoid data migration failures caused by dependencies between objects, DTS migrates the schemas and data of the source PostgreSQL database in the following order: