Install and configure Redis server on centos 7
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, sorted sets, hyperlogs, bitmaps, streams etc.In this tutorial we will see how to install and configure redis on centos 7 server
Step 1: Install and enable Remi repo
we will add remi repository to install latest redis package. Before installing redis we need to install epel repository with following command.
Also Read -> How to install and enable Remi repo in centos 7
[root@localhost ~]# yum install epel-release yum-utils
Now add and enable remi repository
[root@localhost ~]# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
[root@localhost ~]# yum-config-manager --enable remi
[root@localhost ~]# yum repolist enabled
once remi repo is installed you can install redis like below
[root@localhost ~]# yum install redis
Now start and enable it to autostart on system boot
[root@localhost ~]# systemctl start redis
[root@localhost ~]# systemctl enable redis
[root@localhost ~]# systemctl status redis
you can check redis service with status command or netstat
[root@localhost ~]# netstat -antp | grep redis
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 1519/redis-server 1
Redis server is up and running on your system with default TCP port 6379.
We hope you are following "How to Install and Configure Redis Server on Centos 7" step by step carefully. The remaining steps will help you to finish the upgrade process..
Also Read -> How to Install and Configure NFS on Centos 7
Step 2: configure redis Remote access
By default, you can not access Redis from another host because its by default bound to localhost only.if you want to connect to your Redis server from remote hosts then perform below step.
open redis.conf file
[root@localhost ~]# vi /etc/redis.conf
you can find the line that starts with bind 127.0.0.1 and add your server IP address after 127.0.0.1. Then save and close the file.It's recommended to use the internal private ip for your Redis installation and don't use the public ip due to security issue.
bind 127.0.0.1 192.168.0.7
Replace your server ip in above step.
To take changes effect, restart Redis server by running below command
[root@localhost ~]# systemctl restart redis
If firewall service is running on your system then you have to configure rules
you can create a zone as redis
[root@localhost ~]# firewall-cmd --new-zone=redis --permanent
Add rule to open port 6379
[root@localhost ~]# firewall-cmd --zone=redis --add-port=6379/tcp --permanent
Next, specify any private IP addresses which should be allowed to pass through the firewall and access Redis.
[root@localhost ~]# firewall-cmd --permanent --zone=redis --add-source=clientserver_private_IP
After running those commands, reload the firewall to effect the new rules
[root@localhost ~]# firewall-cmd --reload
Step 3: Testing
use redis-cli tool to verify the connection
Also Read -> How to Install and Configure VNC Server in Centos 7
[root@localhost ~]# redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set myname "lampblogs"
OK
127.0.0.1:6379> get myname
"lampblogs"
127.0.0.1:6379> exit
Now you have successfully installed and configure redis server on centos 7.