How to install Redis on a Centos 6.5 & Centos 7.0 Server
Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
How To Install Redis on Centos 7
# wget -r –no-parent -A ‘epel-release-*.rpm’ http://dl.fedoraproject.org/pub/epel/7/x86_64/e/
# rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-*.rpm
It will create two epel’s repo file inside /etc/yum.repos.d
These are –
1. epel.repo
2.epel-testing.repo
Install Redis with Yum
# yum install redis php-pecl-redis
Enable Redis service to start on boot
# systemctl enable redis-server.service
Disable Redis service from start on boot
# systemctl disable redis-server.service
Start/Stop/Restart Redis
# systemctl start redis-server.service
# systemctl stop redis-server.service
# systemctl restart redis-server.service
Check if Redis is Running
#systemctl is-active redis-server.service
How To Install Redis on Centos 6.5
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
# yum install redis php-pecl-redis
# service redis start
# chkconfig redis on
Now verify its set to start at boot
# chkconfig –list redis
redis 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Install EPEL repo
First we will install the EPEL repo. For more detail on EPEL repo, we suggest you to read our this post.
Because our system has x86_64 Operating System architecture, we will use only epel repo package for x86_64 . Search epel repo package as per your Operating System architecture(EPEL URL)
wget -r –no-parent -A ‘epel-release-*.rpm’ http://dl.fedoraproject.org/pub/epel/7/x86_64/e/
rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-*.rpm
It will create two epel’s repo file inside /etc/yum.repos.d
These are –
1. epel.repo
2.epel-testing.repo
[root@localhost ~]# ls -l /etc/yum.repos.d/
total 28
-rw-r–r–. 1 root root 1612 Jul 4 07:00 CentOS-Base.repo
-rw-r–r–. 1 root root 640 Jul 4 07:00 CentOS-Debuginfo.repo
-rw-r–r–. 1 root root 1331 Jul 4 07:00 CentOS-Sources.repo
-rw-r–r–. 1 root root 156 Jul 4 07:00 CentOS-Vault.repo
-rw-r–r–. 1 root root 957 Sep 2 12:14 epel.repo
-rw-r–r–. 1 root root 1056 Sep 2 12:14 epel-testing.repo
[root@localhost ~]#
Install redis server
Now use yum command to install redis server
yum install redis
Two important redis server configuration file’s path
1. /etc/redis.conf
2. /etc/redis-sentinel.conf
Now start the redis server after this.
systemctl start redis.service
Check the running status of redis server
systemctl status redis.service
To test the installation of Redis, use below given command
redis-cli ping
If the response output is PONG, it means installation is completed successfully.
[root@localhost ~]# redis-cli ping
PONG
[root@localhost ~]#
Start/Stop/Restart/Status and Enable redis server
To start redis server
systemctl start redis.service
To stop redis server
systemctl stop redis.service
To restart redis server
systemctl restart redis.service
To get running status of redis server
systemctl status redis.service
To enable redis server at system’s booting time.
systemctl enable redis.service
To disable redis server at system’s booting time.
systemctl disable redis.service
Listening Port Of Redis Server
Redis Server listens by default at port number 6379. Use below given ss command. (To learn more about ss command)
[root@localhost ~]# ss -nlp|grep redis
tcp LISTEN 0 128 127.0.0.1:6379 *:* users:((“redis-server”,19706,4))
[root@localhost ~]#
Note: On minimal installed CentOS 7/ RHEL 7,you wont get netstat command. Instead of netstat command, use ss command which is by default available on system.
[root@localhost ~]# redis-cli
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> exit
[root@localhost ~]#
To check help of redis-cli command.
redis-cli –help
Recent Comments