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
In the management console, select the folder where you want to create a DB cluster.
Select Managed Service for Redis.
Click Create cluster.
Enter the cluster name in the Cluster name field. The cluster name must be unique within the Cloud.
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.
Select the DBMS version.
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.
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.
In Cluster settings under Password, set the user password (from 8 to 128 characters).
Under Network, select the network whose subnets the hosts will be connected to.
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.
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
To create a cluster:
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.
View a description of the CLI's create cluster command:
$ yc managed-redis cluster create --help
View available host classes:
$ yc managed-redis resource-preset list
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-idshould be specified if the selected availability zone contains two or more subnets.
Creating a single-host cluster
To create a cluster with a single host, you should pass a single parameter,
Let's say we need to create a Redis cluster with the following characteristics:
- In the
- In the
- With a single
b1.nanoclass host in the
b0rcctk2rvtr8efcch64subnet and the
- With 20 GB of storage.
- With the
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