Install & Configure Redis on RHEL / CentOS 8

Published on February 26, 2020 59 sec read

Redis is an open-source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. Today we’ll install & configure Redis on RHEL / CentOS 8 server.

Table of Contents

  1. Install Redis Server
  2. Test Redis
  3. Open Firewalld Port
  4. More Info

Install Redis Server

Redis server is available in default CentOS 8 repositories. To install the Redis server package run this command:

sudo dnf install -y redis

Now enable & start Redis using:

# enable
sudo systemctl enable redis
# start
sudo systemctl start redis

Check Redis server version to confirm the installation:

redis-server -v

Let’s check redis-cli:

# start cli
redis-cli
# type ping
127.0.0.1:6379> ping
# output
PONG
# type exit to exit cli
127.0.0.1:6379> exit

Test Redis

Start redis cli and try to set & get data:

# start cli
redis-cli
# set data
set myName "Obydul"
# get data
get myName
# output
"Obydul"
# type exit to exit cli
127.0.0.1:6379> exit

If you see the results like above then Redis is working on your server perfetly.

Open Firewalld Port

If you’re using Firewalld, then follow this step otherwise skip this step. Let’s open Redis port 6379 permanently:

sudo firewall-cmd --add-port=6379/tcp --permanent

We’ve opened the Redis port. We can also allow external server IP to access our Redis server. To do this, we need to provide access like this:

sudo firewall-cmd --zone=redis --add-source=CLIENT_IP_ADDRESS --permanent

Replace CLIENT_IP_ADDRESS with your external server IP.

The reload the firewall:

sudo firewall-cmd --reload

More Info

To allow remote connection we’ve to bind remote IP. Add the external server IP after bind 127.0.0.1:

# open config file
sudo nano /etc/redis.conf
# find 'bind' and add IP
bind 127.0.0.1 CLIENT_IP_ADDRESS

To know more about Redis, please read their documentation.

That’s all!

Author

Hey, I'm Md Obydullah. I build open-source projects and write on Laravel, Linux server, modern JavaScript and more on web development. If you enjoy my content, please consider supporting what I do!

Follow Buy me a coffeeBuy me a coffee

Leave a Reply

Your email address will not be published. Required fields are marked *