• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

How to install redis server on CentOS 7 / RHEL 7

October 4, 2014 by Sharad Chhetri 13 Comments

In this tutorial we will learn, how to install redis server on CentOS 7 / RHEL 7 . The abbreviation of redis is REmote DIctionary Server. It is one the of the most popular open source,advanced key-value cache and store.

Project URL : http://redis.io/

Follow the given below steps to install redis server on CentOS 7 and Red Hat Enterprise Linux 7.

Install wget utility

Install wget command

yum install wget

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.

Learn Redis : http://redis.io/documentation

Who is using redis: Who is using Redis

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. Install redis 3.0 from source on Ubuntu 14.04 / CentOS 7 / RHEL 7
  2. jemalloc/jemalloc.h: No such file or directory – Redis
  3. Install and configure Varnish Cache server on CentOS/RHEL 6.x
  4. Install and configure transparent squid proxy server : RHEL/CentOS 6.x
  5. Install pagespeed module ( mod_pagespeed ) on Apache Web Server : CentOS / RHEL
  6. How to install MySQL Server 5.6 on CentOS 7 / RHEL 7
  7. Install MariaDB Server on CentOS 7 / RHEL 7
  8. Install MariaDB Server 10 on CentOS 7 and RHEL 7 by using yum
  9. Install Telnet Server on CentOS 7 / RHEL 7
  10. How to install Mariadb 10.4 server on CentOS 8 / RHEL 8

Filed Under: Linux Tagged With: redis

Reader Interactions

