Installation of Redis server in Debian 11
This guide describes how to install Redis server in Debian 11
We made in a few minutes using the console.
We log into the console and perform the installation:
1 | apt-get install redis-server -y |
We can check the service status by issuing an order:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | systemctl status redis-server Poniżej wynik: <pre class="">? redis-server.service - Advanced key-value store Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2021-09-26 02:40:45 UTC; 3s ago Docs: http://redis.io/documentation, man:redis-server(1) Main PID: 379829 (redis-server) Status: "Ready to accept connections" Tasks: 5 (limit: 9510) Memory: 6.9M CPU: 62ms CGroup: /system.slice/redis-server.service ??379829 /usr/bin/redis-server 127.0.0.1:6379 Sep 26 02:40:45 debian11 systemd[1]: Starting Advanced key-value store... Sep 26 02:40:45 debian11 systemd[1]: Started Advanced key-value store. |
By default, Redis listens on port 6379. You can verify it using the following command:
To check the redis listening, we can execute the command:
1 | ss -antpl | grep redis |
We will see a similar log:
1 2 3 | LISTEN 0 511 127.0.0.1:6379 0.0.0.0:* users:(("redis-server",pid=379829,fd=6)) LISTEN 0 1024 127.0.0.1:9121 0.0.0.0:* users:(("redis_exporter",pid=14922,fd=3)) LISTEN 0 511 [::1]:6379 [::]:* users:(("redis-server",pid=379829,fd=7)) |
We edit the redis configuration file:
1 | nano /etc/redis/redis.conf |
and add a sign # before. The whole should look like:
1 | #bind 127.0.0.1 ::1 |
Thanks to this, our redis server will only listen locally.
We also set the amount of RAM in this file:
1 2 | maxmemory 500mb maxmemory-policy allkeys-lru |
We reboot:
1 | systemctl restart redis-server |
We can get to redis from the console by issuing a command:
1 | redis-cli |
Now for an example of operation.
issue the command:
1 | 127.0.0.1:6379> ping |
We get the answer
1 | PONG |
So everything works perfectly fine.