Table of Contents
In this tutorial, I will take you through the steps to install and configure Redis Server on CentOS 7. It is an in-memory data structure project implementing a distributed, in-memory key-value database with optional durability. Redis supports different kinds of abstract data structures, such as strings, lists, maps, sets, sorted sets, HyperLogLogs, bitmaps, streams, and spatial indexes. In CentOS install redis argument you need to pass through yum tool to download and install the server from Repository.
Install and Configure Redis Server
Step 1: Prerequisites
You only need to have a running CentOS 7 machine along with root access.
Step 2: Update the System
Firstly you need to update the system using yum update command.
[root@localhost ~]# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 8.4 kB 00:00
* base: centos.excellmedia.net
* epel: mirror2.totbb.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
kubernetes/signature | 454 B 00:00
kubernetes/signature | 1.4 kB 00:00 !!!
puppetlabs-pc1 | 2.5 kB 00:00
updates | 2.9 kB 00:00
No packages marked for update
Step 3: Install Redis Server
Once system is updated, you need to install redis server by using yum install redis command.
[root@localhost ~]# yum install redis
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* epel: mirrors.aliyun.com
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package redis.x86_64 0:3.2.12-2.el7 will be installed
--> Processing Dependency: libjemalloc.so.1()(64bit) for package: redis-3.2.12-2.el7.x86_64
--> Running transaction check
---> Package jemalloc.x86_64 0:3.6.0-1.el7 will be installed
--> Finished Dependency Resolution
...............................................................................................................
Step 4: Configure Redis Server
Once it is installed, you need to configure redis server by searching supervised directive in /etc/redis.conf and change the value from "no" to "systemd".
[root@localhost ~]# cat /etc/redis.conf | grep -i supervise # supervised no - no supervision interaction # supervised upstart - signal upstart by putting Redis into SIGSTOP mode # supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET # supervised auto - detect upstart or systemd method based on supervised systemd
Step 5: Restart Redis Service
Once configuration file is updated, restart redis service by using systemctl restart redis command.
[root@localhost ~]# systemctl restart redis
Check the status of Redis Service once it is restarted.
[root@localhost ~]# systemctl status redis ● redis.service - Redis persistent key-value database Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled) Drop-In: /etc/systemd/system/redis.service.d └─limit.conf Active: active (running) since Mon 2019-12-09 16:48:29 EST; 6s ago Main PID: 3655 (redis-server) CGroup: /system.slice/redis.service └─3655 /usr/bin/redis-server 127.0.0.1:6379 Dec 09 16:48:29 localhost systemd[1]: Starting Redis persistent key-value database... Dec 09 16:48:29 localhost systemd[1]: Started Redis persistent key-value database.
Step 6: Test Redis Server
After successfully gone through the steps to Install and Configure Redis Server, you need to test the connection by providing key value pair data using set command in redis-cli. Here we will provide cyberithub value to hello key. So when you try to access the value of hello, you will see cyberithub in the output.
[root@localhost ~]# redis-cli 127.0.0.1:6379> set hello cyberithub OK 127.0.0.1:6379> get hello "cyberithub"
Also Read: Install and Configure Redis on Ubuntu
Reference: Redis Documentation