All Projects → mdevilliers → Redishappy

mdevilliers / Redishappy

Licence: apache-2.0
Redis Sentinel high availabillity daemon

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Redishappy

Haproxy Configs
80+ HAProxy Configs for Hadoop, Big Data, NoSQL, Docker, Elasticsearch, SolrCloud, HBase, MySQL, PostgreSQL, Apache Drill, Hive, Presto, Impala, Hue, ZooKeeper, SSH, RabbitMQ, Redis, Riak, Cloudera, OpenTSDB, InfluxDB, Prometheus, Kibana, Graphite, Rancher etc.
Stars: ✭ 106 (-4.5%)
Mutual labels:  redis, haproxy
Open Build Service
Build and distribute Linux packages from sources in an automatic, consistent and reproducible way #obs
Stars: ✭ 599 (+439.64%)
Mutual labels:  rpm, deb
Jenkins Bootstrap Shared
Jenkins as immutable infrastructure made easy. A repository of shared scripts meant to be used as a git submodule. Packing Jenkins, plugins, and scripts into immutable packages and images.
Stars: ✭ 270 (+143.24%)
Mutual labels:  rpm, deb
package-build
A toolset for building system packages using Docker and fpm-cookery
Stars: ✭ 36 (-67.57%)
Mutual labels:  deb, rpm
Fpm Within Docker
Leverage fpm inside pre-baked docker images in order to build and test native DEB and RPM packages.
Stars: ✭ 80 (-27.93%)
Mutual labels:  rpm, deb
HAProxy-2-RPM-builder
Build latest HAProxy binary with prometheus metrics support
Stars: ✭ 28 (-74.77%)
Mutual labels:  rpm, haproxy
Platform Install Packages
Official deployment packages to install the Kaltura platform on a server or cluster environments using native OS package managers
Stars: ✭ 436 (+292.79%)
Mutual labels:  rpm, deb
deezer-linux
An universal linux port of deezer, supporting both Flatpak and AppImage
Stars: ✭ 141 (+27.03%)
Mutual labels:  deb, rpm
Nfpm
NFPM is Not FPM - a simple deb, rpm and apk packager written in Go
Stars: ✭ 1,088 (+880.18%)
Mutual labels:  rpm, deb
Rakudo Pkg
Pre-compiled OS packages for Rakudo
Stars: ✭ 55 (-50.45%)
Mutual labels:  rpm, deb
foreman-packaging
Packaging files (RPMs, debs) for Foreman and its dependencies
Stars: ✭ 38 (-65.77%)
Mutual labels:  deb, rpm
Sbt Native Packager
sbt Native Packager
Stars: ✭ 1,480 (+1233.33%)
Mutual labels:  rpm, deb
LAMPP-Manager
A simple LAMPP manager designed to automate all the work.
Stars: ✭ 117 (+5.41%)
Mutual labels:  deb, rpm
SetupBuilder
Gradle plugin for building setups for different platforms.
Stars: ✭ 75 (-32.43%)
Mutual labels:  deb, rpm
st2-packages
StackStorm deb/rpm packages (automated docker build pipeline)
Stars: ✭ 25 (-77.48%)
Mutual labels:  deb, rpm
Javapackager
📦 Gradle/Maven plugin to package Java applications as native Windows, Mac OS X, or GNU/Linux executables and create installers for them.
Stars: ✭ 285 (+156.76%)
Mutual labels:  rpm, deb
Aliddns
aliyun ddns for golang【阿里云DDNS服务,用来将自己的动态IP同步到自己的域名解析服务器,安装方便,配置简单,默认支持Linux和MacOS以后台服务方式持续运行】
Stars: ✭ 136 (+22.52%)
Mutual labels:  rpm, deb
Boostnote-packages
Repo containing .rpm, .deb and Boostnote app folder
Stars: ✭ 31 (-72.07%)
Mutual labels:  deb, rpm
Goreleaser
Deliver Go binaries as fast and easily as possible
Stars: ✭ 9,290 (+8269.37%)
Mutual labels:  rpm, deb
Rpm Haproxy
HAproxy RPM spec and builds for CentOS 6/7
Stars: ✭ 103 (-7.21%)
Mutual labels:  haproxy, rpm

