Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Install Redis on CentOs 6

Tags: redis

Redis is an open source (BSD licensed), in-memory data structure used as database and cache. Its a very powerful and advanced key-value store. It supports data structures such as strings, hashes, lists, sets, sorted sets and much more.

We will discuss more on it. Let us start with the Installation of Redis. As said in couple of previous article you have to login on the terminal with root privileges to install it. or use sudo. I am asuming you are on root privilege.

Before installing Redis you need some tools installed like gcc, gcc-c++, make and tcl. So install it first.

yum -y install gcc gcc-c++ make tcl

Tools are now installed. Now navigate to /usr/local/src and download redis

Download and Install Redis

cd /usr/local/src
tar xzf redis-3.0.6.tar.gz
cd redis-3.0.6

After downloading untar the downloaded file with above command and navigate to redis directory
Now build It and Install

make distclean

You can now test installation (Optional)If everything is ok it will display All tests passed without errors! in the end

make test

Now copy the binary to bin directory

cp src/redis-server src/redis-cli /usr/local/bin

Now create a directory and copy Redis config file to it.

mkdir /etc/redis
cp redis.conf /etc/redis

Now create a working directory for this Redis instance. -p option is for creating recursive directory structure under /var i.e. redis/6379

mkdir -p /var/redis/6379

Edit Redis config file with your favourite text editor to make some necessery changes. Make sure you make change to following lines and set its value as given

vi /etc/redis/redis.conf

#Change Following

daemonize yes
pidfile /var/run/
loglevel notice (choose any one from verbose/debug/notice/warning)
logfile /var/log/redis_6379.log
dir /var/redis/6379

Now download Redis init script (redis-server) and move it to /etc/init.d and make it execeutable

mv redis-server /etc/init.d
chmod 755 /etc/init.d/redis-server

Make sure Redis restarts on server reboot. So add it and start Redis

chkconfig --add redis-server
chkconfig redis-server on
service redis-server start

Now open /etc/sysctl.conf in any editor and add following line in the bottom of file (Optional)

vi /etc/sysctl.conf

#Add following line on bottom

sysctl vm.overcommit_memory=1

And thats it. We are done with Redis Installation. Open Redis CLI terminal with following command


You are now on Redis command line. Try executing Redis commands here. Type exit or press ctrl+c to close session.

This post first appeared on Altaf Hussain's Blog, please read the originial post: here

Share the post

How to Install Redis on CentOs 6


Subscribe to Altaf Hussain's Blog

Get updates delivered right to your inbox!

Thank you for your subscription