• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install and Configure Redis on CentOS 8

Written by Admin, Updated On April 11, 2020
centos, redis
How to Install and Configure Redis on CentOS 8

Redis is an open-source and in-memory key-value store. It can be used as database, message broker or as a cache and supports different data structures like strings, lists, sets, maps, spatial indexes, and bitmaps. Redis supports wide languages with flexibility and high performance. In this guide, we will show how to install and configure Redis on a CentOS 8.

Prerequisites#

  • Before you start to install, you must login as root or non-root user account with sudo privileges
  • IPv6 should be enabled on your server otherwise Redis service will fail to start.

Install Redis on CentOS#

Redis version 5.0.x is included in the default CentOS 8 repositories. Run the following commands to install:

sudo dnf install redis-server

This will install Redis and its dependencies. After completion of installation, Redis service need to be enable and start by typing:

sudo systemctl enable --now redis

You can verify that Redis server is running using below command:

sudo systemctl status redis

It will show below output:

● 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
└─limit.conf
Active: active (running) since Sat 2020-04-11 12:24:14 UTC; 57s ago

That’s it! Redis is ready to use on your CentOS 8 server.

Enable Redis Remote Access#

By default, Redis is configured to listen on localhost only. You can connect to the Redis server only from the same machine where its service is running.

If you want to configure Redis to accept remote connections, open the Redis configuration file with your text editor using below command:

sudo nano /etc/redis.conf

Now find the line starting with bind 127.0.0.1 and your server private ip address after 127.0.0.1.

For example, your server’s private ip is 192.168.1.96 then it should look like below:

bind 127.0.0.1 192.168.1.96

Save and close the file.

You should restart the Redis service for changes to take effect:

sudo systemctl restart redis

Run the below command to verify:

ss -an | grep 6379

It should show as below output:

tcp LISTEN 0 128 192.168.1.96:6379 0.0.0.0:*
tcp LISTEN 0 128 127.0.0.1:6379 0.0.0.0:*

If your are using firewall, you’ll also need to add a firewall rule to enable traffic from your remote machines on TCP port 6379. Run below command to allow connections:

sudo firewall-cmd --new-zone=redis --permanent
sudo firewall-cmd --zone=redis --add-port=6379/tcp --permanent
sudo firewall-cmd --zone=redis --add-source=192.168.1.0/24 --permanent
sudo firewall-cmd --reload

The above commands will create a new zone with name redis which allows access from private network. Now the Redis server will accept remote connections on TCP port 6379.

Make sure that your firewall is configured to accept connections only from trusted IP ranges.

To test that Redis is functioning correctly, connect to the server using redis-cli utility by pinging the Redis server from your remote machine:

redis-cli -h <REDIS_IP_ADDRESS> ping

You should see exact below output:

PONG

You can exit the redis-cli shell by typing:

exit

Conclusion#

This guide shown you how to install Redis on CentOS 8. To find more information about how to manage your Redis installation, visit the Redis documentation page.

If you have any questions, feel free to leave a comment.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install Visual Studio Code on Debian 10
Next Article   How to Install Tomcat 9 on Debian 10 Linux

Related Posts

  • How to Install Php 8 on CentOS 8

    How to Install PHP 8 on CentOS 8

    January 27, 2021
  • How to Install Python 3.9 on CentOS 8

    How to Install Python 3.9 on CentOS 8

    December 31, 2020
  • How to Install GIMP 2.10 on CentOS 8

    How to Install GIMP 2.10 on CentOS 8

    December 30, 2020

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook