Coder Social home page Coder Social logo

redis-sentinel-cluster-setup's Introduction

Redis Sentinel High Availability Setup

Follow this procedure to setup a High Available Redis Caching Layer.

Environment

  1. haproxy
  2. redis
  3. redis-sentinel

Haproxy 1.5+ do have a TCP health check feature for redis. Haproxy will be configured in such a way that proxy connections will be forwarded to master instance only. Sentinel will constantly monitor the redis master instance and will promote slave node with lowest priority as next redis master in case of failure. Redis will be configured in such a way that one node will be master and other two nodes will be configured as slaveof the master instance.

Sentinel will be running as a separate service. we'll need minimum 3 sentinel instances to monitor redis master instance. Our cluster will have quorum of 2 ie; two sentinel instances should agree / vote for a slave to be promoted as master incase of master failure.

Architecture Diagram

redis-sentinel.jpg

Server setup

Redis, Redis-sentinel instances - redis-server-001,002,003

Install system updates

yum update -y

Install remi repository

centos 6

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

centos 7
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

Install redis

yum --enablerepo=remi install redis

Configure redis and redis-sentinel

Create redis-sentinel working directory

mkdir /var/lib/redis-sentinel

Download and install redis and redis-sentinel configuration from redis-server-001,002 and 003 directories and Update file ownership, redis user should have write privileges.

chown redis /etc/redis.conf
chown redis /etc/redis-sentinel.conf

Bootstrap Redis HA enviorment - Start Services and add services into system startup

chkconfig redis on ; chkconfig redis-sentinel on
service redis start ; service redis-sentinel start

Haproxy Instance - haproxy-server-001

Install system updates

yum update -y

Install epel repository

yum -y install epel-release

Install haproxy

yum -y install haproxy

Configure haproxy

cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg_bak

Download and install haproxy configuration from haproxy-server-001 directory

Start Haproxy service and service into system startup

service haproxy start
chkconfig haproxy on

At this point, you'll have

  1. Redis master running on redis-server-001 instance

  2. Redis slaves running on redis-server-002 and redis-server-003 instances

  3. Redis Sentinel services running on all 3 redis nodes

  4. Haproxy Server listerning on port 6379 and forwarding connections to master redis instance.

  5. Upon master failure, redis-sentinel service will promote a slave into the master and haproxy's tcp health-check will detect next master and forward connections to the new master instance.

We setup multiple HAProxy instances and manage them using cluster management services. That's how we ensure redundancy and HA for haproxy instances.

redis-sentinel-cluster-setup's People

Contributors

dijeesh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.