Redis - Connect Redis to vRack

Connect an OVHcloud managed Redis cluster to vrack

Last updated March 17th, 2022

Objective

This page shows you how to create and use a managed Redis cluster with vRack.

We are going to connect a cloud instance, hosted in a datacenter, to a Redis database, hosted in another datacenter, like this:

vrack schema

This will be, from a configuration point of view, the equivalent of this:

vrack schema equivalent

Requirements

The OVHcloud vRack is a private network solution that enables our customers to route traffic between OVHcloud dedicated servers as well as other OVHcloud services, such as databases. The vRack also allows you to add Public Cloud instances to your private network to create an infrastructure of physical and virtual resources.

Your vRack must be configured to be accessible from all the services in your Public cloud project.

vrack configured

Instructions

Creating a virtual network

The first step is to create the virtual network that will be used in your vRack.

To proceed, from the Public cloud tab, click on the Private Network menu, then click on the Add Private Network button.

Add virtual network

You can define yourself a VLAN ID for your virtual network. Value must be between 2 and 4,000.

Define your own range or let dynamic address distribution if you want to use DHCP.

By default, the 10.0.0.0/16 CIDR address is defined. Different subnets can be added later.

Configure virtual network

Give a name to your virtual network.

Name virtual network

Choose the regions where you want your virtual network to operate.

The subnets addresses are automatically ajusted, depending on the number of regions you choose.

Choose regions

Your vRack is ready!

Creating a Redis database connected to the private network

Create a new Redis database service:

Choose database

Choose the Business solution.

According the Redis capabilities page, the use of private networks with databases is allowed for Business and Enterprise plans.

Choose plan

Choose the region in which you want to create your database.

Choose region

Select the instances model.

Choose model

Give a name to the database.

Select Private from the Network Type list, then select XXXX - my-private-network. The XXX value is the ID of the vRack.

From the Subnetwork list, select the 10.0.0.0/16 - YYY. The YYY value is the name of the datacenter you chose.

Configure options

The final section will display a summary of your order as well as the API equivalent for creating this database instance with the OVHcloud API.

Resume database creation

Wait a few minutes before the end of the creation of all nodes. When this is done, status changes to ready.

Nodes are ready

Now you can add users and roles to interact with the database.

From the Users tab, click on the + Add user button.

Add users and roles

Name the Redis user and give him some rights.

Example:

  • Keys: .
  • Categories: +@all
  • Commands: +ping, +get, +set
  • Channels: *

You can follow the official Redis documentation about users and ACL: https://redis.io/topics/acl.

Create user and roles

Once the user is created, the password is displayed in plain text. Save it in a password manager as it won't be displayed again.

Get user password

The last step is to authorize access from your required IPs.

From the Authorised IPs tab, click on the + Add an IP address or IP block (CIDR) button.

Authorize IPs

The simplest way is to authorize the whole private network, as defined on previous steps.

Add virtual network subnet

Check that everything is fine:

  • Status is ready.
  • At least one user is defined.
  • Some IPs added to the white list.

Redis database ready

That's it! Your managed Redis database is ready to be accessed within the vRack virtual network.

Adding another instance to the vRack

The database is now connected to the virtual network, we can use it from any component that is connected to the same vRack.

If you want to test the access from an existing instance, read this tutorial to connect it to the vRack: Configuring vRack for Public Cloud.

For this tutorial, create a new instance by following the next steps.

Start by selecting a model.

Select the model

Choose another region than the database one.

Select a region

Select Debian from the images list.

Select an image

Adjust the number of instances to be created, give a name, then select the desired virtual network XXXX - my-private-network.

Configure the instance

Choose your billing option.

Select the billing period

Wait for the Activated status.

Status activated

Connecting and installing the Redis client

We assume that you have an already set SSH key on your project. For more details, read the Creating and connecting to your first Public Cloud instance page.

Connect to the instance via SSH:

ssh debian@141.95.107.2

Now install the Redis client by installing the Redis server package:

sudo apt-get update && sudo apt-get install redis-server -y

Now connect to the Redis database using the URL retrieved from the OVHcloud Control Panel, with a command such as:

redis-cli --tls -u "rediss://my-redis-user@redis-2612345abc-abcd1234defg.database.cloud.ovh.net:20185"

Authenticate yourself with the AUTH command:

AUTH my-redis-user myRedisUserPassword

Test the overall operation with these sample commands:

redis-2612345abc-abcd1234defg.database.cloud.ovh.net:20185> ping
PONG
redis-2612345abc-abcd1234defg.database.cloud.ovh.net:20185> SET mykey.test test
OK
redis-2612345abc-abcd1234defg.database.cloud.ovh.net:20185> GET mykey.test
"test"

We want your feedback!

We would love to help answer questions and appreciate any feedback you may have.

Are you on Discord? Connect to our channel at https://discord.gg/PwPqWUpN8G and interact directly with the team that builds our databases service!


Did you find this guide useful?

Please feel free to give any suggestions in order to improve this documentation.

Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.

Your support requests will not be processed via this form. To do this, please use the "Create a ticket" .

Thank you. Your feedback has been received.


These guides might also interest you...

OVHcloud Community

¡Acceda al espacio de la OVHcloud Community! Resuelva sus dudas, busque información, publique contenido e interactúe con otros miembros de la comunidad.

Discuss with the OVHcloud community