Getting started with Managed Service for Redis
To get started with the service:
Getting started
-
Go to the management console
and log in to Yandex Cloud or sign up if not signed up yet. -
If you do not have a folder yet, create one:
-
In the management console
, select the appropriate cloud in the list on the left. -
At the top right, click
Create folder. -
Enter the folder name. The naming requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
(Optional) Enter a description of the folder.
-
Select Create a default network. This will create a network with subnets in each availability zone. Within this network, a default security group will be created, inside which all network traffic is allowed.
-
Click Create.
-
-
Make sure your account has the vpc.user role and managed-redis.editor role or higher for creating a cluster.
-
If no public access is set up for a cluster, you can only connect to it from inside Yandex Cloud. To connect to a cluster, create a VM in the same cloud network as the Redis cluster (with Linux).
-
Connect to the VM over SSH.
-
Install the redis-cli
utility on the VM. For example (for Ubuntu 20.04 LTS):sudo apt install redis-tools
Create a cluster
- In the management console, select the folder where you want to create a cluster Redis.
- Select Managed Service for Redis.
- Click Create cluster.
- Set the cluster parameters and click Create cluster. For more information, see Creating clusters.
- Wait until the cluster is ready: its status on the Managed Service for Redis dashboard will change to Running and its state, to Alive. This may take some time.
Connect to the cluster
-
If TLS support is enabled in your cluster, get an SSL certificate:
Linux (Bash)/macOS (Zsh)Windows (PowerShell)mkdir -p ~/.redis && \ wget "https://storage.yandexcloud.net/cloud-certs/CA.pem" \ --output-document ~/.redis/YandexInternalRootCA.crt && \ chmod 0655 ~/.redis/YandexInternalRootCA.crt
The certificate is saved to the
~/.redis/YandexInternalRootCA.crt
file.mkdir $HOME\.redis; curl.exe -o $HOME\.redis\YandexInternalRootCA.crt https://storage.yandexcloud.net/cloud-certs/CA.pem
The certificate is saved to the
$HOME\.redis\YandexInternalRootCA.crt
file. -
If using security groups for a cloud network, configure them to enable all relevant traffic between the cluster and the connecting host.
-
Connect to the cluster using
redis-cli
.Note
To connect to an SSL-enabled cluster, download
an archive with the utility's source code and build a version of the utility with TLS support using themake BUILD_TLS=yes
command.To see code examples with the host FQDN filled in, open the cluster page in the management console
and click Connect.Non-sharded clusterSharded clusterTo connect using Sentinel
(without SSL):-
Get the address of the master host by using Sentinel and any Redis host:
redis-cli -h <FQDN_of_any_Redis_host> \ -p 26379 \ sentinel get-master-addr-by-name <Redis_cluster_name> | head -n 1
-
Connect to the host with this address:
redis-cli \ -h c-<cluster_ID>.rw.mdb.yandexcloud.net \ -a <password> \ -p 6380 \ --tls \ --cacert ~/.redis/YandexInternalRootCA.crt
To connect directly to the master (without SSL):
redis-cli -h c-<cluster_ID>.rw.mdb.yandexcloud.net \ -p 6379 \ -a <Redis_password>
To connect directly to the master (with SSL):
redis-cli -h c-<cluster_ID>.rw.mdb.yandexcloud.net \ -p 6380 \ -a <Redis_password> \ --tls \ --cacert ~/.redis/YandexInternalRootCA.crt
To connect without SSL:
redis-cli -h <FQDN_of_master_host_in_any_shard> \ -p 6379 \ -a <Redis_password>
To connect with SSL:
redis-cli -h <FQDN_of_master_host_in_any_shard> \ -p 6380 \ -a <Redis_password> \ --tls \ --cacert ~/.redis/YandexInternalRootCA.crt
-
-
Once connected, send the
PING
command. Redis should returnPONG
in response.
What's next
- Read about service concepts.
- Learn more about creating a cluster and connecting to a cluster.
- Read questions and answers.