Each shard and ConfigServer in an ApsaraDB for MongoDB sharded cluster instance has three nodes by default. The system automatically triggers a primary/secondary switchover on node failure. You can also manually trigger a switchover for scenarios such as disaster recovery drills.
Usage notes
-
Primary/secondary switchover is supported only for replica set and sharded cluster instances, not for standalone instances.
-
For a sharded cluster instance, the shard or ConfigServer undergoing the switchover must be in the Running state.
-
A primary/secondary switchover causes transient connection errors of up to 30 seconds. Perform this operation during off-peak hours and make sure that your application has a reconnection mechanism.
Procedure
-
Go to the MongoDB Sharded Cluster Instances page. At the top of the page, select a resource group and a region, and then click the ID of the target instance.
-
In the navigation pane on the left, click Service Availability.
-
Click Switch Role to the right of the target shard or ConfigServer component.
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.
-
Click OK.
The instance status changes to Switching Role. The switchover is complete when the status returns to Running.
NoteThe switchover takes about one minute.
-
Optional: To switch over other shard or ConfigServer components in the ApsaraDB for MongoDB sharded cluster instance, repeat these steps.
Related topics
Why does the high availability system trigger a primary/secondary switchover?
API reference
API | Description |
Switches the primary and secondary nodes of an ApsaraDB for MongoDB instance. |