Oct 3, 2023 4 min read

How to Install Redis on Debian 11

Install Redis on Debian 11 with our step-by-step tutorial. Redis is an open-source, in-memory data store used as a database, and message broker.

Install Redis on Debian 11
Table of Contents

Choose a different version or distribution

Introduction

Before we begin talking about how to install Redis on Debian 11, let's briefly understand – What is Redis?

Redis is an open-source, in-memory data structure store that is often used as a database, cache, and message broker. It provides high-performance and low-latency access to data as it stores information in memory.

Redis supports various data structures like strings, lists, sets, hashes, and more, making it versatile for a wide range of use cases. It offers features like replication, persistence, pub/sub messaging, and built-in support for complex operations, allowing developers to build scalable and efficient applications.

In this tutorial, you will install Redis on Debian 11. We will also address a few FAQs on how to install Redis on Debian 11.

Advantages of Redis

  1. High Performance: Redis is an in-memory data structure store that offers exceptionally fast data access and response times, making it ideal for caching and real-time applications.
  2. Scalability: Redis supports horizontal scaling, allowing you to distribute and scale your data across multiple nodes effortlessly.
  3. Versatility: With support for various data structures like strings, lists, sets, and more, Redis can be used for a wide range of use cases, such as caching, session management, messaging, and analytics.
  4. Durability: Redis offers optional data persistence, allowing you to store data on disk and ensuring its availability even after system restarts or crashes.
  5. Simple and Easy-to-Use: Redis provides a straightforward and easy-to-understand API, making it convenient to integrate into your applications, with client libraries available for most programming languages.

How to Install Redis on Debian 11

Before starting the Redis installation process, it is advised to use the command to update the Debian 11 repository:

sudo apt update

We will install Redis by running the following command once the package is up-to-date:

sudo apt install redis-server -y

We will use the systemctl command to verify the package's status after it has been installed:

sudo systemctl status redis-server

The output indicates that Redis has been successfully installed and is currently operational.

How to Configure Redis on Debian 11

With the aid of the nano editor, we will open the configuration file located at the path /etc/redis/redis.conf in order to alter the Redis configuration settings on Debian 11.

sudo nano /etc/redis/redis.conf

A configuration file will seem as follows:

Allowing remote access is the next step, so locate the line that reads "bind 127.0.0.1:: 1" and just comment it by adding the hash character "#" in start:

Update the port to 6379 for security reasons, as shown:

Last but not least, add these two lines to the end of the configuration file to boost the server's memory:

maxmemory 500mb 
maxmemory-policy allkeys-lru

To set the Redis password, type "foobared" into the search box as:

Uncomment it, replace the foobared with anything else to establish your password, such as "itslinux" in our case.

Press CTRL+X to leave the editor now, but CTRL+S to save the file first. Using the systemctl command, restart Redis:

sudo systemctl restart redis-server

Once more, use the systemctl command to check the status:

sudo systemctl status redis-server

After successfully completing the configuration process, run the following command to connect Redis to Debian:

redis-cli

Type the following to verify the connection:

>ping

It will ask for a password, so enter "itslinux" when prompted. Then, carry out the following:

> AUTH itslinux

The connection has been successfully formed when the output says "OK." Now, we can delete Redis from Debian 11 by using the following command:

sudo apt remove redis-server -y

FAQs to Install Redis on Debian 11

Are there any specific prerequisites for installing Redis on Debian 11? 

No, there are no specific prerequisites. You just need a Debian 11 system with root privileges.

Can I check if Redis is running after installation? 

Yes, you can check the Redis service status by using the command sudo systemctl status redis-server.

Where is the Redis configuration file located on Debian 11? 

The Redis configuration file is located at /etc/redis/redis.conf on Debian 11.

How can I enable Redis to start on system boot? 

Run the command sudo systemctl enable redis-server to enable Redis to start automatically during system boot.

Can I modify the default Redis configuration? 

Yes, you can modify the Redis configuration by editing the /etc/redis/redis.conf file. Remember to restart Redis for changes to take effect.

How do I restart the Redis service on Debian 11? 

Use the command sudo systemctl restart redis-server to restart the Redis service.

How can I secure Redis on Debian 11? 

To secure Redis, configure firewall rules, bind Redis to specific IP addresses, set up password authentication, and disable remote access if not required. Consult the Redis documentation for detailed instructions on securing your Redis installation.

Conclusion

Redis is an open-source NoSQL database server used to handle website data in an ordered manner in the form of key values. In this tutorial, we covered how to install Redis on Debian 11, how to configure it, how to set the password for Redis using the configuration file, and how to connect Redis to Debian using port 6379.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.