Redis

How to Install Redis on Debian 11

Redis is a popular key value store with extensive features including sharding, clustering, graph, time series and much more which has made it very popular with developers. It has many of the features you need to build a web app and scale it to large scale. In this article we will demonstrate how to install Redis on Debian Linux version 11. Let’s get started

NOTE: This demo is done on Debian 11 running on WSL (windows subsystem for linux). Slight variations may be needed on Debian 11 running on other cloud or virtualization platforms or natively on bare metal.

Update Debian 11 System First

Running the following commands in your terminal to make sure your system is ready for installation:

$ sudo apt update
$ sudo apt upgrade

Install Redis on Debian 11

Now install Redis Server package which will also include client packages

$ sudo apt-get install redis-server

Start Redis Server

You can now manually start a Redis daemon with redis-server command. Also you can verify it is started with ps command:

$ sudo redis-server /etc/redis/redis.conf
$ ps -ef | grep redis

Interact with Redis using the redis-cli

Test your redis instance locally using the redis-cli utility. Enter the interactive shell and insert a couple key values, print the key count and fetch a value from a key. Then delete everything with flushall. Here is the code:

Enter the redis-cli:

$ redis-cli

Insert a couple keys and then get the key count

127.0.0.1:6379> set f1 "apple"
127.0.0.1:6379> set f2 "banana"
127.0.0.1:6379> set f3 "orange"
127.0.0.1:6379> DBSIZE

Fetch the value of key “f3” and then delete all keys and verify key count:

127.0.0.1:6379> get f3 "apple"
127.0.0.1:6379> FLUSHALL
127.0.0.1:6379> DBSIZE

Conclusion of Installation of Redis

Redis is installed now on Debian 11, using these sample steps. This is good enough for testing and developing with Redis. For production usage of Redis, best practices would be to ensure Redis daemon is supervised using the normal system init scripts. You can see options for this in the redis configuration file and check other tutorials on how to ensure Redis is auto-started and monitored in your system.

About the author

Linux Wolfman

Linux Wolfman is interested in Operating Systems, File Systems, Databases and Analytics and always watching for new technologies and trends. Reach me by tweeting to @linuxhint and ask for the Wolfman.