Perform a primary/secondary switchover

更新时间:
复制 MD 格式

An ApsaraDB for MongoDB replica set instance has three nodes by default: a primary node and a secondary node that provide access endpoints, and a hidden node for high availability. You can use ApsaraDB for MongoDB to manually trigger a primary/secondary switchover for disaster recovery drills.

Background

  • Primary/secondary switchover is supported only for replica set and sharded cluster instances, not standalone instances.

  • A primary/secondary switchover causes a transient connection interruption of up to 30 seconds. Make sure your application supports automatic reconnection.

  • The instance must be in the Running state.

Procedure

  1. Go to the ApsaraDB for MongoDB Replica Set Instances page. At the top of the page, select a resource group and a region, and then click the target instance ID.

  2. In the navigation pane on the left, click Service Availability.

  3. Click Switch Role.

  4. In the Switch Role panel, select the two Roles to switch, and then select an option for Effective Time.

    • Effective Immediately: The switchover occurs immediately.

    • Effective Within Maintenance Window: The switchover occurs during the specified maintenance window. You can use the current maintenance window or select a new one from the Change Maintenance Window drop-down list.

  5. Click OK.

    The instance status changes to Switching Role. When the status returns to Running, the switchover is complete.

    Note
    • The instance status returns to Running in about one minute.

    • If your application connects directly to the primary node's endpoint, update the connection string to the new primary node's endpoint after the switchover. Otherwise, read and write operations may fail. For more information, see Connect to a replica set instance.

Related topics

Why does the high availability system trigger a primary/secondary switchover?

API reference

API

Description

SwitchDBInstanceHA

Switches the primary and secondary nodes of an ApsaraDB for MongoDB instance.