The cloud migration feature of ApsaraDB RDS for PostgreSQL allows you to migrate data
from a self-managed PostgreSQL instance that is deployed on an Elastic Compute Service
(ECS) instance or in a data center to an ApsaraDB RDS for PostgreSQL instance. This
topic describes how to update the pg_hba.conf file of the self-managed PostgreSQL
instance before a cloud migration to grant access from the CIDR block of the virtual
private cloud (VPC) to which the ApsaraDB RDS for PostgreSQL instance belongs.
Procedure
Note In this topic, the self-managed PostgreSQL instance and the ApsaraDB RDS for PostgreSQL
instance run PostgreSQL 13 in the CentOS 7 operating system.
- Log on to the server on which the self-managed PostgreSQL instance resides.
- Find the pg_hba.conf file.
Note Only the root user can run the following command.
find / -name pg_hba.conf
The following or similar command output is displayed:
/var/lib/pgsql/13/data/pg_hba.conf
- Go to the directory in which the pg_hba.conf file is stored.
cd /var/lib/pgsql/13/data/
- Run the
vim pg_hba.conf
command to enable the edit mode and add the following content to the pg_hba.conf file. # Migrate data over an internal network.
host all migratetest 172.21.XX.XX/16 md5
host replication migratetest 172.21.XX.XX/16 md5
# Migrate data over the Internet.
host all migratetest 121.41.XX.XX/32 md5
host replication migratetest 121.41.XX.XX/32 md5
The content contains the following parameters:
migratetest
: the account that is used to migrate data. For more information, see Create an account for cloud migration on a self-managed PostgreSQL instance.
172.21.XX.XX/16
or 121.41.XX.XX/32
: the VPC CIDR block or the public IP address of the RDS instance.
- To migrate data over an internal network, you must configure the VPC CIDR block of the RDS instance.
To view the VPC CIDR block, perform the following operations:
- 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 Self-managed ECS-based PostgreSQL Database or ApsaraDB RDS for PostgreSQL Instance or Self-managed PostgreSQL database in a data center (within the same VPC as the destination
database) and click Next.
- In the Configure Destination Database step of the configuration wizard, view the value of the VPC CIDR block parameter.

- Connect to the self-managed PostgreSQL instance and reload its configuration.
SELECT pg_reload_conf();
Sample output:
pg_reload_conf
----------------
t
(1 row)