Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
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 databases
    • Stop and start the cluster
    • Managing hosts in a cluster
    • How to manage shards
    • Managing backups
    • Changing the master
    • Deleting clusters
  • Concepts
    • Overview
    • Host classes
    • Network in Managed Service for Redis
    • Sharding
    • Backups
    • Replication and fault tolerance
    • Supported clients
    • Limitations of Managed Service for Redis
    • Service quotas and limits
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Before February 1, 2020
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • BackupService
      • ClusterService
      • ResourcePresetService
      • OperationService
    • REST
      • Overview
      • Backup
        • Overview
        • get
        • list
      • Cluster
        • Overview
        • addHosts
        • addShard
        • backup
        • create
        • delete
        • deleteHosts
        • deleteShard
        • get
        • getShard
        • list
        • listBackups
        • listHosts
        • listLogs
        • listOperations
        • listShards
        • move
        • rebalance
        • rescheduleMaintenance
        • restore
        • start
        • startFailover
        • stop
        • streamLogs
        • update
      • ResourcePreset
        • Overview
        • get
        • list
      • Operation
        • Overview
        • get
  • Questions and answers
    • General questions
  1. Step-by-step instructions
  2. Creating clusters

Creating Redis clusters

  • How to create a cluster Redis
  • Examples

Redisclusters 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 cluster Redis

Management console
CLI
Terraform
  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 first updated with new features, improvements, and bug fixes. However, not every update ensures backward compatibility.
  6. Select the DBMS version.

  7. If necessary, enable cluster sharding.

    Warning

    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. Set up a host class for the cluster:

    • Select the host type: it defines the guaranteed vCPU performance. 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. The available disk size depends on the amount of RAM and is limited by quotas and limits. The minimum disk size is twice the selected amount of RAM, while the maximum disk size is 8 times the selected amount of RAM.
  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 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 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. When you create a cluster from the CLI, you can't explicitly specify the host type and amount of RAM. Choose the applicable host class instead. To see what host classes are available, run the command:

    $ 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 \
       --cluster-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. In the configuration file, describe the parameters of resources that you want to create:

    • Database cluster: Description of the cluster and its hosts.
    • 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.

    Example 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>" { name = "<network name>" }
    
    resource "yandex_vpc_subnet" "<subnet name>" {
      name           = "<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, 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 displays a list of created resources and their parameters. If there are errors in the configuration, Terraform points them out. This is a test step. No resources are created.

  3. Create a cluster.

    1. If the configuration doesn't contain any errors, run the command:

      terraform apply
      
    2. Confirm that you want to create the 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 консоли управления.

Examples

CLI
Terraform

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 hm1.nano class host in the b0rcctk2rvtr8efcch64 subnet and the ru-central1-c availability zone.
  • With a 16 GB fast network storage (network-ssd).
  • With the user1user1 password.

Run the command:

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

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 ID b1gq90dgh25bebiu75o.
  • In a folder named myfolder.
  • In a new network named mynet.
  • With a single host of the hm1.nano class in the new mysubnet subnet and the ru-central1-c availability zone. The mysubnet subnet will have a range of 10.5.0.0/24.
  • With a 16 GB fast network storage (network-ssd).
  • 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  = "b1gq90dgh25bebiu75o"
  folder_id = "${data.yandex_resourcemanager_folder.myfolder.id}"
  zone      = "ru-central1-c"
}

resource "yandex_mdb_redis_cluster" "myredis" {
  name        = "myredis"
  environment = "PRODUCTION"
  network_id  = "${yandex_vpc_network.mynet.id}"

  config {
    password = "user1user1"
  }

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

  host {
    zone      = "ru-central1-c"
    subnet_id = "${yandex_vpc_subnet.mysubnet.id}"
  }
}

resource "yandex_vpc_network" "mynet" { name = "mynet" }

resource "yandex_vpc_subnet" "mysubnet" {
  name           = "mysubnet"
  zone           = "ru-central1-c"
  network_id     = "${yandex_vpc_network.mynet.id}"
  v4_cidr_blocks = ["10.5.0.0/24"]
}
In this article:
  • How to create a cluster Redis
  • Examples
Language / Region
Careers
Privacy policy
Terms of use
Brandbook
© 2021 Yandex.Cloud LLC