Selecting a different primary replica
If a cluster has several replicas, you can select a different primary replica (master) as required.
Switching takes on average less than a minute. The cluster may be unavailable for writing for several seconds while switching is taking place.
For more information about selecting a different primary replica, see the MongoDB documentation
- Go to the folder page
and select Managed Service for MongoDB. - Click the cluster name and open the Hosts tab.
- Click
in the row of thePRIMARY
host and select Step down.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change a cluster's primary replica, run the command:
yc managed-mongodb hosts stepdown <name_of_current_primary_replica> \
--name=<cluster_name>
You can request the name of the shard primary replica with a list of cluster hosts and the cluster name with a list of clusters in the folder.
To switch to a different primary replica, use the stepdownHosts REST API method for the Cluster resource or the ClusterService/StepdownHosts gRPC API call and provide the following in the request:
- In the
clusterId
parameter, the ID of the cluster where you want to change the primary replica. To find out the cluster ID, get a list of clusters in the folder. - In the
hostNames
parameter, the name of the current primary replica. To find out the name, get a list of hosts in the cluster.