Comments

  1. kishen sharma says

    January 2, 2019 at 3:26 am

    hi everyone ,

    I have installed redis 3.2.12 centos 7.2 in Linux AWS server. 100 GB storage
    2 GB RAM 100 GB Storage. SSD. am using a EC2
    so the storage is EC2 Storage.

    please help me what’s the next step should be done once the installation of redis been done is linux aws server ?

  2. Jon Hartman says

    March 20, 2018 at 12:48 pm

    Thanks for the tips. I was able to reference most of this for a CentOS installation, as well.

  3. Sharad Chhetri says

    March 26, 2017 at 4:37 pm

    Hi PK Hunter,

    1. We want our Redis to run on some other port. Not the default. Is there a redis.conf we can change?
    Answer: To change the port no. edit the redis.conf file and find this line “port 6379” , replace the port no. 6379 as per your wish.

    2. Secondly, we only want Redis to be accessible from inside our server. So only 127.0.0.1 can access it. Is there any simple command for IPTABLES that can block redis completely from outsiders, and only allow from inside the machine?
    Answer:
    (a) In redis.conf file , find this line “bind ” . The ‘bind’ option helps to listen the service on particular ip address. Hence, if you want the redis port should only listen from localhost’s loopback ip address, then change it to “bind 127.0.0.1”
    As asked, given below is IPTABLES rule should be checked in test machine first.

    Change 6379 with custom redis port number.

    $redis_port=6379
    iptables -A OUTPUT -p tcp -d 0.0.0.0/0 --dport $redis_port -j DROP
    service iptables save
    

    In CentOS 7, good to use firewalld. Please check it once from your end do you want to use iptables or firewalld.

    Regards
    Sharad

  4. PK HUnter says

    March 24, 2017 at 2:05 pm

    Thank you for this very useful tutorial. People on the web are so kind.

    Would you mind sharing your expertise with me for a couple of things:

    1. We want our Redis to run on some other port. Not the default. Is there a redis.conf we can change?

    2. Secondly, we only want Redis to be accessible from inside our server. So only 127.0.0.1 can access it. Is there any simple command for IPTABLES that can block redis completely from outsiders, and only allow from inside the machine?

    Thank you!

  5. Sharad Chhetri says

    February 10, 2017 at 6:02 pm

    Hi Theo,

    In this blog not written about this because many readers have different sets of environment and OS. But which I have replied that is the same logic I professionally applied.
    I will try if in this weekend I manage to get time for this post. I have to quickly search for some sample DB also in between.

    Regards
    Sharad

  6. Theo says

    February 10, 2017 at 4:10 pm

    Do you have a how to?

  7. Sharad Chhetri says

    February 8, 2017 at 4:13 pm

    Hi Theo,

    Installing via yum and compilation is different method as well as the files get distributes in system is also different.
    I am sure you have not removed your old redis server through yum command. Then you should go for compilation. Get latest Redis package from redis official website and follow the method.

    Regards
    Sharad

  8. Theo says

    February 7, 2017 at 11:30 pm

    [root@mail init.d]# systemctl status redis_6379
    ● redis_6379.service – LSB: start and stop redis_6379
    Loaded: loaded (/etc/rc.d/init.d/redis_6379; bad; vendor preset: disabled)
    Active: active (exited) since Wed 2017-02-08 00:09:47 CET; 8s ago
    Docs: man:systemd-sysv-generator(8)
    Process: 28924 ExecStart=/etc/rc.d/init.d/redis_6379 start (code=exited, status=0/SUCCESS)

    Feb 08 00:09:46 mail.lodewijkict.nl systemd[1]: Starting LSB: start and stop redis_6379…
    Feb 08 00:09:46 mail.lodewijkict.nl redis_6379[28924]: Starting Redis server…
    Feb 08 00:09:47 mail.lodewijkict.nl systemd[1]: Started LSB: start and stop redis_6379.
    [root@mail init.d]# systemctl status redis-server
    Unit redis-server.service could not be found.
    [root@mail init.d]# redis-cli -v
    redis-cli 3.2.7
    [root@mail init.d]# systemctl status redis.service
    ● 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 2017-02-07 05:01:33 CET; 19h ago
    Main PID: 907 (redis-server)
    CGroup: /system.slice/redis.service
    └─907 /usr/bin/redis-server 127.0.0.1:6379

    Feb 07 05:01:33 mail.lodewijkict.nl systemd[1]: Started Redis persistent key-value database.
    Feb 07 05:01:33 mail.lodewijkict.nl systemd[1]: Starting Redis persistent key-value database…
    [root@mail init.d]#

  9. theo says

    February 7, 2017 at 11:04 pm

    still redis-cli -v
    redis-cli 2.8.19

    please reply upgrade after this installation not an new installation, now we got a double redis server! we have restored the server to the snapshot after dty it but it is not a solution the link that you send.

    Please a correct upgrade or how to remove the current and install the new one?

    Greetings Theo

  10. Sharad Chhetri says

    February 7, 2017 at 5:47 pm

    Hi Theo,

    In case you are looking for latest Redis server then suggest you to compile the tar ball of redis.
    You can get the latest Redis tar ball from its official website. I have written this post for it.

    You can take backup and restore the redis database in new redis server version.

    Regards
    Sharad

  11. theo says

    February 7, 2017 at 4:15 am

    how to update to redis 3.2.7?

  12. Sharad Chhetri says

    December 2, 2016 at 1:51 pm

    Hi Umapati,

    Download rpm in your system and scp to target machine.
    http://dl.fedoraproject.org/pub/epel/7/x86_64/r/redis-2.8.19-2.el7.x86_64.rpm

    Login into server and become a root, run below given command .
    rpm -ivh redis-2.8.19-2.el7.x86_64.rpm

    If any dependency is required then install those packages also.

    Regards
    Sharad

  13. Umapati Singh says

    December 2, 2016 at 2:30 am

    Hi Sharad,

    how do we proceed if our target server does not have access to internet?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Commands

man command not found in CentOS and Red Hat

sed : find the pattern (keyword) and delete the line from file

print working directory ( pwd , PWD , OLDPWD ) in Linux / Unix

cat,sed and awk commands to display file contents

How To Find Absolute Full Path Of Command On Linux / Unix : which command

group ownership reference to file/dir from other file/dir in linux

How to print particular line number by using sed command

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

How to download package using apt-get command in ubuntu

How to see line numbers in file through cat command

Protect from w00tw00t.at.blackhats.romanian.anti-sec

Allow wget and yum in iptable

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Convert hyphen to underscore in between all filenames shell script

Run the script using nohup without hitting enter key two times

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

Linux basic command

Linux Basic Commands With Examples For Every Beginner

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

Copyright © 2023 ·
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy