How To Install and Configure Redis on Debian 10 Linux

How To Install and Configure Redis on Debian 10 Linux

All

Linux Articles / All 43 Views comments

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

On this tutorial, we'll cowl the best way to set up and configure Redis on a Debian 10, Buster.

Putting in Redis on Debian

Redis model 5.zero.x is included within the default Debian 10 repositories. To put in it run the next instructions as root or user with sudo privileges:

sudo apt replace
sudo apt set up redis-server
```console-bash

The Redis service will begin routinely when the set up finishes. You'll be able to confirm it by typing:

```console-bash
sudo systemctl standing redis-server

The output ought to look one thing like this:

● redis-server.service - Superior key-value retailer
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Lively: lively (operating) since Thu 2019-11-28 14:15:23 PST; 27s in the past
     Docs: http://redis.io/documentation,
           man:redis-server(1)
 Essential PID: 2024 (redis-server)
    Duties: four (restrict: 2359)
   Reminiscence: 6.9M
   CGroup: /system.slice/redis-server.service
           └─2024 /usr/bin/redis-server 127.zero.zero.1:6379

Redis service will fail to start out if IPv6 is disabled in your server.

That is it! Redis is put in and operating in your Debian 10 server, and you can begin utilizing it.

Configure Redis Distant Entry

By default, Redis is configured to pay attention on localhost solely. You'll be able to hook up with the Redis server solely from the machine the place the Redis service is operating.

In case you are utilizing a single server setup, the place the shopper connecting to the database can also be operating on the identical host, you shouldn't allow distant entry.

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

sudo nano /and so on/redis/redis.conf

Seek for a line that begins with bind 127.zero.zero.1 ::1 and remark it.

/and so forth/redis/redis.conf

# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# bind 127.zero.zero.1 ::1

Save the file and shut the editor.

Restart the Redis service for modifications to take impact:

sudo systemctl restart redis-server

Use ss or netstat to confirm that Redis is listening on all interfaces on port 6379:

ss -an | grep 6379

You need to see one thing like under:

tcp  LISTEN  zero  128  zero.zero.zero.zero:6379  zero.zero.zero.zero:*                     
tcp  LISTEN  zero  128  [::]:6379     [::]:* 

You will additionally want so as to add a firewall rule that permits visitors out of your distant machines on TCP port 6379.

Assuming you're utilizing UFW to handle your firewall, and also you need to permit entry from the 192.168.121.zero/24 subnet, you'd run the next command:

sudo ufw permit proto tcp from 192.168.121.zero/24 to any port 6379

Be certain that your firewall is configured to simply accept connections solely from trusted IP ranges.

As soon as executed, use the redis-cli utility to check the connection by pinging the Redis server out of your distant machine:

redis-cli -h <REDIS_IP_ADDRESS> ping

The command ought to return a response of PONG:

PONG

Conclusion

We have now proven you the right way to set up Redis on Debian 10. To seek out extra details about methods to handle your Redis set up, go to the Redis documentation web page.

Should you hit an issue or have suggestions, depart a remark under.

Comments