This topic describes how to switch over services between the primary and read-only nodes of an ApsaraDB for PolarDB cluster. Each PolarDB cluster consists of one primary node and one or more read-only nodes. The system can automatically switch over services from the primary mode to a read-only node. Alternatively, you can perform a manual switchover by specifying a read-only node as the new primary node. A manual switchover is used to verify high availability or when you require a specific read-only node to serve as primary.

Manually switch over services between primary and read-only nodes

  1. Log on to the ApsaraDB for PolarDB console.
  2. In the upper-left corner of the ApsaraDB for PolarDB console, select the region where the cluster resides.
  3. Find the target PolarDB cluster and click the cluster ID.
  4. In the Node Information page, click Switch Primary Node.
    Node information
  5. In the dialog box that appears, select the read-only node that you want to promote as primary from the New Primary Node drop-down list, and click Confirm.
    Switchover between primary and read-only nodes
    Note If you do not select a read-only node from the New Primary Node drop-down list, the system promotes the read-only node with the highest failover priority as primary. There may be a 30-second transient disconnection during the switchover. Make sure that you application can automatically reconnect to the PolarDB cluster.

Automatically switch over services between primary and read-only nodes

ApsaraDB for PolarDB uses an active-active high-availability cluster architecture. This architecture allows for automatic failovers between primary and read-only nodes.

Each node in an ApsaraDB for PolarDB cluster has a failover priority, which determines the probability that the system promotes this node as primary in the event of a failover. If multiple nodes have the same failover priority, they all have the same probability of being promoted as the primary node.

The system performs the following procedure to select a read-only node:
  1. Find all read-only nodes that can be promoted as primary.
  2. Select one or more read-only nodes that have the highest failover priority.
  3. If the failover to the selected read-only node fails due to exceptions such as network or replication faults, another read-only node is promoted as the primary node based on its failover priority until the failover succeeds.

Related operations

API operation Description
FailoverDBCluster Manually switches over services from the primary node to a specified read-only node in an ApsaraDB for PolarDB cluster.