Redis is an open-source in-memory database for storing data structure, caching, and as a message broker. It supports data structures such as strings, lists, sets, hashes, sorted sets with range queries, bitmaps, HyperLogLogs, and geospatial indexes with radius queries. Redis has a built-in replication feature, which makes it work as high available clusters in your production environments.

This tutorial will help you to install the Redis on Debian 11 (Bullseye) Linux system.

Updating System Packages

It’s a good practice to keep packages up to date on your system. You should always update the before beginning any major installations. Issue the command below:

sudo apt update 
sudo apt upgrade 

Installing Redis on Debian 11

Redis 6.0 packages are available under the default Bullseye repositories. You can quickly install Redis by using the apt package manager on your Debian Linux system.

sudo apt install redis-server 

Once the installation finished successfully, check the Redis service status by the below-mentioned command.

sudo systemctl status redis.service 
How to Install Redis on Debian 11 Linux Database Databases nosql redis
Redis Service Status

Configuring Redis

You can use Redis with the default settings from the local system. But in case you need to customize the Redis server like allow access from remote hosts, change the default port or increase the memory allocation.

Edit the Redis configuration file in a text editor:

sudo nano /etc/redis/redis.conf 

Now, make the required changes to the Redis server. Below are some quick uses changes in the Redis server.

  • Change Redis Port: You can run your Redis server to a non-standard port. This is good practice for security purposes. Search for the below section and update the port under at port 6379.

    # Accept connections on the specified port, default is 6379 (IANA #815344).

    # If port 0 is specified Redis will not listen on a TCP socket.

    port 6379

  • Allow Remote Connection: Search for bind 127.0.0.1 ::1 line and comment it by adding “#” at start of line.

    # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES

    # JUST COMMENT OUT THE FOLLOWING LINE.

    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    # bind 127.0.0.1 ::1

  • Change Memory Allocation: Update the following values in Redis configuration file according to your requirement. You can increase max memory limit as per available memory on your server.

    maxmemory 256mb

    maxmemorypolicy allkeyslru

Make necessary changes and save the file. Then restart the Redis service to apply changes.

sudo systemctl restar redis.service 

Connect to Redis

Type redis-cli on command lien to connect to the Redis server.

redis-cli 

You will get the Redis server prompt as below. Now type “ping” on the Redis command prompt. On successful connection with the Redis server, you will get PONG as a result.

"> ping 
PONG

Conclusion

This tutorial helps you with the installation of the Redis server on the Debian 11 Bullseye Linux system.


You can find more details about redis-cli command line tool from its official documentation.