Install Redis on Rocky Linux

This guide will go through how to install Redis on Rocky Linux. Redis is a distributed, in-memory key-value database, cache, and message broker with optional durability that is used as an in-memory data structure store. A variety of abstract data structures are supported by Redis, including strings, lists, maps, sets, sorted sets, HyperLogLogs, bitmaps, streams, and spatial indices.

How to Install Redis on Rocky Linux

  • Update Rocky Linux packages using the command below.
sudo dnf update
  • Next, install Redis on Rocky Linux using the following command.
sudo dnf install redis -y

Sample output

Dependencies resolved.
====================================================================
 Package     Architecture Version             Repository       Size
====================================================================
Installing:
 redis       x86_64       6.2.6-1.el9         appstream       1.3 M

Transaction Summary
====================================================================
Install  1 Package

Total download size: 1.3 M
Installed size: 4.7 M
Downloading Packages:
redis-6.2.6-1.el9.x86_64.rpm        581 kB/s | 1.3 MB     00:02    
--------------------------------------------------------------------
Total                               368 kB/s | 1.3 MB     00:03     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                            1/1 
  Running scriptlet: redis-6.2.6-1.el9.x86_64                   1/1 
  Installing       : redis-6.2.6-1.el9.x86_64                   1/1 
  Running scriptlet: redis-6.2.6-1.el9.x86_64                   1/1 
  Verifying        : redis-6.2.6-1.el9.x86_64                   1/1 

Installed:
  redis-6.2.6-1.el9.x86_64                                          

Complete!
  • Then start Redis and enable it to start on system boot.
sudo systemctl enable redis --now
  • Redis should be running, confirm using the following command.
systemctl status redis

Sample output

● redis.service - Redis persistent key-value database
     Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
    Drop-In: /etc/systemd/system/redis.service.d
             └─limit.conf
     Active: active (running) since Thu 2022-09-08 11:39:21 EAT; 2min 23s ago
   Main PID: 7210 (redis-server)
     Status: "Ready to accept connections"
      Tasks: 5 (limit: 23284)
     Memory: 7.3M
        CPU: 212ms
     CGroup: /system.slice/redis.service
             └─7210 "/usr/bin/redis-server 127.0.0.1:6379"

Sep 08 11:39:21 localhost.localdomain systemd[1]: Starting Redis persistent key-value database...
Sep 08 11:39:21 localhost.localdomain systemd[1]: Started Redis persistent key-value database.
  • To check the Redis version that is installed, run the command below.
redis-server -v
  • Next, let’s perform a ping test to confirm Redis is working.
redis-cli
ping

Sample output

127.0.0.1:6379> ping
PONG
127.0.0.1:6379> exit

Set Redis password on Rocky Linux

  • Open the Redis configuration file by running the command below.
sudo nano /etc/redis/redis.conf

In the configuration file opened above, search for requirepass foobared and uncomment it by removing the # symbol then replace foobared with your password.

# IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility
# layer on top of the new ACL system. The option effect will be just setting
# the password for the default user. Clients will still authenticate using
# AUTH  as usually, or more explicitly with AUTH default 
# if they follow the new protocol: both will work.
#
# The requirepass is not compatable with aclfile option and the ACL LOAD
# command, these will cause requirepass to be ignored.
#

requirepass YourStrongPassword 

# New users are initialized with restrictive permissions by default, via the
# equivalent of this ACL rule 'off resetkeys -@all'. Starting with Redis 6.2, it
# is possible to manage access to Pub/Sub channels with ACL rules as well. The
# default Pub/Sub channels permission if new users is controlled by the 
# acl-pubsub-default configuration directive, which accepts one of these values:
#
  • Restart Redis to apply changes.
sudo systemctl restart redis
  • When you connect again to Redis to do the ping test you will be required to authenticate with your password.
redis-cli
ping

Sample output

127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth YourStrongPassword
OK
127.0.0.1:6379> exit

How to Uninstall Redis on Rocky Linux

  • Run the following command to remove Redis from your system.
sudo dnf autoremove redis
  • You have reached the end of our article. We have gone through how to install Redis on Rocky Linux.

Read more on Redis Documentation

Other Tutorials

Install Lynis Security Audit Tool on Rocky Linux 9

Install KDE Desktop Environment on Rocky Linux 9

Install VNC Server on Rocky Linux 9

System administrator | Software Developer | DevOps

Leave a Comment