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.

    Important

    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.

Examples

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 \
     --password=user1user1