You can call this operation to switch between the primary and secondary nodes in an ApsaraDB for MongoDB instance.
The instance must be in the running state when you call this operation.
- This operation is applicable to replica set instances and sharded cluster instances, but cannot be performed on standalone instances.
- On replica set instances, the switch is performed between instances. On sharded cluster instances, the switch is performed between shards.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | SwitchDBInstanceHA |
The operation that you want to perform. Set the value to SwitchDBInstanceHA. |
DBInstanceId | String | Yes | dds-bpxxxxxxxx |
The ID of the instance. |
RegionId | String | No | cn-hangzhou |
The ID of the region where the instance is deployed. You can call the DescribeRegions operation to query the region ID. |
NodeId | String | No | d-bpxxxxxxxx |
The ID of the shard in the sharded cluster instance. Note You must specify this parameter if the value of DBInstanceId is the ID of a sharded cluster instance.
|
RoleIds | String | No | 972xxxx,972xxxx |
The IDs of the roles that you want to switch. You can call the DescribeRoleZoneInfo operation to query IDs of roles and roles of nodes. Note
|
SwitchMode | Integer | No | 0 |
The time when roles of the primary and secondary nodes are switched. Valid values:
|
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 26BD4E5F-BDB4-47BA-B232-413AA78CFA8F |
The ID of the request. |
Examples
Sample requests
http(s)://mongodb.aliyuncs.com/? Action=SwitchDBInstanceHA
&DBInstanceId=dds-bpxxxxxxxx
&<Common request parameters>
Sample success responses
XML
format
<SwitchDBInstanceHAResponse>
<RequestId>26BD4E5F-BDB4-47BA-B232-413AA78CFA8F</RequestId>
</SwitchDBInstanceHAResponse>
JSON
format
{
"RequestId": "26BD4E5F-BDB4-47BA-B232-413AA78CFA8F"
}
Error codes
For a list of error codes, visit the API Error Center.