Raspberry Pi

How to Install Redis on Raspberry Pi

Redis, commonly referred to as Remote Dictionary Server, is a free and open-source non-relational database system that acts as a data-structure store to save the data in your system’s main memory. The data is stored in the form of key-value as it has two separate columns where one column is assigned for storing the key, while the other column is used for storing the value. It has more robust functionality than other database systems, such as MySQL and MariaDB. It is beneficial in increasing your applications’ performance when used as a cache on top of other database systems.

In this article, we will discuss the different ways through which you can install Redis on Raspberry Pi.

How to Install Redis on Raspberry Pi

There are two simplest approaches to install Redis on Raspberry Pi, either you can install it through the Raspberry Pi repository, or you can use the Snap Store services to install this database on your system. A detailed explanation of both these methods is discussed as under.

1: Install Redis on Raspberry Pi Using the Raspberry Pi Repository

This Redis installation on Raspberry Pi is straightforward as the developers already include its repository into the Raspberry Pi source list and you just need to apply the following command to install this database on your system:

$ sudo apt install redis-server -y

After completing the Redis installation, you need to use the following command to start its services on Raspberry Pi:

$ sudo systemctl start redis.service

Once the Redis service starts without an error, you can execute the following command to check its running status on Raspberry Pi:

$ sudo systemctl status redis.service

Testing Redis on Raspberry Pi

After successfully installing Redis on Raspberry Pi, it’s now time to test it through the following command:

$ redis-cli

With the above command successfully loaded, you can test the Redis connectivity through the ping command and if it replies with the output pong, it means the Redis server is alive and running on your system.

After ensuring that the server is running, you can test it by sending a statement of your choice using the following command and if it replies with an “OK” message, then the test is successful.

set testmessage “<Statement>

To output the test result, you can use the following command:

get testmessage “<Statement>

You can use the quit command or “CTRL+C” to exit the test.

Remove Redis From Raspberry Pi

To remove Redis from Raspberry Pi, you can apply the following command:

$ sudo apt remove redis-server -y

2: Install Redis From Snap Store

You can also install Redis from the snap store; however, before that, you just need to install Snap Store on your Raspberry Pi using the following command:

$ sudo apt install snapd

With the snap store installation completed, you can install Redis through the following command:

$ sudo snap install --edge redis

If the Redis install from snap store unable to start its service on your Raspberry Pi, you can unmask it if there is a conflict with other service and you can do so using the following command:

$ sudo systemctl unmask redis-server.service

After unmasking, you can start and check the Redis status through systemctl commands already mentioned in Method 1.

Remove Redis From Snap Store

To remove Redis from the snap store, you just need to apply the following command in the terminal window:

$ sudo snap remove redis

Conclusion

Redis is an open-source database system with more robust functionality than other database systems, as it also increases the performance of your application. You can install it on your Raspberry Pi either from the official repository or the snap store, as both installation methods are provided in the above guidelines. If you want to give this database a go, you should follow any method and install it on your Raspberry Pi device.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.