1

I configured an HAProxy service for my Redis Cluster installation (3 nodes with Redis Sentinel managing the master delegation) and it works good: clients are redirected only to the master node and whenever a slave node becomes master, HAProxy suddenly change the active member into the backend.

Just wanting to be meticulous, the slave nodes are shown as "DOWN" (red colour) into the HAProxy Statistics Report (Layer7 timeout: at step 5 of tcp-check (expect string 'role:master')). Is there a way to have them shown as "backup UP" (blue colour), which is the correct definition?

This because red nodes seems to be a problem, but this is not true as slave members are UP but they are just slave so they are not active. I think this is the correct definition of the "backup UP" state into HAProxy.

This is the configuration of HAProxy:

frontend Redis
    bind            192.168.70.90:6379 name 192.168.70.90:6379   
    mode            tcp
    log         global
    timeout client      30000
    default_backend     Redis_tcp_ipvANY

backend Redis_tcp_ipvANY
    mode            tcp
    timeout connect     30000
    timeout server      30000
    retries         3
    option tcp-check
    tcp-check connect
    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          redis1 192.168.70.91:6379 check inter 1000  maxconn 1024 
    server          redis2 192.168.70.92:6379 check inter 1000  maxconn 1024 
    server          redis3 192.168.70.93:6379 check inter 1000  maxconn 1024 

Do you have any idea about how it's possible to do what I want?

Thanks!

Mat
  • 1,783
  • 4
  • 22
  • 39
  • Are you sure the health check for the backup node is coming back as up? – chicks Nov 01 '17 at 22:22
  • Yes, if I shutdown the master node one of the slave nodes becomes master and HAProxy makes it UP and green into the statistic page. – Mat Nov 01 '17 at 22:51
  • 3
    You have designed a health check that ensures that non-master nodes will **fail** the health check because `tcp-check expect string role:master`. – Michael - sqlbot Nov 01 '17 at 23:51
  • Yes, I understand this and I understand that HAProxy is working good. But I am wondering if there is any way to tell HAProxy to consider nodes which not have `string role:master` as BACKUP and not as DOWN. – Mat Nov 02 '17 at 09:32

1 Answers1

2

It's possible, but as you have more than two nodes, IT WON'T FAIL OVER CORRECTLY. But since you asked:

backend Redis_tcp_ipvANY
    mode            tcp
    timeout connect     30000
    timeout server      30000
    retries         3
    option tcp-check
    tcp-check connect
    tcp-check send PING\r\n
    tcp-check expect string +PONG
    tcp-check send QUIT\r\n
    tcp-check expect string +OK
    server          redis1 192.168.70.91:6379        inter 1000  maxconn 1024 check
    server          redis2 192.168.70.92:6379 backup inter 1000  maxconn 1024 check
    server          redis3 192.168.70.93:6379 backup inter 1000  maxconn 1024 check

The haproxy BACKUP state simply means the server won't be considered for load-balancing as long as any normal server is UP. Your present setup is better, I think.

kubanczyk
  • 13,502
  • 5
  • 40
  • 55