Help Center/ Relational Database Service/ User Guide/ Working with RDS for PostgreSQL/ Instance Modifications/ Manually Switching Between Primary and Standby DB Instances
Updated on 2024-10-14 GMT+08:00

Manually Switching Between Primary and Standby DB Instances

Scenarios

If you choose to create primary/standby DB instances, RDS will create a primary DB instance and a synchronous standby DB instance in the same region. You can access the primary DB instance only. The standby instance serves as a backup. You can manually promote the standby DB instance to the new primary instance for failover support.

Precautions

For primary/standby switchovers or other operations involving switchovers, such as instance class changes and minor version upgrades:

If there is any slow SQL statement still running during a primary/standby switchover, the slow SQL connection may be suspended (new connections and other idle connections are not affected). After a period of time, an error is returned to the client. The time when the error is reported is related to the settings of TCP parameters such as keepalives_idle, keepalives_interval, and keepalives_count on the client. For details, see the official documentation.

Constraints

You can switch the primary and standby instances only when the following conditions are met:

  • The primary/standby instance is running properly.
  • The primary/standby replication is normal.
  • The replication delay is less than 5 minutes, and the data on the primary and standby instances is consistent.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region.
  3. Click in the upper left corner of the page and choose Databases > Relational Database Service.
  4. On the Instances page, click the target primary/standby instance name to go to the Overview page.
  5. Under DB Instance Type, click Switch.

    A primary/standby switchover may cause a brief interruption of several seconds or minutes (depending on the replication delay). If transaction logs are generated at a speed higher than 30 MB/s, services will probably be interrupted for several minutes. To prevent traffic congestion, perform a switchover during off-peak hours.

  6. If you have enabled operation protection, click Send Code in the displayed Identity Verification dialog box and enter the obtained verification code. Then, click OK.

    Two-factor authentication improves the security of your account and cloud product. For details about how to enable operation protection, see the Identity and Access Management User Guide.

  7. In the displayed dialog box, click OK.
  8. After the switchover is successful, check the status of the DB instance on the Instances page.

    • During the switchover, the DB instance status is Switchover in progress.
    • In the upper right corner of the DB instance list, click to refresh the list. After the switchover is successful, the DB instance status will become Available.