Creating Redis clusters

Redis clusters are one or more database hosts that replication can be configured between. Replication is enabled by default in any cluster consisting of more than one host: the master host accepts write requests and asynchronously duplicates changes on replicas.

The number of hosts that can be created together with a Redis cluster depends on the host type selected:

  • In a cluster with high-memory hosts, you can create an unlimited number of hosts (from 1 to the current maximum quota).

  • In a cluster with burstable hosts, you can create only one host.

How to create a Redis cluster

  1. In the management console, select the folder where you want to create a DB cluster.

  2. Select Managed Service for Redis.

  3. Click Create cluster.

  4. Enter the cluster name in the Cluster name field. The cluster name must be unique within the Cloud.

  5. Select the environment where you want to create the cluster (you can't change the environment once the cluster is created):

    • production: For stable versions of your apps.
    • prestable: For testing, including the Managed Service for Redis service itself. The prestable environment is updated more often, which means that known problems are fixed sooner, but this may cause backward incompatible changes.
  6. Select the DBMS version.

  7. If necessary, enable cluster sharding.


    You can only enable sharding when you create a new cluster. You can't shard an existing non-sharded cluster or disable sharding for a cluster that it's enabled for.

  8. Under Host class:

    • Select the host type: it determines the performance level of the processor cores. High-memory hosts allow full core usage, whereas burstable hosts only a portion.

    • Select the amount of RAM for the host.

    • Select the disk size.

  9. In Cluster settings under Password, set the user password (from 8 to 128 characters).

  10. Under Network, select the network whose subnets the hosts will be connected to.

  11. Under Hosts, click Add host and select the availability zone and subnet to connect the host to. Create the necessary number of hosts. To change the availability zone and the added host, click the pencil icon in the host line.

    If you enabled sharding, enter names for the shards.

  12. Click Create cluster.

If you don't have the Yandex.Cloud command line interface yet, install 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 cluster:

  1. Check whether the folder has any subnets for the cluster hosts:

    $ yc vpc subnet list

    If there are no subnets in the folder, create the necessary subnets in VPC.

  2. View a description of the CLI's create cluster command:

    $ yc managed-redis cluster create --help
  3. View available host classes:

    $ yc managed-redis resource-preset list
  4. Specify the cluster parameters in the create command (only some of the supported flags are given in the example):

    $ yc managed-redis cluster create \
       --name <cluster name> \
       --environment <prestable or production> \
       --network-name <network name> \
       --host zone-id=<availability zone>,subnet-id=<subnet ID> \
       --resource-preset <host class> \
       --disk-size <storage size in GB> \
       --password=<user password> \
       --backup-window-start <backup start time in HH:MM:SS format>

    The subnet ID subnet-id should be specified if the selected availability zone contains two or more subnets.

With Terraform, you can quickly create a cloud infrastructure in Yandex.Cloud. The infrastructure components are identified through configuration files that specify the required cloud resources and their parameters.

If you don't have Terraform yet, install it and configure the provider.

To create a cluster:

  1. Prepare an infrastructure plan.

    In the configuration file, describe the parameters of resources that you want to create:

    • Network: Description of the cloud network where the cluster will be located. If you already have a suitable network, you don't need to describe it again.
    • Subnets: Description of the subnets to connect the cluster hosts to. If you already have suitable subnets, you don't need to describe them again.
    • Database cluster: Description of the cluster and its hosts.

    Sample configuration file structure:

    resource "yandex_mdb_redis_cluster" "<cluster name>" {
      name        = "<cluster name>"
      environment = "<environment>"
      network_id  = "<network ID>"
      config {
        password = "<password>"
      resources {
        resource_preset_id = "<host class>"
        disk_size          = <disk size>
      host {
        zone      = "<availability zone>"
        subnet_id = "<subnet ID>"
    resource "yandex_vpc_network" "<network name>" {}
    resource "yandex_vpc_subnet" "<subnet name>" {
      zone           = "<availability zone>"
      network_id     = "<network ID>"
      v4_cidr_blocks = ["<range>"]

    For more information about resources that you can create using Terraform, see the provider's documentation.

  2. Make sure that the configuration files are correct.

    1. In the command line, use the cd <folder path> command to go to the folder where you created the configuration file.

    2. Run the check using the command:

      terraform plan

    If the configuration is described correctly, the terminal will display a list of created resources and their parameters. If there are errors in the configuration, Terraform will point them out. This is a test step. No resources are created.

  3. Create a cluster.

    1. If there are no errors in the configuration, run the command:

      terraform apply
    2. Confirm the creation of resources.

    After this, all the necessary resources will be created in the specified folder and the IP addresses of the VMs will be displayed in the terminal. You can check resource availability and their settings in консоли управления.


Creating a single-host cluster

To create a cluster with a single host, you should pass a single parameter, --host.

Let's say we need to create a Redis cluster with the following characteristics:

  • Named myredis.
  • In the production environment.
  • In the default network.
  • With a single b1.nano class host in the b0rcctk2rvtr8efcch64 subnet and the ru-central1-c availability zone.
  • With 20 GB of storage.
  • With the user1user1 password.

Run the command:

$ yc managed-redis cluster create \
     --name myredis \
     --environment production \
     --network-name default \
     --resource-preset b1.nano \
     --host zone-id=ru-central1-c,subnet-id=b0rcctk2rvtr8efcch64 \
     --disk-size 20 \

Creating a single-host cluster

Let's say we need to create a Redis cluster and a network for it with the following characteristics:

  • Named myredis.
  • In the production environment.
  • In the cloud with the b1gq90dgh25иuebiu75o ID.
  • In a folder named myfolder.
  • In a new network named mynet.
  • With a single hm1.nano class host in a new subnet named mysubnet and in the ru-central1-c availability zone. The mysubnet subnet will have the range.
  • With 16 GB of storage.
  • With the user1user1 password.

The configuration file for the cluster looks like this:

provider "yandex" {
  token = "<OAuth or static key of service account>"
  cloud_id  = "b1gq90dgh25иuebiu75o"
  folder_id = "${}"
  zone      = "ru-central1-c"

resource "yandex_mdb_redis_cluster" "myredis" {
  name        = "myredis"
  environment = "PRODUCTION"
  network_id  = "${}"

  config {
    password = "user1user1"

  resources {
    resource_preset_id = "hm1.nano"
    disk_size          = 16

  host {
    zone      = "ru-central1-c"
    subnet_id = "${}"

resource "yandex_vpc_network" "mynet" {}

resource "yandex_vpc_subnet" "mysubnet" {
  zone           = "ru-central1-c"
  network_id     = "${}"
  v4_cidr_blocks = [""]