In this tutorial, we’ll explain how to install Redis on Amazon Linux or CentOS.
Redis is open-source, it stores data structure in-memory, which is also used as a database/cache. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, geospatial indexes with radius queries and streams.
How to install Redis on Amazon Linux or CentOS
To know more check out Redis:
In this blog, we will see how to install Redis on Amazon Linux or CentOS, follow the below steps to install Redis v3.2 using YUM.
Step 1: Enable EPEL repository:
Enable EPEL (Extra Packages for Enterprise Linux) repository on the server.
$ wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm $ rpm -ivh epel-release-latest-6.noarch.rpm [OR] Create repo file in "/etc/yum.repos.d/" $ vi /etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux 6 - $basearch baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority enabled=1 gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Step 2: Clean all yum repo and update the repo list:
$ yum clean all $ yum repolist
Step 3: Install Redis on the server by running a command
$ yum install redis
Step 4: Check Redis status
$ service redis status
Commands to Start/Stop/Restart Redis service on Amazon Linux or CentOS
$ service redis start $ service redis stop $ service redis restart
How to test Redis in Linux?
Before testing check Redis server is working, if not start the Redis service
$ service redis start
Test Redis Installation: Command to check Redis is properly installed and working normally if the response is PONG from below command.
$ redis-cli ping
Step 6: Redis server configuration file.
Redis server listens on port 6379 you can update configuration in file “/etc/redis.conf”
Eg: Command to check Redis server listing on which port – herein below output Redis is listening on 6379 port
$ ps aux | grep redis redis 25080 0.0 0.0 142936 3716 ? Ssl 09:13 0:00 /usr/bin/redis-server 127.0.0.1:6379 root 25548 0.0 0.0 110460 2104 pts/0 S+ 09:36 0:00 grep --color=auto redis
Step 7: Autostart Redis service on next boot
$ chkconfig redis on
Some Basic Troubleshooting while Installing Redis:
[root@Sks-linux ~]# cat /var/log/redis/redis.log 21197:C 13 Nov 12:10:14.557 # Can't chdir to '/var/lib/redis': Permission denied Solution: chmod o+x /var/lib/
[root@sks-linux log]# service redis start Starting Redis-server: *** FATAL CONFIG FILE ERROR *** Reading the configuration file, at line 163 >>> 'logfile /var/log/redis/redis.log' Can't open the log file: Permission denied [FAILED] [root@Sks-linux log]#
Follow the below command to fix this issue:
$ chmod o+x /var/log/ $ chmod o+x /var $ chmod o+x /var/run/ $ chown -R redis:redis /var/log/redis/
This is the end of the tutorial where you learn how to install Redis on Amazon Linux or CentOS.
Thanks for reading this article, you’ll also like to read the below articles.
Amazon Web Services Interview Questions
Step By Step Method for installing Nagios in Amazon Linux
Step to Install Docker on Amazon Linux or CentOS Linux
What is AWS EC2 and its Benefits
you can install the EPEL repo directly with yum install epel-release. its in the base repo.
This did not worked for me, so this is what I used:
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -ivh epel-release-latest-7.noarch.rpm
sudo yum update
sudo yum-config-manager –enable epel