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.

Note
  • 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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

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
  • Separate role IDs with commas (,). If this parameter is not specified, roles of the primary and secondary nodes are switched.
  • If the value of DBInstanceId is the ID of a sharded cluster instance, the roles to be switched must belong to one shard.
SwitchMode Integer No 0

The time when roles of the primary and secondary nodes are switched. Valid values:

  • 0: The roles are switched immediately.
  • 1: The roles are switched during the maintenance period.

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.