Offshore Hosting, Offshore VPS, Offshore Servers | WebCare360

About Us Contact Us Legal / AUP Blog

How to Install and Configure Redis Server on CentOS 7

by John Doe

What is Redis:

Redis is a caching system that works by temporarily storing information in a key-value data structure. Redis is popular because it is available in almost all major programming languages. By caching data, Redis can speed up the process of retrieving information. When a user requests information that is not cached, Redis will fetch the data from the database and return it to the user.

Redis is an open source, in-memory data structure store, used as a database, cache, and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, and geospatial indexes with radius queries.

Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence.

Redis is used as a database by web applications such as WordPress and Drupal. It is also used for object caching by platforms such as Magento.

In this step-by-step guide, I will walk you through the steps to install Redis Server on CentOS 7. CentOS requires that you run through yum to install Redis Server from the official repository.

Step 1 – Prerequisites:

Step 2 – Update the Operating System:

  •   First, you need to upgrade the system using yum update.
[[email protected] ~]# 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 the Redis Server:

  •    After your machine is updated, you need to update redis with the yum install redis command.
[[email protected] ~]# yum install redis
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* epel: mirrors.webcare360.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 – Configuration of Redis Server

  •    Access this command in the Redis configuration file through the supervised directive. Change the value from “no” to “systemd”.
[[email protected]~]# 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 the Redis Server:

  •   Restart the redis service by using systemctl restart redis command once the configuration file is updated.
[[email protected]~]# systemctl restart redis

Do check the status of the Redis Service is checked when it’s restarted.

[[email protected] ~]# 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 the installation and the configuration of Redis server following these installation steps, you will need to test Redis connection by giving a key value pair using the set command in redis-cli. Here we can post the value WebCare360 to hello key. When we try to access the value of hello key, we will discover WebCare360 in the output.

[[email protected]~]# redis-cli
127.0.0.1:6379> set hello webcare360
OK
127.0.0.1:6379> get hello
"webcare360"

Reference: Redis Documentation

Related Blogs

How to Disable SELinux on CentOS 7

What is SELinux? SELinux is a powerful security feature that has been around for over 20 years, gaining more and more popularity with each passing

CONNECT

Stay in the Loop