Managing Redis cluster hosts
You can add and remove cluster hosts and manage their settings. For information about moving cluster hosts to a different availability zone, see this guide.
Getting a list of cluster hosts
- Go to the folder page
and select Managed Service for Redis. - Click the cluster name and select the Hosts tab.
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 get a list of cluster hosts, run the command:
yc managed-redis host list \
--cluster-name=<cluster_name>
Result:
+---------------------------------+----------------------+------------+---------+--------+-------------------+
| NAME | CLUSTER ID | SHARD NAME | ROLE | HEALTH | ZONE ID |
+---------------------------------+----------------------+------------+---------+--------+-------------------+
| rc1a-...caf.mdb.yandexcloud.net | c9qb2q230gg1******** | shard1 | MASTER | ALIVE | ru-central1-a |
| rc1b-...bgc.mdb.yandexcloud.net | c9qb2q230gg1******** | shard1 | REPLICA | ALIVE | ru-central1-b |
+---------------------------------+----------------------+------------+---------+--------+-------------------+
You can request the cluster name with a list of clusters in the folder.
To get a list of cluster hosts, use the listHosts REST API method for the Cluster resource or the ClusterService/ListHosts gRPC API call and provide the cluster ID in the clusterId
request parameter.
To find out the cluster ID, get a list of clusters in the folder.
Creating a host
The number of hosts in Managed Service for Redis clusters is limited by the CPU and RAM quotas available to DB clusters in your cloud. To check the resources in use, open the Quotas
Note
Public access to hosts can only be configured for clusters created with enabled TLS support.
To create a host:
- Go to the folder page
and select Managed Service for Redis. - Click the cluster name and go to the Hosts tab.
- Click Create host.
- Specify the host parameters:
-
Availability zone.
-
Subnet (if the required subnet is not on the list, create it).
-
If necessary, configure public access to the host.
-
If you are adding a host to a sharded cluster, select a shard.
-
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 create a host:
-
Request a list of cluster subnets to select one for the new host:
yc vpc subnet list
Result:
+----------------------+-----------+-----------------------+---------------+------------------+ | ID | NAME | NETWORK ID | ZONE | RANGE | +----------------------+-----------+-----------------------+---------------+------------------+ | b0cl69a2b4c6******** | default-d | enp6rq72rndgr******** | ru-central1-d | [172.16.0.0/20] | | e2lkj9qwe762******** | default-b | enp6rq72rndgr******** | ru-central1-b | [10.10.0.0/16] | | e9b0ph42bn96******** | a-2 | enp6rq72rndgr******** | ru-central1-a | [172.16.32.0/20] | | e9b9v22r88io******** | default-a | enp6rq72rndgr******** | ru-central1-a | [172.16.16.0/20] | +----------------------+-----------+-----------------------+---------------+------------------+
If the required subnet is not in the list, create it.
-
View a description of the CLI command for adding a host:
yc managed-redis host add --help
-
Run the add host command:
yc managed-redis host add \ --cluster-name=<cluster_name> \ --host zone-id=<availability_zone>,` `subnet-id=<subnet_ID>,` `assign-public-ip=<public_access>,` `replica-priority=<host_priority>,` `shard-name=<shard_name>
Where:
--cluster-name
: Name of a Managed Service for Redis cluster. You can retrieve it with a list of clusters in a folder.--host
: Host parameters:zone-id
: Availability zone.subnet-id
: Subnet ID. Specify if two or more subnets are created in the selected availability zone.assign-public-ip
: Internet access to the host via a public IP address,true
orfalse
.replica-priority
: Priority for assigning the host as a master if the primary master fails. It is only available for non-sharded clusters.shard-name
: Name of the shard in which the host must be created if the cluster is sharded.
To create a host:
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about how to create this file, see Creating clusters.
-
Add the
host
block to the Managed Service for Redis cluster description.resource "yandex_mdb_redis_cluster" "<cluster_name>" { ... host { zone = "availability_zone>" subnet_id = <subnet_ID> assign_public_ip = <public_access> replica_priority = <host_priority> shard_name = "<shard_name>" } }
Where
assign_public_ip
is public access to the host,true
orfalse
. -
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
For more information, see the Terraform provider documentation
Time limits
A Terraform provider sets the timeout for Managed Service for Redis cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts
block to the cluster description, for example:
resource "yandex_mdb_redis_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # 1 hour 30 minutes
update = "2h" # 2 hours
delete = "30m" # 30 minutes
}
}
To add a host, use the addHosts REST API method for the Cluster resource or the ClusterService/AddHosts gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - New host settings in one or more
hostSpecs
parameters.
Warning
If you cannot connect to the host you added, check that the cluster security group is configured correctly for the host's subnet.
Changing a host
Note
Access to hosts from the Internet via public IP addresses is possible only if the cluster has been created with TLS support enabled.
To change the parameters of the cluster host:
-
Go to the folder page
and select Managed Service for Redis. -
Click the cluster name and open the Hosts tab.
-
Click
in the required host row and select Edit. -
Set new settings for the host:
- Enable Public access if the host must be accessible from outside Yandex Cloud.
- Specify the priority for assigning the host as a master.
-
Click Save.
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 the parameters of the host, run the command:
yc managed-redis host update <host_name> \
--cluster-name=<cluster_name> \
--assign-public-ip=<public_access> \
--replica-priority=<host_priority>
Where --assign-public-ip
is public access to the host, true
or false
.
You can request the host name with a list of cluster hosts, and the cluster name, with a list of clusters in the folder.
To change the parameters of the cluster host:
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about how to create this file, see Creating clusters.
-
In the Managed Service for Redis cluster description, change the attributes of the
host
block corresponding to the host you are updating.resource "yandex_mdb_redis_cluster" "<cluster_name>" { ... host { zone = "availability_zone>" subnet_id = <subnet_ID> assign_public_ip = <public_access> replica_priority = <host_priority> shard_name = "<shard_name>" } }
Where
assign_public_ip
is public access to the host,true
orfalse
. -
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
For more information, see the Terraform provider documentation
To update host parameters, use the updateHosts REST API method for the Cluster resource or the ClusterService/UpdateHosts 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 host. To find out the cluster ID, get a list of clusters in the folder. - In the
updateHostSpecs.hostName
parameter, the name of the host you want to change. To find out the name, get a list of hosts in the cluster. - Host public access settings as
updateHostSpecs.assignPublicIp
. - Host priority in the
updateHostSpecs.replicaPriority
parameter. - List of cluster configuration fields to update in the
UpdateMask
parameter.
Warning
This API method overrides all parameters of the object being modified that were not explicitly passed in the request to the default values. To avoid this, list the settings you want to change in the updateMask
parameter (one line separated by commas).
Warning
If you cannot connect to the host you added, check that the cluster security group is configured correctly for the host's subnet.
Removing a host
You can remove a host from a Redis cluster if it is not the only host in it. To replace a single host, first create a new host and then remove the old one.
If the host is the master when deleted, Managed Service for Redis automatically assigns another replica as the master.
If the number of hosts in a cluster or cluster shard is equal to the minimum value, you cannot delete the host. For more information, refer to Quotas and limits.
To remove a host from a cluster:
- Go to the folder page
and select Managed Service for Redis. - Click the cluster name and open the Hosts tab.
- In the appropriate cluster row, click
and select Delete. - In the window that opens, enable Delete host and click Confirm.
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 remove a host from the cluster, run:
yc managed-redis host delete <host_name> \
--cluster-name=<cluster_name>
You can request the host name with a list of cluster hosts, and the cluster name, with a list of clusters in the folder.
To remove a host from a cluster:
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about how to create this file, see Creating clusters.
-
Delete the
host
block from the Managed Service for Redis cluster description. -
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Type
yes
and press Enter.-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
For more information, see the Terraform provider documentation
Time limits
A Terraform provider sets the timeout for Managed Service for Redis cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts
block to the cluster description, for example:
resource "yandex_mdb_redis_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # 1 hour 30 minutes
update = "2h" # 2 hours
delete = "30m" # 30 minutes
}
}
To delete a host, use the deleteHosts REST API method for the Cluster resource or the ClusterService/DeleteHosts gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - Name(s) of the host(s) to delete in the
hostNames
parameter.