How to install Redis 4 .0 on CentOS 6 and Amazon Linux

What is Redis?

Redis is a flexible open-source, key value data store, used as a database, cache and message broker. Redis allows the user to store vast amounts of data without the limits of a relational database.
In order to achieve its outstanding performance, Redis works with an in-memory dataset. Depending on your use case, you can persist it either by dumping the dataset to disk every once in a while, or by appending each command to a log. Persistence can be optionally disabled, if you just need a feature-rich, networked, in-memory cache.

Server Pre-requisites 

We can either install  the Development tools directly.

On CentOS/AmazonLinux 

yum install "Development Tools"

Or the compiler tools specifically as shown below.

On CentOS 6:

yum install wget make gcc tcl

On CentOS 7

yum install wget make gcc

Install Redis 

For installing Redis  we need to download the source file and compile it. For this Demo setup we will be using latest stable Redis version 4.0 available on http://download.redis.io

On CentOS 6 and CentOS 7 Amazon Linux 

wget -c http://download.redis.io/redis-stable.tar.gz 

Now you have to extract the file that you just downloaded by typing:

tar -xvzf redis-stable.tar.gz

Change directory with the command below:

cd redis-stable

It’s time to compile your Redis step by step:

cd deps
make hiredis lua jemalloc linenoise
make geohash-int

Now run below command to get back to the parent directory and run the next command:

cd ../
make
make install

And for getting sure running a test:

make test

It’s going to take a few minutes, you can check that everything is ok.

Installing init script

This script will help you easily set up a running Redis. You can Hit enter to select all default options. Except the last one where you have to give executable path to redis-server which generaly will be /usr/local/bin/redis-server

cd utils

./install_server.sh

Now we have our redis server installed succeffuly. We will now proceed to start the redis server and test the  redis setup is working fine. To interact with redis server, use the redis-cli command. 

or CentOS 6

service redis_6379 start

For CentOS 7

systemctl start redis_6379

If you want to test your Redis server you can easily use the instruction below:

# redis-cli
> set mykey "Demo Redis Setup"
check if mykey is still stored on the server as shown below
> get mykey

Learn How to Setup Redis Master Server replication.

Spread the love

Leave a Reply

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