Install Redis centos 7

Install Redis centos 7 | Complete tutorial in [2022]

Redis stands for Remote Dictionary Server. It is an open-source, NO-SQL,in-memory key-value data store. This blog will understand how to install redis centos 7 machines.

Install redis 3.2 on Centos 7

Install redis 3.2 on Centos 7

Install redis centos 7 via yum

We will understand how to install redis on centos via the yum package manager in this session. In centos, the recommendation is to install any package via yum.

To install redis on centos, we must first install the Extra Packages for Enterprise Linux (EPEL).EPEL is a package manager that contains several open-source add-on packages

Type the below command to install the EPEL package

yum install epel-release

Now let’s verify which redis package is available by typing the below command

yum info redis
yum info redis
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
Available Packages
Name        : redis
Arch        : x86_64
Version     : 3.2.12
Release     : 2.el7
Size        : 544 k
Repo        : epel/x86_64
Summary     : A persistent key-value database
URL         :
License     : BSD
Description : Redis is an advanced key-value store. It is often referred to as a data
            : structure server since keys can contain strings, hashes, lists, sets and
            : sorted sets.
            : You can run atomic operations on these types, like appending to a string;
            : incrementing the value in a hash; pushing to a list; computing set
            : intersection, union and difference; or getting the member with highest
            : ranking in a sorted set.
            : In order to achieve its outstanding performance, Redis works with an
            : in-memory dataset. Depending on your use case, you can persist it either
            : by dumping the dataset to disk every once in a while, or by appending
            : each command to a log.
            : Redis also supports trivial-to-setup master-slave replication, with very
            : fast non-blocking first synchronization, auto-reconnection on net split
            : and so forth.
            : Other features include Transactions, Pub/Sub, Lua scripting, Keys with a
            : limited time-to-live, and configuration settings to make Redis behave like
            : a cache.
            : You can use Redis from most programming languages also.

From the above output, it is clear that redis Version: 3.2.12 is available in this package. Now type the below command to install redis

yum install redis

Now let’s verify the redis-CLI and redis-server versions by typing the below command

redis-cli --version
redis-cli 3.2.12
redis-server --version
Redis server v=3.2.12 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=7897e7d0e13773f

Configure redis on centos7

Now you have successfully installed redis in your system. Now its time to configure redis so that a user can connect to redis via the command line

The redis configuration file can be found under


Open this file and your system IP after


where is the IP of my system where redis is installed. You can get the system IP by typing the below command


Uncomment the below line and provide a password using which you want to connect to redis

masterauth test123

Here I have given test123 as my password

Now it’s time to restart the redis service. Type the below command to enable and restart the redis service

systemctl start redis
systemctl enable redis
systemctl status redis

Now type the below command to connect to redis-CLI

redis-cli -h -p 6379 -a test123>

Redis Commands

In this session, we will try a few basic redis commands to verify if the setup is working as expected

Check if the redis server is running by typing the below command> ping

Now let’s insert data into redis by typing the below command> set my_key my_value

Type the below command to retrieve the key-value> get my_key

You can check my blog on the basic redis commands to get familiar with the basic redis commands.

How to uninstall redis on centos7

This session will help you understand how to uninstall redis on the centos system. Since redis is part of the yum package manager, it is pretty easy to uninstall redis via yum.

Type the below command to uninstall redis

yum remove redis -y

Verify if the package is uninstalled successfully by typing

yum list installed | grep redis

The above command gives no output. It means redis gets successfully uninstalled from the system.

Install redis 6 on centos 7

Install redis 6.x on Centos 7

By default, centos come with the old version of redis.To install the redis with the latest version, we need to install the remi repo first to our centos 7 repo.

Type the below command to add remi repo

yum -y install

Now we need to install redis using this remi repo. Type the below command to install redis 6. x

yum --enablerepo=remi install redis
install redis 6 on centos

verify the redis-cli version and redis-server version by typing the below command

redis-cli --version
redis-cli 6.2.6
redis-server --version
Redis server v=6.2.6 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=4ab9a06393930489

Enable TLS on redis 6 centos 7

SSL/TLS support is added in redis from version 6. To enable TLS on redis, you need to generate the tls certificates. You can use the OpenSSL library to generate tls certificates.

Redis required the below certificates.


Once you have generated these certificates, open the /etc/redis.config file and add the certificates path

tls-cert-file /path/to/redis.crt
tls-key-file /path/to/redis.key
tls-ca-cert-file /path/to/ca.crt

Now restart the redis service by typing the below command

systemctl restart redis

Directly connect to redis by typing the below command

redis-cli --tls \
    --cert ./tests/tls/redis.crt \
    --key ./tests/tls/redis.key \
    --cacert ./tests/tls/ca.crt

You can check this link to get more details about setting up tls on redis.

Install redis via docker

In this tutorial, I will be explaining how to install Redis in your system using docker.

Make sure the docker instance is running in your system

docker --version
Docker version 20.10.3, build 48d30b5

Pull the redis docker image

docker pull redis
Using default tag: latest
latest: Pulling from library/redis
69692152171a: Already exists
a4a46f2fd7e0: Already exists
bcdf6fddc3bd: Already exists
2902e41faefa: Pull complete
df3e1d63cdb1: Pull complete
fa57f005a60d: Pull complete
Digest: sha256:7e2c6181ad5c425443b56c7c73a9cd6df24a122345847d1ea9bb86a5afc76325
Status: Downloaded newer image for redis:latest

Now install the redis by typing the below command

docker run -d --name my-redis redis:latest

Goto redis container by typing the below command

docker exec -it my-redis /bin/bash

You can check my blog on installing redis via docker to get a detailed explanation.


In this blog, we have learned how to install redis on centos, and we have also learned ways to install different redis versions. We also learned how to uninstall the redis instance and quickly get a redis instance via docker.

Please do let me know if you are facing any issues while following along.

More To read?

MongoDB vs Redis

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top