How to install and configure redis on CentOS 7 step by step guide

How to install and configure redis  on CentOS 7 step by step guide

In this tutorial we learn how to What is edis and how to install and configure redis on centos 7 step by step guide.

What is redis

Redis is an open-source in-memory data structure store. Redis can be used as a database, caching purpose  and supports various data structures such as Strings, Hashes, Lists, Sets, etc.

Installation redis on centos 7

By default redis package is not available in the centos repository. So we need to enable remi repository to install redis package on the centos server. To install the remi repo we need to execute the below commands.
[root@localhost ~]# yum install epel-release yum-utils

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
---> Package yum-utils.noarch 0:1.1.31-50.el7 will be installed
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-50.el7.noarch
--> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-50.el7.noarch
--> Running transaction check
---> Package libxml2-python.x86_64 0:2.9.1-6.el7_2.3 will be installed
---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
--> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
--> Running transaction check
---> Package python-chardet.noarch 0:2.2.1-1.el7_1 will be installed
--> Finished Dependency Resolution
……………………….

Installed:
  epel-release.noarch 0:7-11                                                      yum-utils.noarch 0:1.1.31-50.el7

Dependency Installed:
  libxml2-python.x86_64 0:2.9.1-6.el7_2.3                  python-chardet.noarch 0:2.2.1-1.el7_1                  python-kitchen.noarch 0:1.1.1-5.el7

Complete!

[root@localhost ~]# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Loaded plugins: fastestmirror
remi-release-7.rpm                                                                                                                               |  15 kB  00:00:00
Examining /var/tmp/yum-root-F256As/remi-release-7.rpm: remi-release-7.6-1.el7.remi.noarch
Marking /var/tmp/yum-root-F256As/remi-release-7.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package remi-release.noarch 0:7.6-1.el7.remi will be installed
--> Finished Dependency Resolution
Total size: 18 k
Installed size: 18 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : remi-release-7.6-1.el7.remi.noarch                                                                                                                   1/1
  Verifying  : remi-release-7.6-1.el7.remi.noarch                                                                                                                   1/1

Installed:
  remi-release.noarch 0:7.6-1.el7.remi

Complete!

And the type the below command.

[root@localhost ~]# yum-config-manager --enable remi

 To install redis package type the below command.

[root@localhost ~]# yum install redis
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: mirror.horizon.vn
 * extras: centos.excellmedia.net
 * remi: mirror.awanti.com
 * remi-safe: mirror.awanti.com
 * updates: centos.excellmedia.net
epel                                                                                                                                                        12780/12780
Resolving Dependencies
--> Running transaction check
---> Package redis.x86_64 0:5.0.3-1.el7.remi will be installed
--> Finished Dependency Resolution

Installing:
 redis                                x86_64                                5.0.3-1.el7.remi                                  remi                                919 k

Install  1 Package

Total download size: 919 k
Installed size: 3.0 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/remi/packages/redis-5.0.3-1.el7.remi.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY] 126 kB/s | 908 kB  00:00:00 ETA
Public key for redis-5.0.3-1.el7.remi.x86_64.rpm is not installed
redis-5.0.3-1.el7.remi.x86_64.rpm                                                                                                                | 919 kB  00:00:08
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Importing GPG key 0x00F97F56:
 Userid     : "Remi Collet <RPMS@FamilleCollet.com>"
 Fingerprint: 1ee0 4cce 88a4 ae4a a29a 5df5 004e 6f47 00f9 7f56
 Package    : remi-release-7.6-1.el7.remi.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : redis-5.0.3-1.el7.remi.x86_64                                                                                                                        1/1
  Verifying  : redis-5.0.3-1.el7.remi.x86_64                                                                                                                        1/1

Installed:
  redis.x86_64 0:5.0.3-1.el7.remi

Complete!

Once installation is completed we need to start redis service and enable the service at the startup mode and check the status of the service using the below commands.

[root@localhost ~]# systemctl start redis

[root@localhost ~]# systemctl enable redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.

[root@localhost ~]# systemctl status redis
● redis.service - Redis persistent key-value database
   Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/redis.service.d
           └─limit.conf
   Active: active (running) since Tue 2019-01-01 20:49:29 IST; 1min 27s ago
 Main PID: 1259 (redis-server)
   CGroup: /system.slice/redis.service
           └─1259 /usr/bin/redis-server 127.0.0.1:6379

Jan 01 20:49:29 localhost.localdomain systemd[1]: Starting Redis persistent key-value database...
Jan 01 20:49:29 localhost.localdomain systemd[1]: Started Redis persistent key-value database.
How to install and configure redis  on CentOS 7 step by step guide
How to install and configure redis  on CentOS 7 step by step guide

Configure redis to access remotely

By default we can not access redis remotely. We can only access redis using localhost ip (127.0.0.1) in which redis is installed. To access redis remotely we need to configure , to configure it we need to go redis config file which is located at “/etc/redis.conf”.
[root@localhost ~]# vi /etc/redis.conf

And modify  the below line

# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1 192.168.137.6

After modify the file we need to restart the redis service by using the below command.

[root@localhost ~]# systemctl restart redis

Redis service is working 6379 port. Redis service pot is listening or not we can verify using the below command.
[root@localhost ~]# ss  -tulpn | grep 6379
tcp    LISTEN     0      128    192.168.137.6:6379
tcp    LISTEN     0      128    127.0.0.1:6379                                     

Now we need to the allow the port 6379 if you use the firewalld.


To verify redis is successfully configured or not on centos server for this we execute the below command.

[root@localhost ~]# redis-cli -h 192.168.137.6 ping
After excuting the above command we will get the below output.
PONG

That’s all we have configured redis on CentOS 7.If this article is helpful please share it!!!!!!!!!




                       


                                                Share This Article On Whatsapp

                                                                 Support Our Effort


     
Please Donate To Bitcoin Address: [[address]]
Donation of [[value]] BTC Received. Thank You.
[[error]]
SHARE

Admin

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment