Install and Configure Redis Server on RHEL 8 / CentOS 8

Posted on 65 views

How can I install Redis on CentOS 8 / RHEL 8?. This guide will help you to install and configure Redis server on RHEL 8 / CentOS 8 Linux system. Redis is a free and open Source in-memory data structure store. It can be used as a database server, as a message broker or for caching data in memory for faster retrieval.

The data structures supported by Redis are:

  • Hashes
  • sets with range queries
  • Strings
  • sorted lists
  • Hyperloglogs
  • Bitmaps
  • Geospatial indexes e.t.c

Install Redis on RHEL 8 / CentOS 8

Redis on RHEL 8 is available on AppStream repository.

$ sudo yum module list redis
AlmaLinux 8 - AppStream
Name                                     Stream                                    Profiles                                      Summary
redis                                    5 [d]                                     common [d]                                    Redis persistent key-value database
redis                                    6                                         common [d]                                    Redis persistent key-value database

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

As seen from the output, Redis 4.0 is available on AppStream. Install it using yum package manager.

sudo yum install -y @redis vim

Once the package is installed, start and enable Redis service to start on boot.

sudo systemctl enable --now redis

Service status should show running.

$ systemctl status redis
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
   Active: active (running) since Fri 2022-05-20 22:05:53 EAT; 4s ago
 Main PID: 50649 (redis-server)
    Tasks: 4 (limit: 49359)
   Memory: 6.6M
   CGroup: /system.slice/redis.service
           └─50649 /usr/bin/redis-server

May 20 22:05:52 almalinux-8.localdomain systemd[1]: Starting Redis persistent key-value database...
May 20 22:05:53 almalinux-8.localdomain systemd[1]: Started Redis persistent key-value database.

Configure Redis Server on RHEL 8 / CentOS 8

Now that Redis server is installed, the next part is configuration. There are many tunables you can set to fit your use case, but I’ll cover the basic settings you need to get started.

Enable Redis Service to listen on all interfaces

By default, Redis service listens on Allow the service to listen on all network interfaces if you need remote clients to connect to it.

$ ss -tunelp | grep 6379
tcp   LISTEN  0    128*  users:(("redis-server",pid=30348,fd=6)) uid:986 ino:71091 sk:4 <->    

Open the file /etc/redis.conf with your favorite text editor

sudo vim /etc/redis.conf

Then change line 69 bind to below:


Restart Redis after making the change

sudo systemctl  restart redis

Confirm new bind address.

$ ss -tunelp | grep 6379
 tcp   LISTEN  0    128*  users:(("redis-server",pid=30348,fd=6)) uid:986 ino:71091 sk:4 <-> 

Configure Redis Authentication

Configure Redis Authentication for clients to require AUTH  before processing any other commands.



requirepass StrongPassword

Set Persistent Store for Recovery

Set persistence mode by changing the appendonlyvalue to yes

appendonly yes
appendfilename "appendonly.aof"

Restart redis service after making the changes

sudo systemctl restart redis

If you have an active firewalld service, allow port 6379

sudo firewall-cmd --add-port=6379/tcp --permanenent
sudo firewall-cmd --reload

Check redis service status:

systemctl status redis

Connect to Redis

Confirm that you can connect to Redis Server locally:

$ redis-cli> INFO
 NOAUTH Authentication required.

Test authenticate:> AUTH 

You should receive OK in the output. If you input a wrong password, Authentication should fail:> AUTH WrongPassword
(error) ERR invalid password

Check redis information.> INFO

This will output a long list of data. You can limit the output by passing Section as an argument. E.g.> INFO Server
# Server
os:Linux 4.18.0-348.2.1.el8_5.x86_64 x86_64

Perform Redis Benchmarking

Run the benchmark with 10 parallel connections, for a total of 100k requests, against local redis to test its performance.

# redis-benchmark -h -p 6379 -n 100000 -c 10
100.00% <= 0 milliseconds
 85470.09 requests per second
 ====== LRANGE_500 (first 450 elements) ======
   100000 requests completed in 1.17 seconds
   10 parallel clients
   3 bytes payload
   keep alive: 1
 100.00% <= 0 milliseconds
 85397.09 requests per second
 ====== LRANGE_600 (first 600 elements) ======
   100000 requests completed in 1.18 seconds
   10 parallel clients
   3 bytes payload
   keep alive: 1
 100.00% <= 0 milliseconds
 84530.86 requests per second
 ====== MSET (10 keys) ======
   100000 requests completed in 1.18 seconds
   10 parallel clients
   3 bytes payload
   keep alive: 1
 100.00% <= 0 milliseconds
 84961.77 requests per second

For more options and examples, use:

$ redis-benchmark --help

To show connected clients, use:> client list 
 id=185 addr= fd=8 name= age=75 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client

Using Redis with Python

To use redis with Python, install Python Redis Client Library:

sudo yum -y install  python-redis

Using Redis with PHP

To connect to Redis server with PHP, install PHP Redis Client Module.

sudo yum -y install php-pecl-redis

Enjoy using Redis on RHEL 8 / CentOS 8.


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.