Friday 19 February 2016

Redis Installation in linux

Redis Install linux

Redis is an open Source, in-memory data stricture store, used as database, cache and message broker. Redis server can be installed and configured inside the main box (Server machine) or outside the box as a separate machine. Here you go with the installation/setup process of Redis server.

Download Redis

Redis 3.0 introduces Redis Cluster, a distributed implementation of Redis with automatic data sharding and fault tolerance, important speed improvements under certain workloads, improved AOF rewriting, and more.




Installation

The suggested way of installing Redis is compiling it from sources as Redis has no dependencies other than a working GCC compiler and libc. Installing it using the package manager of your Linux distribution is somewhat discouraged as usually the available version is not the latest.
In order to compile Redis follow this simple steps:
Copy the distribution to your favorite folder where you want to do the installation.

Install Development tools and Jemalloc

Redis have dependency with Development tools like gcc and gcc-c++. We have to install those packages in the operating system. Follow below commands for different operating systems.

--------------------Development Tools installation --------------
Centos:
yum -y update
yum groupinstall 'Development Tools'

Red-hat/centos:
yum -y update
yum -y install gcc gcc-c++ make

Ubuntu:
apt-get install build-essential

------------------------------End------------------------------------

-----------------Jemalloc Installation-------------------------------
Jemalloc:
cd redis-home/deps
make hiredis jemalloc linenoise lua
cd ..


Install Ruby and Rubygems


cd redis-home/redis-3.0.7/utils
yum install ruby
yum install rubygems


Install Redis

Install:
cd redis-home/redis-3.0.7
make install
gem install redis

Configure cluster-create:
cd /redis-3.0.7/utils/create-cluster/
vi create-cluster

Change the HOST name with your ip address which you are going to use in application and change the port to 6379.

# Settings
PORT=6379
TIMEOUT=2000
NODES=6
REPLICAS=1
------------------------------------
-----------------------------------------
-------------------------------------------------
if [ "$1" == "create" ]
then
    HOSTS=""
    while [ $((PORT < ENDPORT)) != "0" ]; do
        PORT=$((PORT+1))
        HOSTS="$HOSTS 192.168.1.10:$PORT"
    done
    ../../src/redis-trib.rb create --replicas $REPLICAS $HOSTS
    exit 0
fi

# Save the file

Redis -start and stop


Start Redis:
./cluster-create start

Stop Redis:
./cluster-create stop

Start Redis:
./cluster-create start

Create Redis:
./cluster-create create

Stop Redis:
./cluster-create stop

Reference


http://redis.io/topics/cluster-tutorial



http://redis.io/topics/quickstart


Check If Redis is working

External programs talk to Redis using a TCP socket and a Redis specific protocol. This protocol is implemented in the Redis client libraries for the different programming languages. However to make hacking with Redis simpler Redis provides a command line utility that can be used to send commands to Redis. This program is called redis-cli.
The first thing to do in order to check if Redis is working properly is sending a PING command using redis-cli:
Below example show how you can connect to Node having port 6380.

command:
cd redis-home/redis-3.0.7/utils
redis-cli -c -p 6380
  
Set a sample value:
redis 127.0.0.1:6379> set mykey somevalue
OK

Get the value:
redis 127.0.0.1:6379> get mykey
"somevalue"


 

35 comments: