Skip to main content

Connect to a Redis cluster

A Redis cluster can be connected to:

Connection with SSL certificate is available for all methods.

Specify the port and address when connecting.

Connection ports

Use ports to connect to Redis:

  • 6380 — port for connection with SSL certificate;
  • 6379 — port for connection without SSL certificate (available only for clusters in private subnet).

Addresses for connection

The address to connect to depends on the cluster subnet and where you are connecting from. You can choose an address depending on one of the scenarios:

Connecting to a cluster on a public subnet

If the cluster is on a public subnet, the nodes can be connected to by DNS address or IP address from the public subnet.

We recommend connecting by DNS address. For DNS addresses in the cluster, the master discovery mechanism is used — the address is bound to the node role, not to the node itself. If the master is unavailable, one of the replicas becomes the new master and the address is transferred to the new node along with the role.

When connecting using an IP address from a public subnet, the master discovery mechanism is not used. If one of the replicas becomes the new master, the master IP address will change and the connection to the old IP address will not work.

You can view the address to connect to in the control panel.

Connecting from a private subnet to a cluster on a private subnet

If you are connecting from a private subnet to a cluster on a private subnet, you can use a DNS address or a private IP address.

We recommend connecting by DNS address. For DNS addresses in the cluster, the master discovery mechanism is used — the address is bound to the node role, not to the node itself. If the master is unavailable, one of the replicas becomes the new master and the address is transferred to the new node along with the role.

When connecting by private IP address, the master discovery mechanism is not used. If one of the replicas becomes the new master, the master IP address will change and the connection using the old IP address will not work.

To connect from another private subnet, first connect both private subnets to the cloud router.

You can view the address to connect to in the control panel.

Connecting from the Internet to a cluster on a private subnet

Если вы подключаетесь к кластеру в приватной подсети из интернета, можно использовать только публичный IP-адрес (Floating IP). Приватная подсеть должна соответствовать требованиям. Если подсеть не соответствует требованиям, подготовьте ее для подключения публичного IP-адреса (Floating IP).

For public IP addresses (Floating IPs) the master discovery mechanism is used — the address is bound to the role of the node, not to the node itself. If the master is unavailable, one of the replicas becomes the new master and the address is transferred to the new node along with the role.

You can view the address to connect to in the control panel.

View the address for connection

  1. In the Dashboard, on the top menu, click Products and select Cloud Databases.
  2. Open the Active tab.
  3. Open the Database Cluster page → Connection tab.
  4. In the Addresses to connect block, look up the address.

Connect with SSL

Connecting using TLS(SSL)-encryption provides a secure connection between your server and the database cluster.

  1. Download the root certificate and place it in the ~/.redis/ folder:

    mkdir -p ~/.redis/
    wget https://storage.dbaas.selcloud.ru/CA.pem -O ~/.redis/root.crt
    chmod 600 ~/.redis/root.crt
  2. Connect to the cluster:

    redis-cli -h <host> \
    -a <password> \
    -p <port> \
    --tls \
    --cacert ~/.redis/root.crt

    Specify:

Connect without SSL

Connection without SSL is only available for clusters on a private subnet.

  1. Open the CLI.

  2. Connect to the cluster:

    redis-cli -h <host> \
    -a <password> \
    -p <port>

    Specify:

Connect via Docker

  1. Download the root certificate and place it in the ~/.redis/ folder:

    mkdir -p ~/.redis/
    wget https://storage.dbaas.selcloud.ru/CA.pem -O ~/.redis/root.crt
    chmod 600 ~/.redis/root.crt
  2. Connect to the cluster:

    docker run --rm -it \
    -v $(pwd)/.redis/root.crt:/root.crt \
    redis \
    redis-cli \
    -h <host> \
    -a <password> \
    -p <port> --tls \
    --cacert /root.crt

    Specify: