Install a Redis server on Debian 11

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. In this post, we will install a Redis server in Debian 11. For this, we will use the Debian repository that provides the most suitable way.

According to the Redis website:

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker.

Redis is used in situations where access to data has to be done as quickly as possible. Thus, it is possible to have lower response times on data requests without sacrificing flexibility in the data structure.

In addition to this, Redis works in cluster replication where data is copied to other servers, thus increasing the speed.

Fortunately, Redis is an open-source project that we can track its source code.

In short, Redis is an interesting project used in specific situations. Today we will install it and make some small configurations.

Installing Redis on Debian 11

Redis can be installed from the official Debian repositories. This makes the process easy to follow, but also very secure.

Connect to your server and update it.

sudo apt update
sudo apt upgrade

After this, install the Redis package using the command.

sudo apt install redis-server

This way, Redis will be on the system. What remains to be done is to start the service.

sudo systemctl start redis-server

And make it enabled to start with the system.

sudo systemctl enable redis-server

Then, you can see if Redis is working properly by checking the status of the service.

systemctl status redis-server
1.- Redis status
1.- Redis status

So, another way to check is to verify the ports in use.

ss -tulpn
2.- Check the ports
2.- Check the ports

So Redis is already running.

Configuring Redis a bit

The Redis configuration resides in the /etc/redis/redis.conf file that we have to edit. I recommend always backing it up.

sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.bak

Now let’s edit it:

sudo nano /etc/redis/redis.conf

So, redis is mainly used for cache. You can increase the size of the cache to use by adding these two lines at the end of the file.

maxmemory 1024mb
maxmemory-policy allkeys-lru

In them, we are defining 1024 Megabytes, but you can change this value.

You can also change the Redis listening port.

port [port]

By default, Redis listens only for requests from the same server, i.e., localhost. If you want to enable remote access, find this line.

bind 127.0.0.1 ::1

And comment it out

#bind 127.0.0.1 ::1

So, that should be enough for now. Save the changes and close the text editor.

To apply all these changes, restart Redis.

sudo systemctl restart redis-server

Testing Redis on Debian 11

Then, to check that Redis is properly installed, we have to connect to the console.

sudo redis-cli 

In it, run a test command.

ping

And you will get a test response

PONG
3.- Redis on Debian 11
3.- Redis on Debian 11

So, we will know that Redis is installed correctly.

Conclusion

So, in this post, you learned how to install Redis on Debian 11. I hope it helped you. Thank you.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook