How to install Redis server on RHEL 8 / CentOS 8 Linux

In this tutorial we will discuss an installation of Redis server and client on RHEL 8 / CentOS 8. This tutorial also includes optional steps on how to allow remote connections to Redis sever running on RHEL 8.

In this tutorial you will learn:

  • How to install Redis server
  • How to install Redis client
  • How to enable Redis server to start after system boot
  • How to allow remote connections to Redis server
  • How to open firewall ports to allow incoming connections to Redis server
  • How to check Redis versionr

Connection to remote Redis server installed on RHEL 8 / CentOS 8

Connection to remote Redis server installed on RHEL 8 / CentOS 8

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System RHEL 8 / CentOS 8
Software Redis server 4.0.10
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to install redis server on RHEL 8 step by step instructions



  1. Install Redis server package:
    # dnf install redis
    

    The above command will install Redis server as well as Redis client on your RHEL 8 / CentOS 8 Linux host.

  2. Start Redis server and enable systemd service in order for the server to start after reboot:
    # systemctl start redis
    # systemctl enable redis
    
  3. Check Redis server version to confirm the correctness of the installation:

    # redis-server -v
    
  4. Connect to Redis server by using the redis-cli command line client:
    # redis-cli 
    127.0.0.1:6379> ping
    PONG
    127.0.0.1:6379>
    

    All done. The below steps are optional to allow remote connections to Redis server if required.



  5. Allow remote connections:

    First, enable the Redis server to listen on all network interfaces instead of the default local 127.0.0.1 loopback interface.

    To do so open the Redis configuration file /etc/redis.conf and comment the bind 127.0.0.1 ::1: line:

    FROM:
    bind 127.0.0.1 ::1
    TO:
    # bind 127.0.0.1 ::1
  6. Next, disable protected-mode to allow for remote connections. Open the Redis configuration file /etc/redis.conf and change the following line:

    FROM:
    protected-mode yes
    TO:
    protected-mode no
    
  7. Restart Redis server:
    # systemctl restart redis-server
    
  8. Open firewall ports to allow Redis incoming traffic:

    # firewall-cmd --zone=public --permanent --add-service=redis
    # firewall-cmd --reload
    
  9. Connect to a Redis server from a remote host using the redis-cli command line client:
    $ redis-cli -h REDISHOSTNAME_OR_IPADDRESS
    rhel8-redis:6379> INFO
    # Server
    redis_version:4.0.10