All Products
Search
Document Center

ApsaraDB RDS:Update the pg_hba.conf file

Last Updated:Mar 25, 2024

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:

  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