X

Get the Blog Updates

Scroll to Top

To Top

How to Install and Configure Redis-Server on Centos/Fedora Server
51
SHARES

On 02, Jul 2013 | One Comment |

‘Redis’ is an Open source key-value data store. Key values are more complex types like Hashes, Lists, Sets or Sorted Sets. It is a highly scalable data store which is shared by multiple processes, multiple applications, or multiple Servers.

Steps to install ‘Redis’:

Step-1
Install prerequisites packages for the ‘Redis’ server

#yum install make gcc wget

Step-2
Download Redis Packages and unzip

#wget http://redis.googlecode.com/files/redis-2.2.12.tar.gz
#tar -xf redis-2.2.12.tar.gz

Step-3
we are ready to install Redis from the source.

#cd redis-2.2.12
#make
#make install

Step- 4
Now we will modify the default configuration of the Redis and change the location of the database. We would also change the log notices to a production acceptable level and the location of the log file.

#mkdir /etc/redis/var/lib/redis

#sed -e "s/^daemonize no$/daemonize yes/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel debug$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" redis.conf  > /etc/redis/redis.conf

Step-5
Add the ‘redis’ init script.

#vi /etc/init.d/redis-server

Add the below lines

#!/bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/redis-server
DAEMON_ARGS=/etc/redis/redis.conf
NAME=redis-server
DESC=redis-server
PIDFILE=/var/run/redis.pid

test -x $DAEMON || exit 0
test -x $DAEMONBOOTSTRAP || exit 0

set -e

case "$1" in
start)
echo -n "Starting $DESC: "
touch $PIDFILE
chown redis:redis $PIDFILE
if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON --background -- $DAEMON_ARGS
then
echo "$NAME."
else
echo "failed"
fi
;;
stop)
echo -n "Stopping $DESC: "
if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
then
echo "$NAME."
else
echo "failed"
fi
rm -f $PIDFILE
;;

restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac

exit 0

Note:Give appropriate permission to the init script

chmod u+x  redis-server

Step-6
To run the ‘redis’ server at startup we need to add it to the chkconfig list.

#/sbin/chkconfig --add redis-server
#/sbin/chkconfig --level 345 redis-server on

Step-7
Finally we are ready to start the Redis Server.

# /etc/init.d/redis-server start

Conclusion:

‘Redis’ also supports datatypes such as Transitions, Publish and Subscribe. ‘Redis ’ is considered more powerful than ‘Memcache’ . It would be smart to bring ‘Redis’ into practice and put ‘Memcache’ down for a while.

We provide one-stop solution by utilizing Redis server with Rails , PHP applications and deploy in cloud services such as AWS to make sure that the application is fully scalable.

Read Also: Memcached vs Redis

Do you have anything to add? We would love to hear from you.

  • http://www.nodewiz.biz/ Christopher Langton

    chown: invalid user: ‘redis:redis’

Copyright © 2009-2014 Andolasoft. All rights reserved.