Installing Redis on a Centos 7.x Server

Redis is an open source, in memory key-value data store which can be used as a database, cache and as a message broker. Redis provides data redundancy and high availability via Redis Sentinel and automatic partitioning with Redis Cluster.

This article assumes that you have a 64 bit server with Centos 7.x installed. We will be taking a look on how to install redis.

As redis is not available by default in Centos, we will be installing redis via the corresponding EPEL repository.

$wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm

$rpm -ivh epel-release-7-9.noarch.rpm

If wget is not installed, install the package by running $yum install wget

Update the packages in the system by running

$yum update -y

After the update has completed, redis can be installed by running the below command:

$yum install redis -y

Start the redis service using the following command:

$systemctl start redis.service

The status of the redis service can be checked via running:

$systemctl status redis.service
 
redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled)
Drop-In: /etc/systemd/system/redis.service.d
   └─limit.conf
Active: active (running) since Wed 2017-03-25 07:34:48 PST; 4s ago
Main PID: 18868 (redis-server)
CGroup: /system.slice/redis.service
   └─18868 /usr/bin/redis-server 127.0.0.1:6379

6379 is the default port number that redis service listens to.

We should get a PONG reply when issuing the below command:

$redis-cli ping

We now have a redis server up and running with the default configuration.

Auto start of redis service after server reboots can be configured with the below command:

systemctl enable redis.service

With this installation, redis can be accessed only via the localhost (server itself). For redis to be accessed from the internet comment the below line in /etc/redis.conf:

#bind 127.0.0.1

We will be learning about securing our redis installation in another article. We have a redis server up and running and its now time to save memory space in your application server by storing session and page cache in your redis server!!