Installing Redis 2.2.4 on Ubuntu 10.10 & 11.04 and running with an ‘init’ script.

Following on from previous post on installing MongoDB 1.8.1, here are similar steps to getting Redis 2.2.4 running on Ubuntu 10.10 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.4.tar.gz
tar -zxf redis-2.2.4.tar.gz
cd redis-2.2.4
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 Github ‘dotfiles’ 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 https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server
wget https://github.com/ijonas/dotfiles/raw/master/etc/redis.conf
sudo mv redis-server /etc/init.d/redis-server
sudo chmod +x /etc/init.d/redis-server
sudo mv 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 mkdir -p /var/lib/redis
sudo mkdir -p /var/log/redis
sudo useradd --system --home-dir /var/lib/redis 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.

sudo update-rc.d redis-server defaults

You’re now ready to launch Redis server with

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

Good luck!

12 thoughts on “Installing Redis 2.2.4 on Ubuntu 10.10 & 11.04 and running with an ‘init’ script.

  1. I think it’s better to add system user:
    sudo adduser –system –group –home /var/lib/redis redis

    …unless you sharing PC with redis man ;)

  2. Hi there! Thank you for this useful post. It worked out of the box for my dev env. I have one little problem with my production server. When I run /etc/init.d/redis-server start, it does startup the server, but not as a separate process and I have to interrupt it (CTRL+C) in order to use the terminal again. Do you know how can I fix this? Thanks again. Bye bye

  3. Well written, thank you.

    sudo useradd –home /var/lib/redis redis

    - skips couple of steps
    - avoids to have a possibly useless /home/redis
    - makes an intuitive place for the dumps, configuratons and so on like – for example – postgreSQL is doing.

  4. Pingback: Install redis as server in ubuntu | Darktalker

  5. To [Giuseppe Modarelli] – i had the same problems. The trick is to change the /etc/init.d/redis-server start script.

    What you then need to do is to add the “–background” option to the start command … et voilà – now the redis-server starts up in the background and your telnet server will get a chance to start too!

    PS: Thank you Ijonas for taking the time to write the instructions of setting up redis – i found you through google and thought i leave this comment here for all the other people that come the same way and then run into trouble with the boot process hanging because redis isn’t started in background.

  6. Thank you Ijonas for sharing your install experience with Redis. I just installed it on Ubuntu 11.04 and plan on playing around with it. One issue however… How do I stop the terminal echo “Client Connections”? Since the daemonize is set to true, I can’t get a commandline at all! Using VirtualBox as my VM on OS X.

  7. thank you so much for the post !!!! it helped a lot around people using MAC OS X and using homebrew on it for the install !!! thanks !!!

  8. Just in case, if you aren’t the admin of the server it’s much better to observe the below command to fire up the server else it may create issue while saving the db via a client like python-redis.

    sudo redis-server /etc/redis.conf

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>