redishappy

Build Status Coverage Status

One method of providing a highly available Redis service is to deploy using Redis Sentinel.

Redis Sentinel monitors your Redis cluster and on detecting failure, promotes a slave to become the new master. RedisHappy provides a daemon to monitor for this promotion and to tell the outside world that this has happened.

Currently we support HAProxy with redishappy-haproxy and Consul with redishappy-consul.

Features

  • Automatic discovery and healthchecking of Redis Sentinels.
  • Extensible to support various service discovery mechanisims
  • Developed in Golang, clean deployment with no additional dependencies.
  • Read-only RestAPI.
  • Syslog integration.
  • RPM and Deb packages available.
  • Support for Linux, Solaris and Windows
  • Puppet module available.

Deployment

Redishappy ships in two forms redishappy-haproxy and redishappy-consul.

redishappy-haproxy

redishappy-haproxy updates HAProxy's configuration file on Redis master promotion and then reloads the HAProxy configuration file. The reload maintains current connections.

redishappy_haproxy

The redishappy daemon is installed on the same machine as HAProxy and runs with correct user rights to interact with HAProxy. Multiple instance of HAProxy/redishappy-haproxy can be deployed and operate seperatly.

redishappy-consul

redishappy-consul updates entries in a Consul instance on Redis master promotion.

redishappy_consul

FAQ

Q. Why - I thought in the modern age Redis clients should be Sentinel aware? They should connect to the correct Redis instance on failover.

A. Some do, some don't. Some it seems to be an eternal 'work in progress'. Rather than fixing all of the clients we needed to work correctly with Sentinel, RedisHappy was built upon the fact that all of the clients I have tested are great at connecting to a single address.

Operations teams also need to support legacy applications and libraries - adding redishappy, Sentinels and HAProxy can help provide a HA enviroment for Redis backed applications.

Q. Why - This article suggests that HAProxy can healthcheck Redis instances quite fine by itself.

A. Yes. It can do. But not reliably... I'll explain.

Suppose we have this setup. R1 and R2 are redis instances, S1,S2,S3 are Sentinel instances, H1 and H2 are HAProxy instances.

    R1,R2
    S1, S2, S3
    H1, H2
  • Life is good - R1 and R2 are in a master slave configuration, H1 and H2 correctly identify R1 as the master
    R1      R2
    M  ---- S
    ^
    |
    ---------
    |       |
    H1      H2
  • Disaster! - R1 dies or is partitioned but don't fear R2 is now the "master". Day saved!
    *       R2
            M
            ^
            |
    ---------
    |       |
    H1      H2
  • Disaster! - R1 comes back online and announces itself as a "master". Both R1 and R2 are now accepting writes, as HAProxy's healthcheck identifies both as online.
    R1        R2
    M       M
    ^        ^
    |       |
    ---------
    |       |
    H1      H2
  • R1 is made the "slave" of R2. Everything is ok now, except for the writes that R1 accepted which are lost forever.
    R1      R2
    S ----- M
            ^
            |
    ---------
    |       |
    H1      H2

When a Redis instance is started and stopped it initially announces itself as a "master". It will some time later be made a "slave" but in the meantime accept writes which will be lost when it is correctly made a slave.

RedisHappy attempts to avoid this failure mode by only presenting the correct server to HAProxy or any other service once it is confirmed as a "master". We assume clients will either block or fail until the master is online again.

Building

Using Vagrant

The provided vagrant file creates a virtual machine with all of the dependancies to build redishappy, smoke test it, and build the deb and rpm packages.

vagrant up

The packages are automatically built to - $GOPATH/src/github.com/mdevilliers/redishappy/

The vagrant box also installs HAProxy, Docker and https://github.com/mdevilliers/docker-rediscluster for manual testing.

