How to install and configure Redis on CentOS 8

Redis is an open source storage program that stores key-value pair data in memory. It can be used as a database, cache, information temporary storage, and supports various data structures, such as strings, hash values, lists, collections, and so on. Redis provides high availability through the automatic block processing of multiple Redis nodes in Redis Sentinel and Redis clusters.

This guide covers installing and configuring Redis on CentOS 8.

1. Install Redis on CentOS 8

Redis 5.0 is included in the CentOS 8 source repository. To install it, run the following command directly as root or another user with sudo privileges:

sudo dnf install redis-server

Once the installation is complete, enable and start the Redis service:

sudo systemctl enable --now redis

To check whether the Redis server is running, enter:

sudo systemctl status redis
● 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-02-0820:54:46 UTC; 7s ago

that's it. You have installed and running Redis on your CentOS 8 server.

Two, configure Redis remote access##

By default, Redis does not allow remote connections. You can only connect to the Redis server from 127.0.0.1 (localhost)-the machine where the Redis server is running.

If you are using a single machine, the database is also on this machine, you do not need to enable remote access.

To configure Redis to accept remote access, open the Redis configuration file with your text editor:

sudo nano /etc/redis.conf

Locate the line starting with bind 127.0.0.1 and add your server's LAN IP address after 127.0.0.1.

bind 127.0.0.1192.168.121.233

Make sure to replace 192.168.121.233 with your own IP address. Save the file and close the text editor.

If you want Redis to listen to all network interfaces, just comment out this line.

Restart the Redis service to make the application take effect:

sudo systemctl restart redis

Use the following ss command to verify that the Redis server is listening on port 6379:

ss -an | grep 6379

You should see a message similar to the following:

tcp    LISTEN    0128192.168.121.233:63790.0.0.0:*
tcp    LISTEN    0128127.0.0.1:63790.0.0.0:*

Next, you will need to configure your firewall to allow network traffic through TCP port 6379.

Usually you want to allow access to the Redis server from a specified IP address or a specified IP range. For example, to allow connections from 192.168.121.0/24, run the following command:

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.121.0/24--permanent
sudo firewall-cmd --reload

The above command creates a zone named redis, opens the port 6379 and allows access from the LAN.

At this point, the Redis server will accept remote connections from the 6379 TCP port.

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

To verify that all settings are set up, you can try to use redis-cli to ping the Redis server from your remote machine.

redis-cli -h <REDIS_IP_ADDRESS> ping

This command will return a response: PONG

PONG

Three, summary##

We have shown you how to install Redis on CentOS 8. To learn more about how to use Redis, please visit their Official Documentation Page.

Original: https://linuxize.com/post/how-to-install-and-configure-redis-on-centos-8/

Recommended Posts

How to install and configure Redis on CentOS 8
How to install and configure Elasticsearch on CentOS 7
How to install and configure VNC on CentOS 8
How to install and configure phpMyAdmin on CentOS 6
How to install and configure Owncloud on CentOS 8
How to install and configure Redmine on CentOS 8
How to install and configure NFS server on CentOS 8
How to install and configure Postfix mail server on CentOS8
How to install and configure NATS on Ubuntu 16.04
How to install and configure Gogs on Ubuntu 18.04
How to install and use Docker on CentOS 7
How to install and configure Cyberpanel on Ubuntu 18.04
How to install and configure ownCloud on Ubuntu 16.04
How to install and configure GitLab on Ubuntu 18.04
How to install and configure Ansible on Ubuntu 18.04
How to install and use Composer on CentOS 8
How to install and configure PostGIS on Ubuntu 14.04
How to install Node.js and npm on CentOS 8
How to install and configure VNC on Ubuntu 18.04
How to install and configure Sphinx on Ubuntu 16.04
How to install and configure OrientDB on Ubuntu 14.04
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
How to install and use Curl on CentOS 8
How to install and configure AppScale on Ubuntu 12.04
How to install and uninstall tomcat on centos
How to install and configure PostGIS on Ubuntu 14.04
How to install jdk1.8 on centOS7
How to install MySQL on CentOS 8
How to install Memcached on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
How to install TeamViewer on CentOS 8
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install Gradle on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Webmin on CentOS 8
How to install Ruby on CentOS 8
How to install Skype on CentOS 8
How to install htop on CentOS 8
How to install Python on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Postgresql on CentOS 8
How to install Wordpress on Centos
How to install htop on CentOS 8
How to install TeamViewer on CentOS 8
How to install MariaDB on CentOS 8
How to install MongoDB on CentOS 7
How to install Odoo 13 on CentOS 8
How to install Apache on CentOS 8
How to install OpenCV on CentOS 8