Written in C language, Redis is a cross-platform opensource NoSQL, in-memory Key-value database that was written by Salvatore Sanfilippo. WIt can be used as a cache, a database, and a message broker. Redis is an acronym for Remote Dictionary Server, and in this guide, you will learn how to install Redis on Debian 10 (buster).
Requirements
A running instance of the Debian 10 server. You can deploy a fully-managed VPS or cloud server instance at only $3.71 from Cloudcone.
Data Structures in Redis
Redis is a key-value database, also regarded as a key-value store. Unlike the traditional SQL databases where data is stored in tables made up of rows and columns, in Redis, data is stored in key-value pairs. To understand a key-value pair, let’s refer to the example below on command line.
$ redis-cli SET <key> <value>
Redis uses the SET command to assign a key its value and GET command to retrieve the value assigned to the key.
For example,
$ redis-cli SET pet sammy
To retrieve the key pet run
$ redis-cli GET pet
Data structures in Redis include
- Strings
- Lists
- Sets
- Sorted Sets
- Hashes
- Hyperloglogs
- Bitmaps
Benefits of Redis
Redis ships useful benefits as listed below
- It provides asynchronous Master-Slave replication to ensure data redundancy and fault tolerance in case of system downtime.
- Redis simple and flexible, unlike in SQL where data needs to be arranged in Tables.
- It is extremely super-fast and used in telecommunication channels & web applications where response time is critical.
- Can be used as a cache system for a fully-fledged database system e.g SQL or PostgreSQL. It serves requests to and from the database and this enhances speed and overall efficiency.
- Redis is compatible with a myriad of languages such as C, C++, Python, Go, Perl and Bash, to mention a few.
How to install Redis on Debian 10
To install Redis on Debian 10 Buster, follow the steps below
Step 1: Update the system
To install Redis on Debian 10, log in to your Debian 10 instance as a regular user with Sudo privileges and update the system packages and their versions using the commands below
$ sudo apt update && apt upgrade
Step 2: Install Redis on Debian 10
With the system packages already updated and upgraded to their newer versions, install Redis using the command below
$ sudo apt -y install redis-server
After successful installation, it’s prudent to check the running status of your Redis instance. To do so, run the command
$ sudo systemctl status redis-server
The output below shows that the Redis server is up and running
If the Redis is not running, start it using the command:
$ sudo systemctl start redis-server
Additionally, you can use the netstat command as shown below to confirm that Redis is actively listening on your Debian 10 server
$ sudo netstat -pnltu
Step 3: Securing the Redis server
With Redis successfully installed and running, its time to make a few tweaks here and there to fortify its security. The main configuration file of Redis Server is found at /etc/redis/redis.conf
.
Open the file
$ sudo vim /etc/redis/redis.conf
Locate the attribute requirepass
Uncomment it, and specify your preferred password.
requirepass your_password
Save and exit the text editor. To effect the changes on the configuration file, restart the Redis server as shown
$ sudo systemctl restart redis-server
Step 4: Testing Redis
With the basic settings done and dusted, it’s time to login into your Redis Server instance.
To access Redis Server, run the command below on the terminal
redis-cli
Next, type auth followed by the password that you specified in the Redis configuration file
auth password
Awesome. Now let’s run a few commands. Let’s store the value ‘James’ in the key ‘student1’
SET student1 James
To retrieve the key student1, use the GET command as shown
GET student1
Conclusion
We’ve come to the end of this guide. In this tutorial, you learned how to install Redis on Debian 10 server. Your comments are most welcome.