By default, each shard component and the ConfigServer component in an ApsaraDB for MongoDB sharded cluster instance contains three nodes. When a node fails, the high availability system of ApsaraDB for MongoDB 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 in scenarios such as routine disaster recovery drills.
Usage notes
A primary/secondary switchover can be triggered only for an ApsaraDB for MongoDB sharded cluster or replica set instance. You cannot trigger a primary/secondary switchover for an ApsaraDB for MongoDB standalone instance due to the architecture of the instance.
If you want to trigger a primary/secondary switchover for a shard component or the ConfigServer component in a sharded cluster instance, the shard component or the ConfigServer component must be in the running state.
Each time a primary/secondary switchover is triggered for an instance, the instance may be disconnected for approximately 30 seconds. We recommend that you perform this operation during off-peak hours and make sure that your applications can automatically reconnect to the instance.
Procedure
Go to the Sharded Cluster Instances page. In the top navigation bar, select the region in which the instance resides. Then, find the instance and click the ID of the instance.
In the left-side navigation pane of the instance details page, click Service Availability.
Click Switch Role in the Actions column of the shard or ConfigServer component for which you want to trigger a primary/secondary switchover.
In the Switch Role panel, select two roles and configure Effective At.
Effective Immediately: The system immediately performs a primary/secondary switchover.
Effective Within Maintenance Window:The system performs a 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. The switchover is successful when the instance status changes back to Running.
NoteThe switchover takes about one minute. Then, the instance returns to normal.
Optional: If you want to trigger a primary/secondary switchover for other shard components in the ApsaraDB for MongoDB sharded cluster instance, repeat the preceding operations.
FAQ
Why does the high availability system of ApsaraDB for MongoDB trigger a primary/standby switchover?
Related API operations
Operation | Description |
Switches the primary and secondary nodes for an ApsaraDB for MongoDB instance. |