How to Install Redis in Linux Machine(CentOS)

Welcome back folks, this is the continuation part of Redis complete guide. In the last article, we have seen, how to install the Redis server on the windows environment.

In the windows environment. We had certain limitations in using the Redis server. Also, a recommendation from the Redis lab not to use the windows version for the Production environment.

Prerequisites

In this guide, I am going to install the Redis server on the CentOS Linux 8 server machine. So, you need to have the CentOs up and running with non-root users with Sudo privileges.

How to Install Redis in Linux Machine(CentOS) 1

Install Redis in CentOs

Before we can install Redis, we must first add Extra Packages for Enterprise Linux (EPEL) repository to the server’s package lists. EPEL is a package repository containing a number of open-source add-on software packages, most of which are maintained by the Fedora Project.

sudo yum install epel-release
add Extra Packages for Enterprise Linux (EPEL) repository to the server’s package lists

Once the EPEL installation has finished you can install Redis. Try below command to install the Redis server.

 sudo apt install redis-server
Install Redis server on CentOs

Once the installation is completed. You can start the service by issuing a command shown below.

sudo systemctl start redis.service

Once you start the service. Please validate the status by issuing a service status command.

sudo systemctl status redis.service
How to Install Redis in Linux Machine(CentOS) 2

If you’d like Redis to start on boot, you can enable it with the following command.

sudo systemctl enable redis

That’s it you are done with the installation of Redis. Now confirm it by pinging the Redis server.

sudo redis-cli ping
Ping Redis server using ping command

As you can see in the terminal. Pong messages will be shown. This proves that the Redis server has been installed successfully.

Access Redis Remotely

Once done with the installation. You have to configure the redis server to be access by specific IP address and port to the consumer applications.

Bind Ip Address to Redis

We can bind the ipaddress to the redis server by editing the redi.config file.To do that open the redis.config in your favorite editor and update the following information.

sudo vi /etc/redis.conf

Look for the commented line called bind followed by Ip Address and change the IpAddress of your machine or VM.

How to Install Redis in Linux Machine(CentOS) 3

Restart the Redis after adding your IP address. Also, you need to change some firewall settings to allow port number 6379 which is the default port for the s server.

sudo firewall-cmd --new-zone=redis --permanent
sudo firewall-cmd --zone=redis --add-port=6379/tcp --permanent
sudo firewall-cmd --zone=redis --add-source=192.168.1.106 --permanent
sudo firewall-cmd --reload
sudo systemctl restart redis

Once the Redis server is restarted. You should be able to connect to it by using the address assigned there. Try to connect with the s server by issuing this command.

redis-cli -h 192.168.1.108 
How to Install Redis in Linux Machine(CentOS) 4

The More you learn, The more you earn

Warren Buffett

With this quote lets continue!

We tried connecting to the Redis server in the same VM where we have installed the Redis.

Now try to connect it by using some other machine or the host machine if you are running the HyperV or virtual machine.

I have installed the Redis on HyperV CentOs. And, want to connect from my windows machine.

Redis CLI Download

As we know we can connect to the Redis server by using Redis-CLI client. I have two options now.

  1. I can install the Redis server on my windows machine and use Redis-CLI to test the connection.
  2. Write some lines of code in any of the languages like (C#, Java, Python) and try to connect to the Redis server.
  3. Another alternate solution is to download the npm package using npm and test the connection.

Since i have already installed the Node.Js in my machine. So, i will go with installing the npm package and test the connection with Redis server.

npm i redis-cli

Once done with the installation try connecting to the Redis server by using this command.

rdcli -h 192.168.1.108
How to Install Redis in Linux Machine(CentOS) 5

If you see the similor screen means you are successfully connected to the Redis server.

Wrapping it up!

So, in this article, we have covered these many topics.

  • How to install the Redis Server on CentOs.
  • Ping the Redis using Redis-CLI client.
  • Assign Ip address to the Redis server by updating the /etc/redis.conf file.
  • Access Redis server remotely using Redis-CLI client.

Let us know your comments or concerns in the comment section.

Comments are closed.

Scroll to Top