Each shard and ConfigServer component in an ApsaraDB for MongoDB sharded cluster instance contains three nodes by default. If a node fails, the high availability (HA) system automatically triggers a primary/secondary switchover to maintain service availability. You can also trigger a primary/secondary switchover manually for purposes such as disaster recovery drills.
Prerequisites
The instance is an ApsaraDB for MongoDB replica set or sharded cluster instance. Primary/secondary switchover is not supported for standalone instances due to their single-node architecture.
The shard or ConfigServer component that you want to switch over is in the Running state.
Impact
A primary/secondary switchover causes a transient connection error of up to 30 seconds. To minimize the impact on your workloads:
Perform the switchover during off-peak hours.
Make sure your application has a reconnection mechanism.
Procedure
Log on to the ApsaraDB for MongoDB console and 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 left-side navigation pane, click Service Availability.
Find the target shard or ConfigServer component and click Switch Role to the right of it.
In the Switch Role panel, select the Roles to switch and configure the Effective At parameter.
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 use the current maintenance window or specify a different one from the Change Maintenance Window drop-down list.
Click OK.
The instance status changes to Switching Role. The switchover completes in about one minute, after which the status returns to Running.
(Optional) To perform a primary/secondary switchover for other shard or ConfigServer components in the instance, repeat the preceding steps.
Related questions
Why does the high availability system trigger a primary/secondary switchover?
Related APIs
API | Description |
Switches the primary and secondary nodes for an ApsaraDB for MongoDB instance. |