This topic describes how to perform a switchover. A PolarDB cluster consists of one primary node and one or more read-only nodes. If a failure occurs on the primary node, the system can automatically perform a failover. You can also perform a manual switchover by promoting a read-only node to a new primary node. For example, if you need to test the high availability of a cluster or specify a read-only node to a primary node, you can perform a manual switchover.

Considerations

A transient connection error may occur for approximately 30 seconds during a switchover in PolarDB clusters. We recommend that you perform the switchover during off-peak hours and make sure that your application can automatically reconnect to the PolarDB cluster.

Manual switchover

  1. Log on to the PolarDB console.
  2. In the upper-left corner of the page, select the region where the PolarDB cluster is located.
    Select the region where the cluster is located.
  3. Find the target cluster and click the cluster ID.
  4. On the Overview page, click Switch Primary Node in the Database Nodes section.
  5. In the Switch Primary Node dialog box, select a new primary node from the New Primary Node drop-down list and click OK.
    Note If you do not select a new primary node from the New Primary Node drop-down list, the system automatically promotes a read-only node that has the highest failover priority to the new primary node. A transient connection error may occur for approximately 30 seconds during a switchover. Make sure that your application can automatically reconnect to the cluster.
    The Switch Primary Node dialog box

Automatic failover

PolarDB clusters run in an active-active high-availability architecture. This architecture supports automatic failovers between the primary node and read-only nodes. The system automatically selects a new primary node.

Each node in a cluster has a failover priority. This priority determines the probability that the system promotes the node to the primary node if a failover occurs. If multiple nodes have the same failover priority, they all have the same probability of being promoted to the primary node.

The system performs the following steps to promote a read-only node to the primary node:

  1. Find all the read-only nodes that can be promoted to the primary node.
  2. Select one or more read-only nodes that have the highest failover priority.
  3. If the first node fails to be promoted to the primary node due to network or replication errors, the system attempts to promote the next available node. The system continues this process until the failover is successful.

Related API operations

API Description
FailoverDBCluster Performs a manual switchover by promoting a read-only node to a new primary node in your PolarDB cluster.