mdevilliers / redishappy

Redis Sentinel high availabillity daemon
Apache License 2.0
114 stars 23 forks source link

Does RedisHappy work with redis 3.2.4 #59

Closed samof76 closed 7 years ago

samof76 commented 7 years ago

I am running cluster with the latest stable redis. And when i try to start up the redis-haproxy, i get the following error.

2016/10/04 06:44:39.621394 Starting Goji on [::]:8000
panic: runtime error: index out of range

goroutine 34 [running]:
panic(0x7656c0, 0xc420012100)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/therealbill/libredis/client.(*PubSub).Receive(0xc42010a180, 0x0, 0x0, 0x0, 0xc4201203c0, 0x596093)
        /home/ec2-user/projects/src/github.com/therealbill/libredis/client/pubsub.go:68 +0x1e3f
github.com/mdevilliers/redishappy/services/redis.(*PubSubClient).loopSubscription(0xc420104120)
        /home/ec2-user/projects/src/github.com/mdevilliers/redishappy/services/redis/pubsubclient.go:50 +0x35
created by github.com/mdevilliers/redishappy/services/redis.(*PubSubClient).Start
        /home/ec2-user/projects/src/github.com/mdevilliers/redishappy/services/redis/pubsubclient.go:39 +0xb3

Could you clarify if it works with the latest redis version?

Here is my config json

{
  "Clusters" :[
  {
    "Name" : "mymaster",
    "ExternalPort" : 6379
  }],
  "Sentinels" : [
      {"Host" : "172.31.0.4", "Port" : 26379}
  ],
  "HAProxy" :
    {
      "TemplatePath": "/root/redishappy/haproxy_template.cfg",
      "OutputPath": "/etc/haproxy/haproxy.cfg",
      "ReloadCommand": "haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)"
    }
}
samof76 commented 7 years ago

Well, I have firgured out what caused this. In redis 3.2.4, they have a configuration variable called protected-mode which defaults, and immediately downs any external connections. So for redis-haproxy to communicate with redis-sentinel, the sentinel configuration either should have this,

protected-mode no

or explicitly bind on 0.0.0.0, like this,

bind 0.0.0.0

Now this enures that redis-haproxy connects to the sentinel for automatic switchovers.

samof76 commented 7 years ago

Have created an install script for Amazon Linux/ CentOS 6 or 7 / RedHat.