Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex Managed Service for Redis
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Information about existing clusters
    • Creating clusters
    • Changing cluster and database settings
    • Connecting to a database
    • Stopping and starting clusters
    • Updating a Redis version
    • Managing hosts in a cluster
    • Managing shards
    • Managing backups
    • Switching the master
    • Monitoring the state of clusters and hosts
    • Viewing cluster logs
    • Deleting clusters
  • Tutorials
  • Concepts
  • Access management
  • Pricing policy
  • API reference
  • Revision history
  • Questions and answers
  1. Step-by-step instructions
  2. Managing hosts in a cluster

Managing Redis cluster hosts

Written by
Yandex Cloud
  • Getting a list of cluster hosts
  • Adding a host
  • Changing a host
  • Removing a host

You can add and remove cluster hosts and manage their settings.

Getting a list of cluster hosts

Management console
CLI
API
  1. Go to the folder page and select Managed Service for Redis.
  2. Click on the name of the cluster you need and select the Hosts tab.

If you don't 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 | c9qb2...0gg  | shard1     | MASTER  | ALIVE  | ru-central1-a |
| rc1b-...bgc.mdb.yandexcloud.net | c9qb2...0gg  | shard1     | REPLICA | ALIVE  | ru-central1-b |
+----------------------------+--------------+------------+---------+--------+-------------------+

The cluster name can be requested with a list of clusters in the folder.

Use the listHosts API method and pass the cluster ID in the clusterId request parameter.

To find out the cluster ID, get a list of clusters in the folder.

Adding 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 page and find Managed Databases.

Note

Public access to hosts can only be configured for clusters created with enabled TLS support.

Management console
CLI
Terraform
API

To add a host to the cluster:

  1. Go to the folder page and select Managed Service for Redis.
  2. Click on the name of the cluster you need and go to the Hosts tab.
  3. Click Add host.
  4. 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 don't 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 add a host to the cluster:

  1. Request a list of cluster subnets to select one for the new host:

    yc vpc subnet list
    

    Result:

    +-----------+-----------+------------+-------------------+------------------+
    |     ID    |   NAME    | NETWORK ID |       ZONE        |      RANGE       |
    +-----------+-----------+------------+-------------------+------------------+
    | b0cl69... | default-c | enp6rq7... | ru-central1-c | [172.16.0.0/20]  |
    | e2lkj9... | default-b | enp6rq7... | ru-central1-b | [10.10.0.0/16]   |
    | e9b0ph... | a-2       | enp6rq7... | ru-central1-a | [172.16.32.0/20] |
    | e9b9v2... | default-a | enp6rq7... | ru-central1-a | [172.16.16.0/20] |
    +-----------+-----------+------------+-------------------+------------------+
    

    If the necessary subnet is not in the list, create it.

  2. View a description of the CLI command for adding a host:

    yc managed-redis host add --help
    
  3. 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 host access: true or false>,`
             `replica-priority=<host priority>,`
             `shard-name=<shard name>
    

    Where:

    • --cluster-name is the 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. It must be specified if the selected availability zone includes two or more subnets.
      • assign-public-ip indicates whether the host is reachable from the internet over a public IP address.
      • replica-priority: Priority for selecting the host as a master if the primary master fails. Only available for unsharded clusters.
      • shard-name: Name of the shard to which the host must be added if the cluster is sharded.

To add a host to the cluster:

  1. Open the current Terraform configuration file with an infrastructure plan.

    For more information about creating this file, see Creating Redis clusters.

  2. Add a 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 host access: true or false>
        replica_priority = <host priority>
        shard_name       = "<shard name>"
      }
    }
    
  3. Make sure the settings are correct.

    1. Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.

    2. Run the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

  4. Confirm the update of resources.

    1. 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.

    2. If you are happy with the planned changes, apply them:

      1. Run the command:

        terraform apply
        
      2. Confirm the update of resources.

      3. Wait for the operation to complete.

For more information, see the Terraform provider documentation.

Warning

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
  }
}

Use the addHosts API method and pass the following in the request:

  • The 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 can't connect to the added host, check that the cluster's security group is configured correctly for the subnet where you placed the host.

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.

Management console
CLI
Terraform
API

To change the parameters of the cluster host:

  1. Go to the folder page and select Managed Service for Redis.
  2. Click on the name of the cluster you want and select the Hosts tab.
  3. Click the icon in the same row as the desired host and select Edit.
  4. Enable Public access if a host must be accessible from outside Yandex Cloud.
  5. Click Save.

If you don't 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 host access: true or false> \
   --replica-priority=<host priority>

The host name can be requested with a list of cluster hosts, and the cluster name can be requested with a list of clusters in the folder.

To change the parameters of the cluster host:

  1. Open the current Terraform configuration file with an infrastructure plan.

    For more information about creating this file, see Creating Redis clusters.

  2. In the Managed Service for Redis cluster description, change the attributes of the host block corresponding to the host to update.

    resource "yandex_mdb_redis_cluster" "<cluster name>" {
      ...
      host {
        zone             = "<availability zone>"
        subnet_id        = "<subnet ID>"
        assign_public_ip = <public host access: true or false>
        replica_priority = <host priority>
        shard_name       = "<shard name>"
      }
    }
    
  3. Make sure the settings are correct.

    1. Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.

    2. Run the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

  4. Confirm the update of resources.

    1. 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.

    2. If you are happy with the planned changes, apply them:

      1. Run the command:

        terraform apply
        
      2. Confirm the update of resources.

      3. Wait for the operation to complete.

For more information, see the Terraform provider documentation.

To change the parameters of the host, use the updateHosts API method and pass the following in the query:

  • 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, request 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 can't connect to the added host, check that the cluster's security group is configured correctly for the subnet where you placed the host.

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.

Management console
CLI
Terraform
API

To remove a host from a cluster:

  1. Go to the folder page and select Managed Service for Redis.
  2. Click on the name of the cluster you want and select the Hosts tab.
  3. In the row next to the appropriate cluster, click and select Delete.
  4. In the window that opens, check Delete host and click Confirm.

If you don't 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>

The host name can be requested with a list of cluster hosts, and the cluster name can be requested with a list of clusters in the folder.

To remove a host from a cluster:

  1. Open the current Terraform configuration file with an infrastructure plan.

    For more information about creating this file, see Creating Redis clusters.

  2. Delete the host block from the Managed Service for Redis cluster description.

  3. Make sure the settings are correct.

    1. Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.

    2. Run the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

  4. Type the word yes, then press Enter.

    1. 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.

    2. If you are happy with the planned changes, apply them:

      1. Run the command:

        terraform apply
        
      2. Confirm the update of resources.

      3. Wait for the operation to complete.

For more information, see the Terraform provider documentation.

Warning

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
  }
}

Use the deleteHosts API method and pass the following in the request:

  • The cluster ID in the clusterId parameter. To find out the cluster ID, get a list of clusters in the folder.
  • The name(s) of the host(s) to delete, in the hostNames parameter.

Was the article helpful?

Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
In this article:
  • Getting a list of cluster hosts
  • Adding a host
  • Changing a host
  • Removing a host