How to Install and Configure Redis on CentOS 8 - MS TV Life.COM

How to Install and Configure Redis on CentOS 8

How to Install and Configure Redis on CentOS 8

Redis is an open-source in-memory key-value information retailer. It may be used as a database, cache and, message dealer and helps numerous information buildings resembling Strings, Hashes, Lists, Units, and extra. Redis gives excessive availability by way of Redis Sentinel and automated partitioning throughout a number of Redis nodes with Redis Cluster.

How to Remove a Git Remote

This information covers the set up and configuration of Redis on CentOS 8

.

Installing Redis on CentOS 8 #

Redis version 5.0.x is included in the default CentOS 8 repositories. To install it run the following commands as root or user with sudo privileges:

sudo dnf install redis-server

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

sudo systemctl enable --now redis

To check whether the Redis server is running, type:

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-08 20:54:46 UTC; 7s ago

That’s it. You have Redis installed and running on your CentOS 8 server.

Configure Redis Remote Access #

By default, Redis doesn’t enable distant connections. You possibly can hook up with the Redis server solely from 127.0.0.1 (localhost) – the machine the place Redis is working.

How to Install GCC (Development Tools) on CentOS 8

If you’re utilizing a single server setup, the place the consumer connecting to the database can also be working on the identical host, you shouldn’t allow distant entry.

To configure Redis to just accept distant connections open the Redis configuration file together with your textual content editor:

sudo nano /etc/redis.conf

Locate the line that begins with bind 127.0.0.1 and add your server private IP address after 127.0.0.1.

/etc/redis.conf

bind 127.0.0.1 192.168.121.233

Make sure you replace 192.168.121.233 with your IP address. Save the file and close the editor.

How to Install R on Debian 10

If you want Redis to listen to all the interfaces, just comment the line.

Restart the Redis service for changes to take effect:

sudo systemctl restart redis

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

ss -an | grep 6379

You should see something like below:

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

Next, you’ll need to configure your firewall to enable traffic from on TCP port 6379.

Typically you would want to allow access to the Redis server only from a specific IP address or IP range. For example, to allow connections only from 192.168.121.0/24, run the following commands:

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

The instructions above create a brand new zone named redis, opens the port 6379 and permits entry from the non-public community.

At this level, the Redis server will settle for distant connections on TCP port 6379.

Make certain your firewall is configured to just accept connections solely from trusted IP ranges.

How to Set Up SSH Keys on Debian 10

To confirm that the whole lot is ready up correctly, you’ll be able to attempt to ping the Redis server out of your distant machine utilizing the redis-cli utility which gives a command-line interface to a Redis server:

redis-cli -h <REDIS_IP_ADDRESS> ping

The command should return a response of PONG:

PONG

Conclusion #

We’ve proven you the way to set up Redis on CentOS 8. To study extra about the way to use Redis, go to their official documentation web page.

If in case you have questions, be happy to depart a remark under.

Copy link
Powered by Social Snap