By default, each shard and ConfigServer component in an ApsaraDB for MongoDB sharded cluster instance contains three nodes. When a node fails, the high availability (HA) system automatically triggers a primary/secondary switchover to ensure overall availability. You can also manually trigger a primary/secondary switchover for an ApsaraDB for MongoDB instance for scenarios such as disaster recovery drills.
Usage notes
Primary/secondary switchover is supported only for ApsaraDB for MongoDB replica set and sharded cluster instances. This feature is not supported for standalone instances because of their architecture.
The shard or ConfigServer component for which you want to trigger a primary/secondary switchover must be in the Running state.
A primary/secondary switchover causes a transient connection error that lasts for up to 30 seconds. Perform this operation during off-peak hours and ensure that your application has a reconnection mechanism.
Procedure
Go to the MongoDB Sharded Cluster Instances page. In the top navigation bar, select a resource group and a region. 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 two roles and configure Effective At.
Effective Immediately: The system immediately performs primary/secondary switchover.
Effective Within Maintenance Window:The system performs primary/secondary switchover within the specified maintenance window. You can select the current maintenance window or specify a custom maintenance window in the Change Maintenance Window drop-down list.
Click OK.
The instance status changes to Switching Role. When the status changes to Running, the switchover is successful.
NoteThe switchover is complete in about one minute, and the instance status returns to Running.
Optional: To trigger a primary/secondary switchover for other shard or ConfigServer components in the ApsaraDB for MongoDB sharded cluster instance, repeat the preceding steps.
FAQ
Why does the high availability system of ApsaraDB for MongoDB trigger primary/standby switchover?
Related API operations
Operation | Description |
Switches the primary and secondary nodes for an ApsaraDB for MongoDB instance. |