This topic describes how to use the cloud migration feature to migrate data from a self-managed PostgreSQL instance that resides on an Elastic Compute Service (ECS) instance or in a data center to an ApsaraDB RDS for PostgreSQL instance. The cloud migration feature of ApsaraDB RDS for PostgreSQL uses physical streaming replication to help you migrate data to the cloud in an easy-to-use, efficient manner and at a high speed with no downtime. This feature is suitable in all scenarios.
Prerequisites
- The RDS instance meets the following requirements:
- The RDS instance and the self-managed PostgreSQL instance run the same PostgreSQL version, which can be PostgreSQL 10, PostgreSQL 11, PostgreSQL 12, PostgreSQL 13, PostgreSQL 14 or PostgreSQL 15. Note If you want to migrate data from an instance that runs PostgreSQL 10 to an RDS instance that runs PostgreSQL 13, you must use the cloud migration feature to migrate the data from the source PostgreSQL instance to an RDS instance that runs PostgreSQL 10 and then upgrade the major engine version of the RDS instance to PostgreSQL 13 based on the descriptions in Upgrade the major engine version of an ApsaraDB RDS for PostgreSQL instance.
- The RDS instance is a primary instance. Read-only RDS instances do not support cloud migration.
- The RDS instance is equipped with standard SSDs or enhanced SSDs (ESSDs).
- The RDS instance is empty. The available storage of the RDS instance is greater than or equal to the size of the data in the self-managed PostgreSQL instance.
- The RDS instance and the self-managed PostgreSQL instance run the same PostgreSQL version, which can be PostgreSQL 10, PostgreSQL 11, PostgreSQL 12, PostgreSQL 13, PostgreSQL 14 or PostgreSQL 15.
- The self-managed PostgreSQL instance meets the following requirements:
- Network configurations are complete.
Migration source Network configuration Self-managed ECS-based PostgreSQL database or ApsaraDB RDS for PostgreSQL instance If the self-managed PostgreSQL instance resides on an ECS instance, the ECS instance and the destination RDS instance must reside in the same virtual private cloud (VPC). If the source instance is an RDS instance, the source RDS instance and the destination RDS instance must reside in the same VPC. If the source instance and the destination RDS instance reside in different VPCs, you must use Cloud Enterprise Network (CEN) to connect the VPCs. For more information, see What is CEN? Self-managed PostgreSQL database in a data center (within the same VPC as the destination database) The data center must be able to communicate with the VPC to which the destination RDS instance belongs. For more information, see Connect a data center to a VPC. - If the self-managed PostgreSQL instance resides on an ECS instance, an ECS security group is configured. For more information, see (Optional) Configure an ECS security group on a self-managed PostgreSQL instance.
- The configurations that are described in Configure the postgresql.conf file of a self-managed PostgreSQL instance are complete.
- The configurations that are described in Create an account for cloud migration on a self-managed PostgreSQL instance are complete.
- The configurations that are described in Update the pg_hba.conf file of a self-managed PostgreSQL instance are complete.
- The configurations that are described in Configure the firewall of the server on which a self-managed PostgreSQL instance resides are complete.
- Network configurations are complete.
Usage notes
During the cloud migration, you can read data from and write data to the self-managed PostgreSQL instance. However, do not perform operations such as migration, restart, or specification changes on the self-managed PostgreSQL instance.
Step 1: Evaluate whether the data migration is allowed
- Access RDS Instances, select a region at the top, and then click the ID of the target RDS instance.
- In the left-side navigation pane, click Migrate to Cloud. On the page that appears, click the Migration Assessment tab.
- In the Select Migration Source step of the configuration wizard, select a migration source and click Next.
- In the Configure Destination Database step of the configuration wizard, click Next.
- In the Configure Source Database step of the configuration wizard, select all listed items and click Next. You must complete the preparations that are described in the listed items before you start the cloud migration. Note For more information about the items that are listed in the Configure Source Database step of the configuration wizard, see (Optional) Configure an ECS security group on a self-managed PostgreSQL instance, Create an account for cloud migration on a self-managed PostgreSQL instance, and Update the pg_hba.conf file of a self-managed PostgreSQL instance.
- In the Initiate Migration Assessment step of the configuration wizard, configure the information about the self-managed PostgreSQL instance.
Parameter Description Migration Task Name The name of the cloud migration task. ApsaraDB RDS automatically generates a name for the cloud migration task. You do not need to modify the generated name. Source VPC/DNS IP - If the self-managed PostgreSQL instance resides on an ECS instance, enter the private IP address of the ECS instance. For more information about how to obtain the private IP address of an ECS instance, see View IP addresses.
- If the self-managed PostgreSQL instance resides in a data center, enter a private IP address of the data center.
Source Port The port that is used to connect to the self-managed PostgreSQL instance. You can run the netstat -a | grep PGSQL
command to view the port.Username The username of the account that is used to connect to the self-managed PostgreSQL instance. Enter migratetest
, which is the username of the account that you created in the Create an account for cloud migration on a self-managed PostgreSQL instance step.Password The password of the account that is used to connect to the self-managed PostgreSQL instance. Enter 123456
, which is the password of the account that you created in the Create an account for cloud migration on a self-managed PostgreSQL instance step. - Click Create Migration Assessment Task. Note During the cloud migration assessment, the status of the destination RDS instance changes to Maintaining Instance.After the cloud migration assessment is complete, you can view the status of the cloud migration assessment task on the Migration Assessment tab.
- If the value in the Status column of the cloud migration assessment task is Successful, you can start the cloud migration. For more information, see Step 2: Start the cloud migration.
- If the value in the Status column of the cloud migration assessment task is Failed, you can click View Report in the Actions column to view and handle the reported errors. For more information about common errors, see Introduction to cloud migration assessment reports.
After you handle the reported errors, you can click Re-access in the Actions column to run the cloud migration assessment task again.
Step 2: Start the cloud migration
- Access RDS Instances, select a region at the top, and then click the ID of the target RDS instance.
- In the left-side navigation pane, click Migrate to Cloud. On the page that appears, click the Migration to Cloud tab. On the tab that appears, click Create Cloud Migration Task.
- In the Create Cloud Migration Task dialog box, select the cloud migration assessment task whose status indicates a success in Step 1: Evaluate whether the data migration is allowed from the Associated Assessment Task drop-down list. Note After you select a cloud migration assessment task from the Associated Assessment Task drop-down list, ApsaraDB RDS automatically obtains the values of the Migration Source Type, Source IP/DNS, Source Port, and Username parameters. You do not need to manually configure these parameters.
- Click Initiate Migration to Cloud. ApsaraDB RDS automatically starts the cloud migration task. Important During the cloud migration, the status of the ApsaraDB RDS for PostgreSQL instance changes to Migrating Data In. You can read data from and write data to the self-managed PostgreSQL instance. However, do not perform operations such as migration, restart, or specification changes on the self-managed PostgreSQL instance.
- Switch the workloads of the self-managed PostgreSQL instance to the destination RDS instance.