Giter Club home page Giter Club logo

redis_cluster's Introduction

Redis Cluster

Redis cluster with Docker Compose

Using Docker Compose to setup a redis cluster with sentinel.

Prerequisite

Install Docker and Docker Compose in testing environment

Docker Compose template of Redis cluster

The template defines the topology of the Redis cluster

services:
  redis01:
    build: redis-config
    ports:
      - '6380:6379'
    networks:
      - host
    env_file:
      - 'redis-config/env/master_variables.env'

  redis02:
    build: redis-config
    ports:
      - '6381:6379'
    depends_on:
      - redis01
    networks:
      - host
    env_file:
      - 'redis-config/env/slave_variables.env'

  redis03:
    build: redis-config
    ports:
      - '6382:6379'
    depends_on:
      - redis01
    networks:
      - host
    env_file:
      - 'redis-config/env/slave_variables.env'

  proxy:
    build: ./haproxy
    depends_on:
      - redis01
      - redis02
      - redis03
    networks:
      - host
    ports:
      - '9911:8080'
      - '8080:80'

networks:
  host:

There are following services in the cluster;

master: Redis master

slave: Redis slave

The details could be found in sentinel/sentinel.conf

The default values of the environment variables for Sentinel are as following

  • SENTINEL_QUORUM: 2
  • SENTINEL_DOWN_AFTER: 1000
  • SENTINEL_FAILOVER: 5000

Play with it

Build the sentinel Docker image

docker-compose build

Start the redis cluster

docker-compose up -d

Check the status of redis cluster

docker-compose ps

Name                    Command               State                                       Ports
-----------------------------------------------------------------------------------------------
redis_proxy_1     /docker-entrypoint.sh hapr ...   Up      0.0.0.0:8080->80/tcp,:::8080->80/tcp, 0.0.0.0:9911->8080/tcp,:::9911->8080/tcp
redis_redis01_1   /etc/redis/redis-entrypoint.sh   Up      0.0.0.0:6380->6379/tcp,:::6380->6379/tcp
redis_redis02_1   /etc/redis/redis-entrypoint.sh   Up      0.0.0.0:6381->6379/tcp,:::6381->6379/tcp
redis_redis03_1   /etc/redis/redis-entrypoint.sh   Up      0.0.0.0:6382->6379/tcp,:::6382->6379/tcp

Replication

redis_replication

redis_cluster's People

Contributors

ugurh avatar

Stargazers

 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.