How to Install Redis Server on Debian 11 Tutorial (Step by Step)

How to Install Redis Server on Debian 11. Want a great speed, reliability, and unparalleled performance from your application?

Well, Redis got you covered.

Remote Dictionary Server or Redis is a data structure store that can store all your data in the primary memory of your system.

The main reason why it’s super fast and reliable for different business requirements is because it stores data in memory and not in a disk or solid state drive (SSD).

What is Redis

Redis server is an in memory, open source, NoSQL key/value store that can be used as a quick response database or application cache. Redis is built to store all data in memory, which delivers better possible performance when writing and reading data.

It offers built in replication capabilities that can help you place data physically near the user for minimal latency. It uses key value pairs that can help to store data like HashMap in Java, an object in JavaScript, or a dictionary in Python.

Follow the article below to learn about Redis pros and then we will move onto how to install Redis server on Debian 11. 

Redis Features

Redis server supports geospatial indexes with radius sever queries. It holds Lua scripting and LRU eviction and other interesting features and pros are below:

In memory storage

The traditional databases access and store data from the SSDs and the hard drive, which are the secondary memory of the system. But the primary memory is faster than the secondary, and the processor can access it directly.

So Redis stores the data on the primary memory, which does the writing and reading data faster than databases that focus on storing data on the disks.

The ability to store data on the primary memory enables Redis to use a cache in multiple applications to provide agility.

Advanced data structures

Redis stores its data using multiple data structures like lists, strings, sorted sets, sets, bit arrays, hashes, streams, and hyperloglogs.

The ability to use a variety of data structures makes Redis unique compared to other in memory key value stores available in the market. It’s easier to use and implement and you won’t find it difficult to explore its maximum potential.

The data is stored in the form of the data structure as there’s no serialization required while using Redis.

Persistence

If you use the primary memory, the data is stored in volatile and gets washed away when the power source is turned off.

Redis offers great persistence with the help of its two mechanisms that help to prevent data loss. It uses append only fines and snapshots that are the backup of the Redis datastore.

It recalls the state of the database in case of power shortage or system failure to load the data from the available backups offered by Redis and prevents data losses.

Replication

Redis uses primary replica (master slave) architecture to replicate the data to multiple servers. It helps boost the read request’s performance as the request can be split into different servers to access the data faster.

You can recover the data swiftly if the primary or master server experiences any outage. The replication of the data improves the reliability factor of the Redis server and makes it stand out from the rest of the in memory key value stores.

Intelligent Caching

Redis is used for caching to store frequently accessed data in memory so that applications can be responsive to users. It is capable to know how long you want to keep data and which data to get rid of and this feature is called intelligent caching.

Data Expiration

Redis data storage can be marked with a Time To Live (TTL) and after that the data will be removed.

Great support

Redis is an open source project that offers you excellent community support. It has a diverse range of community members from different industries and experience levels contributing to enhancing the datastore.

It has no constraints regarding technology as it supports open data formats and is based on open standards. It offers support in more than 40 coding languages and creates a faster, reliable ecosystem to access data.

Multi language support

Redis supports multiple programming languages like Java, Node.js, C, C++, JavaScript, C#, Ruby, Python, PHP, R, etc. The open community support offers extensibility to Redis and makes it a very simplified technology.

Using a few code lines, you can use, access, or store data with your application, making it unique from other technologies available in the market.

Pub/Sub Messaging

Pub/Sub message allows for messages to be pushed to channels in where the right subscribers of that channel will receive that message. This feature makes it possible for information to pass quickly through your infrastructure.

Redis Sentinel

Redis offers a stand alone distributed system you can use to calibrate instances to be available to the clients. It informs users if something wrong with the master and slave instances using a series of notifications, monitoring processes and automatic failovers.

It also automatically reconfigures new connections if required for the application based on the demands of the users.

Redis cluster

Split datasets into multiple nodes with the help of the distributed implementation of Redis, also known as the Redis cluster. It supports scalability and higher performance of the database deployment and ensures continuous operations when the node subsets cannot communicate with the remaining cluster.

Follow the next steps to learn how to install Redis server on Debian 11.

