Hi all,

This is an interesting one.

I'm trying to have haproxy send requests to 4 backends which are redis
servers. Only one of the four is master, and the other 3 are slaves.
I want to health check by sending an INFO command, to which redis will reply

$640
redis_version:1.3.15
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:32
multiplexing_api:select
process_id:9987
uptime_in_seconds:1201116
uptime_in_days:13
connected_clients:1
connected_slaves:3
blocked_clients:0
used_memory:372250520
used_memory_human:355.01M
changes_since_last_save:58
bgsave_in_progress:0
last_save_time:1315567163
bgrewriteaof_in_progress:0
total_connections_received:1888418
total_commands_processed:2587074
expired_keys:0
hash_max_zipmap_entries:64
hash_max_zipmap_value:512
pubsub_channels:0
pubsub_patterns:0
vm_enabled:0
role:master
db0:keys=2228970,expires=0
db1:keys=41,expires=0

If the response from the check includes the reply "role:master", I want the
health check to succeed, else fail.
I'm finding this really hard to do with haproxy.

I have

listen redis localhost:6379
  mode tcp
  option tcplog
  log global
  balance roundrobin
  option httpchk INFO \r\n
  http-check expect rstring master
  server redis1 192.168.0.1:6379 maxconn 30 check inter 30s
  server redis2 192.168.0.2:6379 maxconn 30 check inter 30s backup

etc

But the health check is failing with

[WARNING] 251/123821 (8241) : Server redis/redis1 is DOWN, reason: Layer7
invalid response, info: "$640", check duration: 25ms. 3 active and 0 backup
servers left. 0 sessions active, 0 requeued, 0 remaining in queue.

I know I'm trying to do something odd with httpchk, and perhaps I need to
craft a better regexp for my expect string.
Could anyone assist?

Kind Regards

john

-- 
John Helliwell

Reply via email to