×

Get the Blog Updates

Your information will not be shared with any 3rd parties under any circumstances.
Cancel
Image Image Image Image Image
Scroll to Top

To Top

Scroll to Top

To Top

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

53 Flares Twitter 15 Facebook 12 Buffer 8 LinkedIn 11 Google+ 7 53 Flares ×

redis_new-123

‘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.

53 Flares Twitter 15 Facebook 12 Buffer 8 LinkedIn 11 Google+ 7 53 Flares ×