Help Center/ Document Database Service/ User Guide/ Instance Modifications/ Changing Cluster Instance Nodes/ Manually Switching the Primary and Secondary Nodes of a Cluster
Updated on 2024-08-08 GMT+08:00

Manually Switching the Primary and Secondary Nodes of a Cluster

A cluster instance consists of a config node, and multiple dds mongos and shard nodes. Each shard or config is deployed as a three-node replica set including primary, secondary, and hidden nodes. Primary and secondary nodes do not provide IP addresses for external access. Hidden nodes are only used for backing up data. When a primary node becomes faulty, the system automatically selects a new primary node to ensure high availability. DDS supports primary/secondary switchovers for scenarios such as disaster recovery.

Precautions

  • To perform a switchover, the instance status needs to be Available, Abnormal, Changing to yearly/monthly, Changing a security group, or Heavy load.
  • The database connection may be interrupted during the switchover. Ensure that your client supports reconnection.
  • The longer the delay for primary/secondary synchronization, the more time is needed for a primary/secondary switchover. If the primary to secondary synchronization delay exceeds 300s, primary/secondary switchover is not supported. For details about the synchronization delay, see What Is the Time Delay for Primary/Secondary Synchronization in a Replica Set?

Performing a Primary/Secondary Switchover for a Config Node

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click in the upper left corner of the page and choose Databases > Document Database Service.
  4. On the Instances page, click the cluster instance name.
  5. In the Node Information area on the Basic Information page, click the config tab and click Switch in the Operation column.

    Figure 1 Primary/Secondary switchover

  6. In the displayed dialog box, click Yes.

    Figure 2 Performing a primary/secondary switchover for a config node

  7. Check the result.

    • During the switchover process, the DB instance status changes to Switchover in progress. After the switchover is complete, the status is restored to Available.
    • In the Node Information area, you can view the switchover result.
    • After the switchover, the previous primary node becomes the secondary node. You need to reconnect to the primary node. For details, see Connecting to a DB Instance.

Performing a Primary/Secondary Switchover for a Shard Node

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click in the upper left corner of the page and choose Databases > Document Database Service.
  4. On the Instances page, click the cluster instance name.
  5. In the Node Information area on the Basic Information page, click the shard tab, locate a target shard node, and choose More > Switch in the Operation column.

    Figure 3 Primary/Secondary switchover

  6. In the displayed dialog box, click Yes.

    Figure 4 Performing a primary/secondary switchover for a shard node

  7. Check the result.

    • During the switchover process, the DB instance status changes to Switchover in progress. After the switchover is complete, the status is restored to Available.
    • In the Node Information area, you can view the switchover result.
    • After the switchover, the previous primary node becomes the secondary node. You need to reconnect to the primary node. For details, see Connecting to a DB Instance.

Forcibly Promoting a Secondary Node to the Primary

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click in the upper left corner of the page and choose Databases > Document Database Service.
  4. On the Instances page, click the cluster instance name.
  5. In the Node Information area on the Basic Information page, click the config or shard tab, locate the node whose role is Secondary, and click Promote to Primary.

    Figure 5 Promote to Primary

  6. In the displayed dialog box, click Yes.

    Figure 6 Forcibly promoting a secondary node to the primary

  7. Check the result.

    • In the Node Information area on the Basic Information page, you can view the result.