﻿# Redis

> [HTML Version](redis.html)

For the proper functioning of the system, Redis version 5 or 6.2 is required. The article describes the installation of Redis 6.2.12 for Ubuntu Linux 20.04 and 22.04. You can also refer to the guide in the [official Redis documentation](https://redis.io/docs/getting-started/installation/install-redis-on-linux/).

````
начало внимание

````
Due to changes in the licensing policy of Redis, we recommend installing Valkey as an alternative solution. For detailed installation instructions, refer to the [Valkey](valkey.md) article.

````
конец внимание

````
It is recommended to install Redis in the same Kubernetes environment as the BRIX application. For more details on infrastructure organization options, refer to [Prepare BRIX On-Premises infrastructure](infrastructure-preparation.md).

Installation consists of three steps:

1. [Install Redis](#1redis).

2. [Configure Redis](#2redis).

3. [Connect to Redis](#3redis).

## Step 1: Install Redis

1. Install the necessary packages:

````
sudo apt install lsb-release curl gpg

2. ````
Import the necessary keys and add the Redis repository:

````
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg  
echo "deb \[signed-by=/usr/share/keyrings/redis-archive-keyring.gpg\] https://packages.redis.io/deb \$(lsb\_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

3. ````
Update the package cache:

````
sudo apt-get update

4. ````
Install Redis:

````
sudo apt-get -y install redis=6:6.2.12-1rl1~\$(lsb\_release -cs)1 redis-server=6:6.2.12-1rl1~\$(lsb\_release -cs)1 redis-tools=6:6.2.12-1rl1~\$(lsb\_release -cs)1

## ````
Step 2: Configure Redis

````
Начало примечание

````
**Note**

The password can contain the following characters:

- Uppercase Latin letters: A to Z

- Lowercase Latin letters: a to z

- Digits: 0 to 9

- Symbols: -\_

Reserved (invalid) characters: \! \* ' ( ) ; : @ \& = + \$ , / ? % # \[ \]

````
Конец примечание

1. ````
Allow connection to the Redis server. To do this, edit the \[OBJECT\] configuration file and add the machine's IP address (e.g., 192.168.10.10):

````
sudo nano /etc/redis/redis.conf  
bind 192.168.10.10

````
Configuring TLS/SSL in Redis

To enable TLS/SSL support in Redis, in the configuration file \[OBJECT\] do the following:

1. Disable unprotected connections by setting \[OBJECT\] in the parameter \[OBJECT\]. 

2. Set the port for TLS connections. Uncomment the parameter \[OBJECT\].

3. Specify the path to the server certificate file in the parameter \[OBJECT\].

4. Specify the path to the private key file in the parameter \[OBJECT\].

5. Specify the path to the root CA file in the parameter \[OBJECT\].

6. Disable client authentication using the active certificate by setting \[OBJECT\] in the parameter \[OBJECT\].

````
port 0  
tls-port 6379  
tls-cert-file /path/redis.crt  
tls-key-file /path/redis.key  
tls-ca-cert-file /path/to/ca.crt  
tls-auth-clients no

````
For more details on TLS/SSL configuration in Redis, refer to the [official Redis documentation](https://redis.io/docs/management/security/encryption/).

2. Increase the maximum number of clients by changing the value of the parameter \[OBJECT\] to \[OBJECT\]. Uncomment the line by removing the # sign:

````
maxclients 20000

3. ````
Set the key eviction policy by changing the value of the parameter \[OBJECT\] to \[OBJECT\]. Uncomment the line by removing the # sign:

````
maxmemory-policy allkeys-lfu

4. ````
 Disable **snapshot** creation by changing the value of the parameter \[OBJECT\] to \[OBJECT\]. Uncomment the line by removing the # sign:

````
save ""

5. ````
Disable **AOF** (saving the Redis database to a file). To do this, change the value of the parameter \[OBJECT\] to \[OBJECT\]. Uncomment the line, removing the # sign:

````
appendonly no

6. ````
Restart Redis:

````
sudo systemctl restart redis-server

## ````
Step 3: Connect to Redis

Connection string to Redis:

````
redis://<redis-server-address>:6379/0

````
Connection string to Redis with TLS/SSL:

````
redis://<redis-server-address>:6379/0

````
If you already have a Redis cluster, you can use it as a cache for BRIX. For information on deploying a Redis Cluster, refer to the [official documentation](https://redis.io/docs/management/scaling/#redis-cluster-101)).