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
Software Requirements and Conventions Used
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
- 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.
- Start Redis server and enable systemd service in order for the server to start after reboot:
# systemctl start redis # systemctl enable redis
-
Check Redis server version to confirm the correctness of the installation:
# redis-server -v
- 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.
- 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 thebind 127.0.0.1 ::1:
line:FROM: bind 127.0.0.1 ::1 TO: # bind 127.0.0.1 ::1
- Restart Redis server:
# systemctl restart redis-server
-
Open firewall ports to allow Redis incoming traffic:
# firewall-cmd --zone=public --permanent --add-service=redis # firewall-cmd --reload
- 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
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