When a system failure occurs, a PolarDB cluster can automatically switch over services from the primary node to a read-only node. You can also perform a manual switchover by specifying a read-only node as a new primary node.

Automatically switch over services between primary and read-only nodes

A PolarDB cluster of Cluster Edition uses an active-active cluster architecture that has high availability. This architecture supports automatic failovers between the primary node that supports reads and writes and the read-only nodes. The system automatically elects a new primary node.

Each node in a PolarDB cluster has a failover priority. This priority determines the probability at which a node is elected as the primary node during a failover. If multiple nodes have the same failover priority, they all have the same probability of being elected as the primary node.

The system performs the following steps to automatically elect a primary node:
  1. Find all the read-only nodes that can be elected as the primary node.
  2. Select one or more read-only nodes that have the highest failover priority.
  3. If the failover to the first node fails due to reasons, such as network issues and abnormal replication state, the system attempts to switch to another node until the failover succeeds.

In the Database Nodes section of the Overview page for the cluster, you can view and configure the failover priority of each node in the cluster.

Failover priorities of nodes

Manually switch over services between primary and read-only nodes

You can also perform a manual switchover by specifying a read-only node as a new primary node. For example, if you need to test the high availability of a cluster or specify a read-only node as a primary node, you can perform a manual switchover.

  1. Log on to the PolarDB console.
  2. In the upper-left corner of the console, select the region where the cluster is deployed.
  3. Find the cluster and click the cluster ID.
  4. In the Database Nodes section of the Overview page, click Switchover in the upper-right corner of the section to switch views.
  5. Click Switch Primary Node.
    1
  6. In the dialog box that appears, specify New Primary Node and click OK.
    Note If you do not specify New Primary Node, the system automatically elects the read-only node that has the highest failover priority as the primary node for the switchover. A transient connection may last for approximately 30 seconds during the switchover. Make sure that your application can automatically reconnect to the cluster.

Related operations

API Description
FailoverDBCluster Manually switches services between the primary node and a read-only node of a specified PolarDB cluster. You can specify a read-only node as the new primary node.