Install and Configure Redis on CentOS 8 - Step by Step Procedure ?

Redis is an in-memory data structure store. It is an open-source application that can be used as a Memcached alternative to store key-value pairs, means sets of two linked items, as a database NoSQL, message broker, and supports different data structures such as Hashes, Lists, Sets, Strings, and more.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Redis queries on Linux Systems.

In this context, we shall look into steps to install and configure Redis on the CentOS 8 Linux system.

Complete steps to Install and configure Redis on CentOS 8

It is important to log into your server as the administrator or with root privileges on CentOS 8 to install Redis.

Then proceed with the below steps to install Redis.

1. Install Redis using CentOS 8 repository

Start by logging into the system and open the command line application 'Terminal' from the left sidebar of your CentOS 8 desktop. Now, update the system packages and CentOS 8 repositories by running the below command:

$ sudo dnf update
$ sudo dnf install redis

2. Verify Redis installation

Once the installation of Redis is finished, check Redis installation details by using the below terminal command:

$ rpm -qi redis

3. Enable Redis service 

Here, enable and then start the Redis service on CentOS 8 by using the following commands:

$ sudo systemctl enable redis
$ sudo systemctl start redis

Now, verify the running status of Redis service by executing the below-mentioned command:

$ sudo systemctl status redis

By default, port 6379 is used by Redis. Using the netstat command, you can easily confirm the port as follows:

$ sudo netstat -pnltu | grep redis

4. Configure Redis for remote access

By default, Redis only allows the Redis server to localhost ( connection means on which the Redis is running. Redis does not allow remote connections. If a user uses a single server where the client's database is also running on the same host then, in this case, the user cannot access the remote connection. 

However, using the Redis configuration file, users can access the remote connection. Open the configuration file of Redis by running the below-given command:

$ sudo nano /etc/redis.conf

Now, find the bind parameter in the configuration file and add your private server IP address with

Then save the configuration file and close it.

Restart Redis by executing the following command:

$ sudo systemctl restart redis

By using the 'ss' command, you can easily check if Redis is either listening on port 6379 or not.

$ ss -an | grep 6379

To check that Redis is working correctly, send the ping Redis with the following command:

$ redis-cli

5. Allow Firewall Access

Configure the firewall on your CentOS 8 system to allow access to the remote connections. First, add the new Redis zone by running the below-mentioned command:

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

Then, Add the port number '6379' by using the following command:

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

Enable firewall access to the private IP by running the below-mentioned command:

$ sudo firewall-cmd --permanent --zone=redis --add-source=private-IP-address

Finally, at the end reload the firewall by executing the below-mentioned command:

$ sudo firewall-cmd --reload

How to Uninstall Redis from CentOS 8 ?

After using Redis, you can easily uninstall it to make some free space in your system. Use the following command to remove Redis from CentOS 8:

$ sudo dnf remove redis

[Need assistance in setting up Redis on any Linux Distribution? We can help you. ]

This article covers the complete Installation guide of Redis on the CentOS 8 system. Redis is an open-source in-memory data structure store. In fact, You can use it as a Memcached alternative to store simple key-value pairs, as a NoSQL database, or even a message broker with the Pub-Sub pattern.

Also, Redis supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, HyperLogLogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.

Related Posts