Search code examples
redishaproxy

Why haproxy shows 2 redis nodes down even when those are the to redis slave nodes connected to redis master node?


redis-a is master and other 2 are slaves connected to master then why haproxy is showing them as down enter image description here this is how i have setup in haproxy config.

defaults REDIS
       mode tcp
       timeout connect 4s
       timeout server 30s
       timeout client 30s

frontend front_redis
       bind *:3679 name redis
       default_backend back_redis

backend back_redis
       option tcp-check
       tcp-check connect
       tcp-check send AUTH\ redis123\r\n
       tcp-check expect string +OK
       tcp-check send PING\r\n
       tcp-check expect string +PONG
       tcp-check send info\ replication\r\n
       tcp-check expect string role:master
       tcp-check send QUIT\r\n
       tcp-check expect string +OK

       server redis-a 192.168.0.15:6379 check inter 1s
       server redis-b 192.168.0.14:6379 check inter 1s
       server redis-c 192.168.0.16:6379 check inter 1s

# Redis Block end

here is the result of the redis cli via haproxy.

3679> info Replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.5.16,port=6379,state=online,offset=1358919,lag=1
slave1:ip=192.168.5.14,port=6379,state=online,offset=1358919,lag=1
master_replid:5a096bcddd97e297wdww236ae9e6dd3f8df9f7
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1359061
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:310486
repl_backlog_histlen:1048576

3679 is haproxy port

my redis version is 6.0.9.


Solution

  • the two server 192.168.0.14 and 192.168.0.16 are sentinel slaves will not have role:master which is your haproxy check. so you need to check for slaves separate check .

    that should do it.