I have a HAproxy instance with one backend and two mysql servers. My question is Can I set for each server in backend different healthchecks? It could be perfect to set mysql-check to backend server and tcp-check to main server. I didn’t find this in official docs.
Here is backend’s config
backend db-backend
#option mysql-check user ###
option tcp-check
tcp-check connect port 10000
tcp-check send GET /check-status HTTP/1.1rn
tcp-check send rn
tcp-check expect rstring "200"
server data1 10.0.0.20:3306 maxconn 500 fall 2 inter 2000 rise 10 backup
server data2 10.0.0.20:3307 maxconn 500 check fall 2 inter 2000 rise 10
I had a mysql-check, it’s commented in config, it worked well, but now I have task to check not only health of mysql instance. One instance is backup and they have master-master replication. So, when main server rises, I need to be sure that replication not failed. I made tcp-check for this, it checks status of slave_io_running (Yes), slave_sql_running(Yes) and seconds_behind_master(0) and respond with code 200 OK. And only then main database set to status UP.
If main server failed, parameter slave_io_running on backup server will change to “connecting”, so my check will fail and I loose whole backend.
Roman Gunko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.