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.
  1. Log on to the server on which the self-managed PostgreSQL instance resides.
  2. 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
  3. Go to the directory in which the pg_hba.conf file is stored.
    cd /var/lib/pgsql/13/data/
  4. 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
    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: the VPC CIDR block of the RDS instance.
      To view the VPC CIDR block, perform the following operations:
      1. Access RDS Instances, select a region at the top, and then click the ID of the target RDS instance.
      2. In the left-side navigation pane, click Database Connection. On the page that appears, view the value of the Netword segment parameter. VPC网段
  5. Connect to the self-managed PostgreSQL instance and reload its configuration.
    SELECT pg_reload_conf();
    Sample output:
     pg_reload_conf
    ----------------
     t
    (1 row)

What to do next

Configure the firewall of the server on which a self-managed PostgreSQL instance resides