Git Product home page Git Product logo

redis-ha's Introduction

Reliable, Scalable Redis on OpenShift

The following document describes the deployment of a reliable, multi-node Redis on OpenShift.

It deploys a master with replicated slaves, as well as replicated redis sentinels which are use for health checking and failover.

Build configuration

  1. Create image stream and build config

        oc process -f build/redis-build.yml \
            -p REDIS_IMAGE_NAME=redis-ha \
            -p GIT_REPO=https://github.com/openlab-red/redis-ha.git \
            | oc create -f -
  2. Start the build

        oc start-build redis-ha-build

Deployment Configuration

Persistent

Create a persistent storage, the storage must be RWX.

Create a new persistent storage (RWX)

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: backend-redis-storage
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
    oc create -f /tmp/storage.yml

Turning up an initial master/sentinel pod

Create a bootstrap master and sentinels with relative service

    export REDIS_PREFIX=backend
    export REDIS_NAME=${REDIS_PREFIX}-redis
    
    oc process -f templates/redis-master.yml \
        -p REDIS_SERVICE_PREFIX=${REDIS_PREFIX} \
        -p REDIS_IMAGE=redis-ha:latest \
        -p REDIS_PV=${REDIS_NAME}-storage \
        | oc create -f -

Turning up replicated redis slave servers

Create a deployment config for redis slave servers

    oc process -f templates/redis-slave.yml \
        -p REDIS_SERVICE_PREFIX=${REDIS_PREFIX} \
        -p REDIS_IMAGE=redis-ha:latest \
        -p REDIS_PV=${REDIS_NAME}-storage \
        | oc create -f -

Create a deployment config for redis sentinels

    oc process -f templates/redis-sentinel.yml \
        -p REDIS_SERVICE_PREFIX=${REDIS_PREFIX} \
        -p REDIS_IMAGE=redis-ha:latest \
        | oc create -f -

Scale down the bootstrap master

Scale down the original master pod

    oc scale --replicas=0 dc ${REDIS_NAME}-master

Failover

Recommended setup

For a recommended setup that can resist more failures, set the replicas to 5 (default) for Redis and Sentinel.

With 5 or 6 sentinels, a maximum of 2 can go down for a failover begin.

With 7 sentinels, a maximum of 3 nodes can go down.

Custom settings

Environment Default Value Note
REDIS_DOWN_AFTER_MILLIS 30000 The time in milliseconds an instance should not be reachable for a Sentinel starting to think it is down
REDIS_FAILOVER_TIMEOUT 180000 Specifies the failover timeout in milliseconds.

For a fast failover under 1 minute

  • REDIS_DOWN_AFTER_MILLIS=20000
  • REDIS_FAILOVER_TIMEOUT=30000

Migration from existing single Redis instance

Migration from existing single redis instance

Backup and Recovery

Backup and Recovery

References

redis-ha's People

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.