Download and build.

Install golang 1.4 +

go get github.com/mdevilliers/redishappy

cd $GOPATH/src/github.com/mdevilliers/redishappy

go get github.com/tools/godep
go get github.com/axw/gocov/gocov
go get github.com/mattn/goveralls
go get golang.org/x/tools/cmd/cover
go get golang.org/x/tools/cmd/goimports

godep restore

build/ci.sh

Defaults

Installing using the deb and rpm packages will set the following defaults -

  • Installs to /usr/bin/redis-haproxy
  • Configuration to /etc/redishappy-haproxy
  • Logs to file in /var/log/redishappy-haproxy
  • Warnings, Errors go to syslog

Configuration

Example configurations can be found in the main folders

Definitions for the elements

{
  // OPTIONAL - TCP Keep-Alive time (in seconds)
  "SentinelTCPKeepAlive" : 0
  // REQUIRED - needs to contain at least one logical cluster
  "Clusters" :[
  {
    "Name" : "testing", // logical name of Redis cluster
    "ExternalPort" : 6379 // port to expose for the cluster via HAProxy
  }],
  // REQUIRED - needs to contain the details of at least one cluster
  // redishappy will discover additional sentinels as they come online
  "Sentinels" : [
      {"Host" : "172.17.42.1", "Port" : 26377}
  ],
  // OPTIONAL for running redishappy-haproxy
  "HAProxy" :
    {
      // REQUIRED - absolute path to the template file
      "TemplatePath": "/var/redishappy/haproxy_template.cfg",
      // REQUIRED - absolute path to HAProxy's config file
      "OutputPath": "/etc/haproxy/haproxy.cfg",
      // REQUIRED - command to run to reload the config file on changes
      "ReloadCommand": "haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)"
    },
    // OPTIONAL for running redishappy-consul
   "Consul" : {
       // REQUIRED - path to Consul instance
    "Address" : "127.0.0.1:8500",
    // REQUIRED - for each cluster in the main config there should be a defined service
      "Services" : [
        {
            // REQUIRED - should match a name of a Cluster in the main config
            "Cluster" : "testing",
            // REQUIRED - logical name for the node
            "Node" : "redis-1",
            // REQUIRED - logical name for the data centre
            "Datacenter": "dc1",
            // REQUIRED - tags for the service
            "tags" : [ "redis", "master", "anothertag"]
          }
      ]
  }
}

Or you can configure with the following environmental variables -

Environment Variable Example Notes
REDISHAPPY_CLUSTERS clustername:6379 multiple values can be ; seperated
REDISHAPPY_SENTINELS ip_name:26377 multiple values can be ; seperated
REDISHAPPY_HAPROXY_TEMPLATE_PATH string, see config file for example
REDISHAPPY_HAPROXY_OUTPUT_PATH string, see config file for example
REDISHAPPY_HAPROXY_RELOAD_CMD string, see config file for example

API

RedisHappy provides a readonly API on port 8000. You can change the port by specifying a PORT environment variable. It is also possible to use a BIND environment variable if you wish to bind to other interfaces etc.

  • GET /api/ping - will reply "pong" if running
  • GET /api/configuration - displays the start up configuration
  • GET /api/sentinels - displays the sentinels being currently monitored and their current states
  • GET /api/topology - displays the current view of the Redis clusters, their master and their host/ip addresses

redishappy-haproxy provides the following additional read only apis

  • GET /api/template - displays the current template file
  • GET /api/haproxy - displays the rendered HAProxy file

Hacking

Running the following script will gofmt, govet, run the tests, build all of the executables.

build/ci.sh

Benchmarks

Find some benchmarking information here.

Testing with Docker

https://github.com/mdevilliers/docker-rediscluster

Will start up a master/slave, 3 sentinel redis cluster for testing.

Thanks

Big thanks to

Copyright and license

Code and documentation copyright 2017 Mark deVilliers. Code released under the Apache 2.0 license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].