All Products
Search
Document Center

ApsaraDB RDS:Disaster recovery instance preparation

Last Updated:Jun 20, 2026

Before creating a disaster recovery instance, ensure network connectivity between the source and destination instances. You must also create a synchronization account and configure the necessary files on the source instance. This topic uses a self-managed PostgreSQL database on an ECS instance as an example to describe these preparations.

Prerequisites

Create a destination ApsaraDB RDS for PostgreSQL instance that meets the following requirements. For more information, see Create an ApsaraDB RDS for PostgreSQL instance.

  • The major engine version of the instance is the same as that of the source instance.

  • The instance is a primary instance. Read-only instances cannot be used as disaster recovery instances.

  • The billing method must be pay-as-you-go or subscription. Serverless instances are not supported.

  • The instance must be empty. Its available storage must be greater than or equal to the total data size of the source database.

Establish network connectivity

Network connectivity solutions

Source instance type

Network connectivity method

Self-managed database in an on-premises data center

Express Connect, VPN Gateway, Smart Access Gateway, or Cloud Enterprise Network (CEN).

Self-managed database on another cloud platform

Smart Access Gateway, Cloud Enterprise Network (CEN), or Internet NAT Gateway.

Self-managed database on an Alibaba Cloud ECS instance

Cloud Enterprise Network (CEN) or Internet NAT Gateway.

Note

If the ECS instance and the destination ApsaraDB RDS for PostgreSQL instance are in the same VPC, you do not need to establish network connectivity.

Managed database service on another cloud platform

Smart Access Gateway, Cloud Enterprise Network (CEN), or Internet NAT Gateway.

ApsaraDB RDS for PostgreSQL

Cloud Enterprise Network (CEN) or Internet NAT Gateway.

Note

If the source and destination ApsaraDB RDS for PostgreSQL instances are in the same VPC, you do not need to establish network connectivity.

If the source instance supports public access, you can use an Internet NAT Gateway to establish connectivity between the source instance and the VPC of the destination instance. This topic describes how to configure the Internet NAT Gateway for the destination ApsaraDB RDS for PostgreSQL instance.

If your source instance does not support public access, use Cloud Enterprise Network (CEN) to establish network connectivity. For more information, see Use CEN to establish network connectivity.

Configure the destination NAT gateway

  1. Log on to the ApsaraDB RDS console and 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 instance ID.

  2. In the navigation pane on the left, click Database Connection. On the Database Connection page, view the VPC and vSwitch of the destination instance.

    Hover over the VPC ID to view the vSwitch ID.

  3. Click the VPC ID to go to the VPC console.

  4. On the Resource Management tab, find the Access to Internet section. Hover over Internet NAT Gateway and click Create Now.

  5. On the creation page, configure the following options and click Buy Now.

    Configuration

    Description

    Billing Method

    The default value is Pay-As-You-Go. You are charged for the resources that you use. For more information, see NAT Gateway billing.

    Instance Name

    Set a name for the Internet NAT Gateway instance.

    The name must be 2 to 128 characters in length, start with a letter or a Chinese character, and can contain digits, underscores (_), and hyphens (-).

    Region

    Select the region of the destination ApsaraDB RDS for PostgreSQL instance.

    Resource Group

    Select the resource group to which the VPC belongs. For more information, see What is a resource group?

    Network and Zone

    Select the VPC and vSwitch of the destination ApsaraDB RDS for PostgreSQL instance.

    Network Type

    Select Internet NAT Gateway.

    EIP

    Select an elastic IP address (EIP). If you have not purchased an EIP, see Purchase an Internet NAT gateway and an EIP in one-stop mode for a VPC.

  6. On the Confirm Order page, confirm the configuration of the Internet NAT Gateway and click Enable Now.

Configure the source instance

Step 1: Create a synchronization account

The source instance requires a database account for synchronization. This account is known as the synchronization account.

  1. Connect to the source PostgreSQL instance, create a synchronization account, and set the required permissions. For example, create a synchronization account named replicatoraccount.

    CREATE ROLE replicatoraccount CREATEROLE REPLICATION LOGIN PASSWORD 'your_password';
  2. Grant the pg_monitor permission to the synchronization account replicatoraccount.

    GRANT pg_monitor TO replicatoraccount;
  3. Connect to the source PostgreSQL instance by using the created synchronization account replicatoraccount and run the following SQL statements to verify that the account has the required permissions.

    1. Run the following SQL statement to create a test user named testreplicator with the REPLICATION permission. If the user is created, the replicatoraccount synchronization account has the required replication permission.

      CREATE USER testreplicator WITH REPLICATION;

      If an error similar to must be superuser to create replication users occurs, use an account that has the SUPERUSER permission to connect to the source instance and grant the SUPERUSER permission to the synchronization account replicatoraccount. For example, run the ALTER USER replicatoraccount WITH SUPERUSER; command.

    2. Delete the test user testreplicator.

      DROP USER IF EXISTS testreplicator;

Step 2: Configure the ECS security group

  1. Log on to the ECS console.

  2. In the navigation pane on the left, choose Instances & Images > > > Instance.

  3. In the top navigation bar, select a region.

  4. Find the destination ECS instance and click the instance ID.

  5. On the Security Group tab, click the name of the security group.

  6. On the Security Group Details page, go to the Access Rules section. On the Inbound tab, click Manually Add. Add the following security group rules.

    The following table describes the security group rules and key parameters.

    Protocol type

    Port range

    Authorization object

    All ICMP (IPv4)

    Source: -1/-1

    Destination: -1/-1

    The elastic IP address (EIP) of the Internet NAT Gateway, created in the "Establish network connectivity" step.

    Note

    On the details page of the destination Internet NAT Gateway, you can view the EIP on the Associated EIP tab.

    TCP

    The port of the self-managed PostgreSQL database on the ECS instance. You can run the netstat -a | grep PGSQL command to view the port.

Step 3: Configure the pg_hba.conf file

Note

These steps use PostgreSQL 13 on CentOS 7 as an example.

  1. Log on to the ECS instance that hosts the self-managed PostgreSQL database. For more information, see Remotely connect to an ECS instance.

  2. Find the location of the pg_hba.conf file.

    Note

    Run this command as the root user.

    find / -name pg_hba.conf

    Sample output:

    /var/lib/pgsql/13/data/pg_hba.conf
  3. Go to the directory of the pg_hba.conf file.

    cd /var/lib/pgsql/13/data/
  4. Edit the pg_hba.conf file and append the following lines.

    host  all    replicatoraccount  121.XX.XX.XX/32  md5
    host  replication  replicatoraccount  121.XX.XX.XX/32  md5

    Key parameters:

    • replicatoraccount: The synchronization account that you created. For more information, see Step 1: Create a synchronization account.

    • 121.XX.XX.XX: The EIP of the Internet NAT Gateway that is created for the destination ApsaraDB RDS for PostgreSQL instance when you establish network connectivity.

      Note

      On the details page of the destination Internet NAT Gateway, you can view the EIP on the Associated EIP tab.

  5. Connect to the source PostgreSQL instance and reload the configuration to apply the changes.

    SELECT pg_reload_conf();

    Sample output:

     pg_reload_conf
    ----------------
     t
    (1 row)

Step 4: Configure the postgresql.conf file

For more information, see Configure the postgresql.conf file.

Step 5: Configure the server firewall

For more information, see Configure the server firewall.