Installing Redis 2.2.14 on CentOS 5/6 and running with an “init” script.

Here are simple steps to get Redis 2.2.14 running on CentOS 5/6 (local desktop running CentOS 5.4 and EC2 AMI running CentOS 6.1) using an init script.
The setup is intended to be used on developer desktop/laptop rather than production infrastructure.

As ever, first download and unzip Redis from here.

$> cd /tmp
$> wget http://redis.googlecode.com/files/redis-2.2.14.tar.gz
$> tar xvfz redis-2.2.14.tar.gz
$> cd redis-2.2.14
$> make
$> sudo make install

Your Redis binaries should now be located in /usr/local/bin.

To get an init script and Redis config working cleanly with this setup, download my init and config files from my development/redis repo.
My init script is pretty standard. However my redis.conf sets Redis up with 1Gb of virtual memory and 20Gb of swap space – intended for general development purposes.

$> wget http://www.zorranlabs.com/development/redis/redis.conf
$> wget http://www.zorranlabs.com/development/redis/redis-server

Runner “redis-server” is using start-stop-daemon from Debian distribution, so it needs to be compiled on CentOS. You can take it from my repo. Make sure you have gcc-c++, otherwise, you might get the following error: “exec: g++: not found”

$> sudo yum install gcc gcc-c++ m4 make automake libtool gettext openssl-devel
$> wget http://www.zorranlabs.com/development/start-stop-daemon/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
$> tar xvfz apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
$> cd apps/sys-utils/start-stop-daemon-IR1_9_18-2/
$> gcc start-stop-daemon.c -o start-stop-daemon
$> cp start-stop-daemon /usr/sbin/

There is a small difference between start-stop-daemon versions, so redis-server script should be update:
Please replace the following line

if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS

to this one

if start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS

Update redis.conf to change the following line

vm-enabled yes

to the following line

vm-enabled no

Otherwise, you will get the following error, trying to start redis-server:

“Redis Virtual Memory is going to be deprecated soon,
we think you should NOT use it, but use Redis only if
your data is suitable for an in-memory database.
If you *really* want VM add this in the config file:

really-use-vm yes

Copy init script, and redis.conf it their proper locations:

$> sudo cp redis-server /etc/init.d/redis-server
$> sudo chmod +x /etc/init.d/redis-server
$> sudo cp redis.conf /etc/redis.conf

Before you can fire up the Redis server for the first time, you’ll need add a redis user and prep a data and logging folder.

$> sudo /usr/sbin/useradd redis
$> sudo mkdir -p /var/lib/redis
$> sudo mkdir -p /var/log/redis
$> sudo chown redis.redis /var/lib/redis
$> sudo chown redis.redis /var/log/redis

Also, you need to activate your Redis services init script by adding it to your system’s run-level configuration. That way the service will startup during the boot sequence and stop nicely during the OS’ shutdown procedure.

## initial check, should show nothing
$> sudo /sbin/chkconfig --list | grep redis
$> sudo /sbin/chkconfig --add redis-server
## confirmation, should retruen something like that:
## redis-server 0:off 1:off 2:on 3:on 4:on 5:on 6:off
$> sudo /sbin/chkconfig --list | grep redis
#enable service, specifies run levels 3 and 5:
$> sudo /sbin/chkconfig --level 35 redis-server on

You’re now ready to launch Redis server with and should see that it is started:

$> sudo /etc/init.d/redis-server start
Starting redis-server: redis-server

Netstat should tell you that you listen on redis port, 6379

$> netstat -an | grep 6379
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN

Do not forget to “open” port 6379 on your firewall to get it accessible outside of the host

Good luck and thanks authors of the following posts for the guides and ideas:


http://www.denofubiquity.com/nosql/412/

http://www.cyberciti.biz/faq/rhel5-update-rcd-command/
https://www.centos.org/modules/newbb/viewtopic.php?viewmode=flat&topic_id=24207&forum=40
http://chast.in/start-stop-daemon-on-centos.html

10 Comments

Filed under technology

10 Responses to Installing Redis 2.2.14 on CentOS 5/6 and running with an “init” script.

  1. Cesar Sendro

    Thanks for your article! Frankly speaking I have never seen anything that cool.

  2. invest liberty reserve

    I am not sure where you’re getting your information, but good topic. I needs to spend some time learning much more or understanding more. Thanks for wonderful info I was looking for this Installing Redis 2.2.14 on CentOS 5/6 and running with an ‘init’ script. | http://www.zorranlabs.com for my mission.

  3. Julie

    The blog is cool

  4. Trometter682

    Installing Redis 2.2.14 on CentOS 5/6 and running with an “init” script. | http://www.zorranlabs.com I was suggested this website by my cousin. I’m not sure whether this post is written by him as nobody else know such detailed about my trouble. You’re wonderful! Thanks! your article about Installing Redis 2.2.14 on CentOS 5/6 and running with an “init”script. | http://www.zorranlabs.com Best Regards Lawrence Justin

  5. Alessandra

    thanks for the info, appreciated it. it was so well formatted.

  6. Andrew Pelt

    as soon as i saw this post i shared it on my facebook and a few other social media sites. thank you!

  7. Nicol Poulin

    this blog is magnificent i love reading your articles. Keep up the good work! You know, lots of people are searching around for this information, you could aid them greatly.

  8. Yang Hesser

    Youre so cool! I dont suppose Ive learn something like this before. So nice to search out somebody with some authentic thoughts on this subject. realy thanks for beginning this up. this website is one thing that’s needed on the net, someone with slightly originality. helpful job for bringing something new to the internet!

  9. Andrew A. Sailer

    I just want to tell you that I am just very new to blogging and certainly enjoyed this web-site. Most likely I’m want to bookmark your website . You certainly come with beneficial posts. Bless you for sharing your website page.

  10. This is very good post i will link this guide to my blog, keep posting!

Leave a Reply

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