Switching the master
In a failover Managed Service for Redis cluster with multiple hosts, you can switch the master role from the current master host to the replica host. After this operation, the current master host becomes the replica host of the new master.
It takes several minutes on average to switch, and the cluster is available during that time.
A sharded cluster contains one or more master hosts: one per shard. Switching the master for a sharded cluster is done for each shard one by one.
To switch the master in a non-sharded cluster:
- In the management console
, go to the folder containing the non-sharded cluster. - Select Managed Service for Redis.
- Click the name of the cluster you need and select the Hosts tab.
- Next to the host with the
MASTER
role, click and select Switch master host. - In the window that opens, select the I want to switch the master option and click Switch.
To switch the master in a sharded cluster:
- In the management console
, go to the folder containing the sharded cluster. - Select Managed Service for Redis.
- Click the name of the cluster you need and select the Hosts tab.
- Next to the host with the
MASTER
role, click and select Switch master host. - In the window that opens, click Switch.
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 switch the master in a non-sharded cluster, run the command:
yc managed-redis cluster start-failover \
--name <cluster_name>
To switch the master in a sharded cluster, run the command:
yc managed-redis cluster start-failover \
--name <cluster_name> \
--hostnames <current_master_name>
You can request the cluster name with a list of clusters in the folder and the name of the master host for the desired shard with a list of hosts in the cluster.
To switch the master, use the startFailover REST API method for the Cluster resource or the ClusterService/StartFailover gRPC API call and provide the following in the request:
- ID of the cluster where you want to switch the master in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - For a sharded cluster only: the name of the shard's current master in the
hostNames
parameter. To find out the name, get a list of hosts in the cluster.