How to Install Redis Server on Debian 11

Install Redis on Debian 11

By default, Redis Server package is included in the Debian 11 default repository. You can install it by just runnign the following command:

				
					apt-get install redis-server -y
				
			

Once the installation is completed, verify the Redis installation using the following command:

				
					apt-cache policy redis-server
				
			

You will get the following output:

				
					redis-server:
  Installed: 5:6.0.16-1+deb11u2
  Candidate: 5:6.0.16-1+deb11u2
  Version table:
 *** 5:6.0.16-1+deb11u2 500
        500 http://security.debian.org/debian-security bullseye-security/updates/main amd64 Packages
        100 /var/lib/dpkg/status
     5:6.0.15-1 500
        500 http://debian.gtisc.gatech.edu/debian bullseye/main amd64 Packages

				
			

Manage Redis Service

Next step in how to Install Redis Server on Debian 11 is after the Redis Server installation it will start the Redis service automatically. You can check the status of the Redis service with the following command:

				
					systemctl status redis-server
				
			

You should see the server status in the following output:

				
					● redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-03-17 13:38:12 UTC; 16s ago
       Docs: http://redis.io/documentation,
             man:redis-server(1)
   Main PID: 1073 (redis-server)
     Status: "Ready to accept connections"
      Tasks: 5 (limit: 2341)
     Memory: 7.7M
        CPU: 80ms
     CGroup: /system.slice/redis-server.service
             └─1073 /usr/bin/redis-server 127.0.0.1:6379

Mar 17 13:38:12 debian11 systemd[1]: Starting Advanced key-value store...
Mar 17 13:38:12 debian11 systemd[1]: Started Advanced key-value store.

				
			

To stop the Redis service, run the following command:

				
					systemctl stop redis-server
				
			

To start the Redis service again, run the following command:

				
					systemctl start redis-server
				
			

Connect to Redis Server

By default, Redis server listen on port 6379. You can check it using the following command:

				
					ps -ef | grep redis
				
			

You will get the Redis listening port in the following output:

				
					redis       1073       1  0 13:38 ?        00:00:00 /usr/bin/redis-server 127.0.0.1:6379
				
			

You can now use the redis-cli command-line utility to connect to the Redis instance:

				
					redis-cli
				
			

You will get the following shell:

				
					127.0.0.1:6379>
				
			

Now, ping the Redis service using the following command:

				
					127.0.0.1:6379> ping
				
			

If everything is fine, you will get the following output:

				
					PONG
				
			

Now, run the following command to exit from the Redis instance:

				
					127.0.0.1:6379> exit
				
			

Configure Redis Server

Redis default configuration file located at /etc/redis/redis.conf. You can edit it with the following command:

				
					nano /etc/redis/redis.conf
				
			

If you want to allow the remote connectin, change the following line:

				
					#bind 127.0.0.1 ::1
				
			

Next, define the memory for caching purposes by adding the following lines at the end of the file:

				
					maxmemory 1024mb 
maxmemory-policy allkeys-lru
				
			

Save and close the file then restart the Redis service to apply the changes:

				
					systemctl restart redis-server
				
			

Verify Redis Remote Connection

At this point, Redis server is configured to allow remote connection. You can check the Redis listening connection port with the following command:

				
					ss -antpl | grep redis
				
			

You will get the following output:

				
					LISTEN 0      511          0.0.0.0:6379      0.0.0.0:*    users:(("redis-server",pid=1416,fd=7))
LISTEN 0      511             [::]:6379         [::]:*    users:(("redis-server",pid=1416,fd=6))

				
			

Now, connect to the Redis instance from the remote machine by running the following command:

				
					redis-cli -h redis-server-ip ping
				
			

If everything is fine, you will get the following output:

				
					PONG
				
			

How to Install Redis Server on Debian 11 Conclusion

Congratulations! you have successfully installed and configured Redis Server on Debian 11. You can now deploy the Redis Server in the production environment and used as a database server, cache, and message broker.

 

Redis is an very popular, fast, flexible in memory database with lots of great data structures. Thanks to those features you have one of the most versatile NoSQL databases.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x