How to Install Redis on Almalinux

Categories

How to Install Redis on Almalinux

You are here:

Redis is a popular and open-source in-memory key-value or data structure store used as a distributed database, message broker, and cache. Redis supports data structures, such as Lists, Strings, and Sets, widely recognised due to its broad support, performance, availability, and flexibility. This article shows you how to install and configure Redis on the AlmaLinux operating system. However, this can be done on a vast range of different platforms.

First of all, we need to ensure that the system is up to date with the latest application; this is done by running the following command.

Updating the System

sudo dnf update && upgrade

 

Installing Redis

The next step is to install the Redis application on Almalinux

dnf install redis -y

After the install has been complete, you will need to change some settings in the configuration file, open the file and edit with by entering the following command:

vi/etc/redis.conf

Once in the file will need to locate the following lines and make some changes.

Locate the following :

bind 127.0.0.1 to IP address or 0.0.0.0.

This will allow redis to communicate with remote devices. If this is something you are not doing, leave this section out and go to testing.  If you do choose to have Redis running on a public IP then ensure that the Redis port is firewalled as detailed below.

If you want to have a remote connection to the redis server, we need to change the protection to connect by locating the current line protection-mode no and change this to yes. Within the same configuration file, find the line supervised no and switch it to supervised systemd. Save the file and exit.

Now we need to start the service.

 

Testing Redis

To confirm the install of Redis has been successful, can perform a test to this will use the Redis command line. Enter

 redis-cli ping 

You should recieve back PONG

 

Configuring a Firewall Rule

Configuring the firewall to allow traffic from port 6979

 sudo firewall-cmd --permanent --new-zone=redis

After adding the new zone, add port 6379.

sudo firewall-cmd --permanent --zone=redis --add-port=6379/tcp

Now, add the private IP address that you want to allow to pass through the firewall.

sudo firewall-cmd --permanent --zone=redis --add-source=<the-private-IP-address>

Reload the firewall

 

 

 

Table of Contents