How to Install Redis on Linux Debian 9?

How to Install Redis on Linux Debian 9?

Redis is an Open Source NoSQL database. It is very popular, capable and remarkably fast In-Memory database. It stores the data in key-value pair and no doubtfully says it is a NoSQL database.

Installing Redis on Linux Debian 9, is very simple and follow the steps given below one by one to install the Redis on Linux Debian 9.

update all existing packages

Before Installing Redis, update all existing packages on the Linux Debian 9 by executing the below command.

sudo apt update
sudo apt-get update

install redis server

Install Redis Server by executing the below command on the Linux Debian 9.

sudo apt-get install redis-server

Redis will start installing on the Linux Debian 9 automatically and also starts the Redis service.

configure systemd process

There is an important configuration needs to be update after installing the Redis server. Open the Redis configuration file by using below command.

sudo vi /etc/redis/redis.conf

Find the word “supervised” and change the default value from “no” to “systemd” to manage and monitor the Redis service.

supervised process of Redis service

allow connections from anywhere

By Default, Redis is binding to localhost. Execute the below steps to allow the connections from anywhere to access the Redis. Open the Redis configuration file by using below command.

sudo vi /etc/redis/redis.conf

Find the word bind 127.0.0.1 and make sure it is un-commented out (remove the # if it exists)

binding to localhost

configure redis password

Follow the below steps to configure the Redis password. Open the Redis configuration file by using below command.

sudo vi /etc/redis/redis.conf

Find the word “requirepass” and set the secure password to access the Redis and make sure it is un-commented out (remove the # if it exists)

Require pass for Redis

Then, Restart the Redis service now by executing the below command.

sudo systemctl restart redis 

redis client

Execute the below command on the terminal to connect the Redis server by using Redis client.

redis-cli

The Redis client terminal will open on the same console and we can start execute the Redis commands.

set authentication on the redis client

Since we have secured the password, we should set the Authentication on the Redis client before start executing the Redis commands. Use the below command to set the password on the Redis client to access the Redis server.

auth foobared
Authentication on the Redis client

ping pong command

To check the connection between Redis server and client execute the following command on the Redis client terminal.

PING

If you get the acknowledgement, “PONG” on the console, then the connection between the server and client is stable.

ping and pong with Redis client

Execute the below Redis commands on the Redis client to store the data as Key-Pair value on the Redis server.

set employee John

get employee
set and get Redis key pair data

monitor and manage the redis service

By executing below commands, we can monitor and manage the Redis service on the Linux Debian 9.

To view the current status of the Redis service.

sudo systemctl status redis

To stop the Redis service.

sudo systemctl stop redis

To start the Redis service after it got stopped.

sudo systemctl start redis 

If any Redis configuration got update, we should restart the Redis service. Execute the below command to restart the Redis service.

sudo systemctl restart redis 

By default Redis service will start when the system starts. To disable that execute the below command.

sudo systemctl disable redis

Execute the below commands to enable the Redis service once again after it got disabled.

sudo systemctl enable redis-server.service

How useful was this post?

Click on a star to rate it!

As you found this post useful...

Follow us on social media!

Advertisements

Post your comments