How to set up Redis in Ubuntu Linux

Redis is an open source, advanced key-value store, and is quickly picking up momentum in real-time software development , it is now a well known and trusted product and can be used in various  problem scenarios as a No SQL implementation. 

Redis is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

Here is quick guide to Install Redis in Ubuntu 10.04, and it should be similar for higher versions and similar deb environment.

Prepare System for Redis

Issue the following commands to update your system's package repositories and ensure that all installed packages are up to date:

apt-get update
apt-get upgrade

You may also need to prepare a vanilla system to get some installation tools. apt-get install build-essential

Begin the installation process by issuing the following sequence of commands to download the software and prepare it for use:

cd /tmp
tar -zxf redis-2.2.4.tar.gz
cd redis-2.2.4
sudo make install

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

note:Check the Redis upstream project source to ensure that you are downloading the most up to date version of Redis

All Redis configuration options can be specified in the redis.conf file located at /tmp/redis/redis.conf.  

Sample redis conf

daemonize yes
pidfile /var/run/
logfile /var/log/redis.log
port 6379
timeout 300
loglevel notice
##Default configuration options
databases 16
save 900 1
save 300 10
save 60 10000
rdbcompression yes
dbfilename dump.rdb
dir /tmp/redis/
appendonly no
glueoutputbuf yes

Most of the values in this configuration mirror the default Redis configuration. However, this configuration configures Redis to run in a daemon mode bound only to the local network interface. You may want to change these values depending on the needs of your application.

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

Finally Start

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

How to set up Redis in Ubuntu Linux  by  admin