Redis stands for Remote Dictionary Server and is an open-source data store. It supports various types of abstract data structures such as maps, lists, data sets, streams, strings, etc.
It was initially released back in 2009 and is one of the most popular key-value database applications when it comes to open-source. Redis usually writes data to a file system every 2 seconds, so that if there is a complete system failure, very little data would be lost.
In this tutorial, we’ll cover all steps to install and run the Redis server on Debian 11.
Table of Contents
Prerequisites
- Server running Debian 11
- Root access
Installing Redis Server
The Redis package is by default included on Debian 11 repository. You can proceed with a pre-update before the installation:
apt-get update -y; apt-get upgrade -y
After the update is done, you can install Redis with this command:apt-get install redis-server -y
Once your installation is done, you can check the status from your redis with the following command:systemctl status redis-server
You should see an output like this:
root@server:~# systemctl status redis-server
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-11-27 01:54:46 EST; 49s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 14406 (redis-server)
Status: "Ready to accept connections"
Tasks: 5 (limit: 4678)
Memory: 7.2M
CPU: 244ms
CGroup: /system.slice/redis-server.service
└─14406 /usr/bin/redis-server 127.0.0.1:6379
Nov 27 01:54:46 server.domain.com systemd[1]: Starting Advanced key-value store...
Nov 27 01:54:46 server.domain.com systemd[1]: Started Advanced key-value store.
Configuring Redis
Generally, the usage for Redis is for caching purposes. We need now to edit the config file located at:/etc/redis/redis.conf
And will define a memory limit to our instance, by adding the following lines at the end of our file:maxmemory 500mb maxmemory-policy allkeys-lru
If you want your redis to be publicly accessible, you need to comment on the following line on the above file:#bind 127.0.0.1 ::1
Then just restart your redis with:service redis restart
You can see on which port Redis is running with this command:ss -tulpn | grep redis
You should see an output like this:
tcp LISTEN 0 511 0.0.0.0:6379 0.0.0.0:* users:(("redis-server",pid=14634,fd=7))
tcp LISTEN 0 511 [::]:6379 [::]:* users:(("redis-server",pid=14634,fd=6))
So, in the above output, we can see the port in my case is 6379. To fully enable remote access, it’s needed to set protected-mode to NO, so, to do that we need to run this command:
root@server:~# redis-cli CONFIG SET protected-mode no
Output: OK
Once you are done, your Redis is ready to be used and you should be able to connect to it without problems. You can test the remote connection by running the following command:
root@server:~# redis-cli -h `hostname -i` ping
PONG
That’s it. You have successfully installed Redis server on your Debian 11. Of course, if you have any Linux VPS hosting with us, you don’t need to do this installation.
Our admins are available 24/7/365 to help you with those steps and would gladly set up any additional installation, for free.