Redis package is not included in the default CentOS repositories. It can be installed from the Remi repository.

In order to install Redis, you need to have root permission.


STEP 1. Enabling the Remi repository

sudo yum install epel-release yum-utils
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --enable remi


STEP 2. Install the Redis package by typing:

sudo yum install redis


STEP 3. Once the installation is completed, start the Redis service and enable it to start automatically on boot with:

sudo systemctl start redis
sudo systemctl enable redis


You can check the status of the service by:

sudo systemctl status redis


If you face any technical issue in using redis from remote connection, you will need to run below:

sudo sed -i 's/bind 127.0.0.1/#bind 127.0.0.1/gi' /etc/redis.conf
sudo sed -i 's/protected-mode yes/protected-mode no/gi' /etc/redis.conf
sudo /usr/sbin/setsebool httpd_can_network_connect=1

Below shell script is useful, when you monitor Redis status on your CentOS terminal

redis_info.sh
#!/bin/bash
for i in {0..1024}
do
        clear
        redis-cli info clients
        sleep 1
done

Or you can check its status as:

redis-cli --stat

To clear Redis, run:

redis-cli flushall

To get memory specific stats, run:

redis-cli info memory

If you want to check it on remote server

redis-cli -h 10.0.1.17 -p 6379 info memory

Then you will see the result like:

# Memory
used_memory:867256
used_memory_human:846.93K
used_memory_rss:16515072
used_memory_rss_human:15.75M
used_memory_peak:1155512248
used_memory_peak_human:1.08G
used_memory_peak_perc:0.08%
used_memory_overhead:805128
used_memory_startup:805128
used_memory_dataset:62128
used_memory_dataset_perc:100.00%
allocator_allocated:3713432
allocator_active:6828032
allocator_resident:14118912
total_system_memory:33565704192
total_system_memory_human:31.26G
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.84
allocator_frag_bytes:3114600
allocator_rss_ratio:2.07
allocator_rss_bytes:7290880
rss_overhead_ratio:1.17
rss_overhead_bytes:2396160
mem_fragmentation_ratio:19.04
mem_fragmentation_bytes:15647848
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:0
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0