An Apsara PolarDB cluster consists of one writer node and one or more reader nodes. This topic describes how to switch your workloads from a writer node to a reader node. If a failure occurs on a writer node, the system can automatically perform a failover. You may want to manually switch your workloads from the writer node to a reader node to run a disaster recovery drill and to specify a certain reader node as the writer node.

Considerations

An Apsara PolarDB cluster may be disconnected for approximately 30 seconds during switchover. We recommend that you perform the switchover during off-peak hours and make sure that your application can automatically reconnect to the Apsara 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. In the upper-right corner of the Node Information section, click Switch Primary Node.
    Switch workloads from writer nodes to reader nodes
  5. In the Switch Primary Node dialog box that appears, select a new writer node from the New Primary Node drop-down list, and click OK.
    Note If you do not select a new writer node from the New Primary Node drop-down list, the system automatically promotes a reader node with the highest failover priority to the new writer node. The cluster may be disconnected for approximately 30 seconds during switchover. Make sure that your application can automatically reconnect to the cluster.
    Switchover dialog box

Automatic failover between the writer node and reader nodes

An Apsara PolarDB cluster runs in an active-active high-availability architecture. This architecture allows for automatic failovers between the writer node and reader nodes.

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

The system follows these steps the to promote a reader node to the writer node:

  1. Find all reader nodes that can be promoted to the writer node.
  2. Select one or more reader nodes that have the highest failover priority.
  3. If the failover to the first node fails due to network or replication errors, the system tries to switch the workloads to the next available node. The system continues the failover until one of the available nodes is promoted to the writer node.

Related API operations

Operation Description
FailoverDBCluster Manually switches your workloads from the writer node to a specified reader node in an Apsara PolarDB cluster.