This feature uses physical streaming replication for a fast, simple, and reliable migration that supports a wide range of scenarios and improves migration efficiency.
Prerequisites
-
The target ApsaraDB RDS for PostgreSQL instance must meet these requirements:
-
The major version of the instance must match that of your self-managed PostgreSQL database. PostgreSQL 10 and later versions are supported.
NoteTo migrate across major versions, such as from PostgreSQL 10 to ApsaraDB RDS for PostgreSQL 13, you must first complete the one-click cloud migration described in this topic. Then, you can upgrade the major version of the database from ApsaraDB RDS for PostgreSQL 10 to 13.
-
The instance must be a primary instance. read-only instances do not support one-click cloud migration.
-
The instance's storage type must be cloud disk.
-
The instance is empty and has available storage space greater than or equal to the data size of your self-managed PostgreSQL database.
-
-
Your self-managed PostgreSQL database must meet these requirements:
-
Network
Migration source
Network requirements
A self-managed PostgreSQL database on an ECS instance or an ApsaraDB RDS for PostgreSQL instance
The source and target instances must be in the same Virtual Private Cloud (VPC). If they are in different VPCs, you must connect them by using Cloud Enterprise Network (CEN). For more information, see Cloud Enterprise Network (CEN).
A self-managed PostgreSQL database in an on-premises data center (the data center is connected to the VPC)
Establish a private network connection between the on-premises data center and the ApsaraDB RDS for PostgreSQL instance. For details, see Connect a VPC to an on-premises data center.
-
If you are migrating from a self-managed PostgreSQL database on an ECS instance to an ApsaraDB RDS for PostgreSQL instance, you must first complete the steps in (Optional) Configure an ECS security group.
-
You must have completed the steps in Configure the postgresql.conf file.
-
You must have completed the steps in Create a migration account.
-
You must have completed the steps in Update the pg_hba.conf file.
-
You must have completed the steps in Configure the server firewall.
-
Notes
During the cloud migration task, you can read from and write to your self-managed PostgreSQL database. However, do not perform major administrative operations such as another migration, a restart, or a specification change.
Step 1: Run a feasibility evaluation
Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
-
In the left-side navigation pane, click Cloud Migration/DR Deployment, and then click the Feasibility Assessment tab.
-
On the Configure Scenario and Source Type page of the wizard, set Migration to Cloud to Cloud Migration, select your migration source, and click Next.
-
On the Configure Destination Instance page, click Next.
-
On the Configure Source Instance page, select the checkboxes for all the prerequisite configurations you have completed, and then click Next.
NoteFor more information about the items on the Configure Source Instance page, see (Optional) Configure an ECS security group, Create a migration account, and Update the pg_hba.conf file.
-
On the Start Feasibility Assessment page, configure the source instance information.
Parameter
Description
Migration Task Name
Auto-generated. No changes are required.
Source VPC/DNS IP
-
If the source database is on an ECS instance, enter the private IP of the ECS instance. For more information, see View IP addresses.
-
If the source database is in an on-premises data center, enter the private IP of the data center.
Port of Source Instance
The port of your self-managed PostgreSQL database. You can run the
netstat -a | grep PGSQLcommand to view the port.Username
migratetest. This is the database account created in the Create a migration account step.Password
123456. This is the password for the database account created in the Create a migration account step. -
-
Click Create Feasibility Assessment Task.
NoteDuring the feasibility evaluation, the instance status changes to Maintaining Instance.
After the evaluation is complete, you can view the task status in the Migration to Cloud list on the Feasibility Assessment tab.
-
If the status is Success, you can proceed to the cloud migration step. For more information, see Step 2: Start the cloud migration.
-
If the status is Failed, click Report Details in the Actions column and troubleshoot the issue based on the error message. For information about common errors, see Interpret a cloud migration evaluation report.
After you resolve the error, click Re-assess in the Actions column to start the evaluation task again.
-
Step 2: Start the cloud migration
You can perform this step only after the feasibility evaluation is successful.
Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
-
In the left-side navigation pane, click One-Click Cloud Migration/Disaster Recovery, go to the Migration to Cloud tab, and click Create Cloud Migration Task.
-
In the Create Cloud Migration Task window, select the successful evaluation task from the Associated Assessment Task list. This task is the one that you created in Step 1: Run a feasibility evaluation.
NoteAfter you select an Associated Assessment Task, the Migration Source Type, Source IP/ DNS, Port of Source Instance, and Username parameters are automatically populated.
-
Click Initiate Migration to Cloud. The system automatically starts the cloud migration task.
WarningDuring the cloud migration, the instance status changes to Migrating Data In. You can perform read and write operations on your self-managed PostgreSQL database. However, do not perform major administrative operations such as another migration, a restart, or a specification change. Otherwise, the cloud migration task will fail.
-
Perform the cutover.
-
In the cloud migration task list, click the link in the Cloud Migration Phase column to check the progress of the task.
-
When the cloud migration phase is Incremental Data Synchronization, click Switchover in the Action column to begin the cutover.
-
In the Switchover window, follow the cutover instructions: set the source instance to read-only or stop write operations from your application. Confirm that the replication status is streaming and select the checkboxes for the other instructions: the superuser is demoted to rds_superuser, and the passwords for the aurora and replicator accounts are reset and used as RDS system accounts. After you confirm, click Switch Now.
NoteSet the source instance to read-only:
-
If the source instance is an ApsaraDB RDS for PostgreSQL instance, follow these steps:
-
In Configure instance parameters, set the rds_force_trans_ro_non_sup parameter of the source instance to on.
-
Run the following statement to terminate all existing sessions.
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE usename not in ('replicator', 'monitor', 'pgsql', 'aurora') AND pid != pg_backend_pid();
-
-
If the source instance is a self-managed database, follow these steps:
-- Set the database to read-only. ALTER SYSTEM SET default_transaction_read_only=on; -- Reload the parameter configuration to apply the change. SELECT pg_reload_conf(); -- Terminate all existing sessions. SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE usename not in ('replicator', 'monitor', 'pgsql', 'aurora') AND pid != pg_backend_pid();
-
-
Select all checkboxes and click Switch Now. Then, wait for the migration to complete.
After the migration is complete, the Cloud Migration Phase column displays Completed, and the Task Status column displays Successful.
-