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 thePRIMARY
host row 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 <current_primary_replica_name> \
--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:
- ID of the cluster where you want to switch the primary replica in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - Name of the current primary replica in the
hostNames
parameter. To find out the name, get a list of hosts in the cluster.