I have have set up MySQL multi-master replication with HAProxy as a load balancer following Alex Williams' tutorial found here; http://www.alexwilliams.ca/blog/2009/08/10/using-haproxy-for-mysql-failover-and-redundancy/

I am using a status checker found here; http://sysbible.org/2008/12/04/having-haproxy-check-mysql-status-through-a-xinetd-script/

as well as a replication checker found here; http://forge.mysql.com/tools/tool.php?id=6

The Mysql status checker works fine when I have the following line in my HAProxy config file:

server db02 check port 9200 inter 1s weight 1 rise 1 fall 1

But when I try to test the check replication script with this line:

server db02 check port 9201 inter 1s weight 1 rise 1 fall 1

and try to connect through the proxy I get a failure:

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication  packet', system error: 0

When I telnet from the HAProxy machine to that port it works fine:

# telnet 9201

Connected to
Escape character is '^]'.
Replication slave is running
Connection closed by foreign host.

Is there any reason that that would not work while I can still check it through telnet? Is this a limitation of HAProxy? I would assume not as it seems that this is what others have used for their setups. Is it a configuration or permissions issue? I am confused as to how one of them would work and let me connect fine, but the other will not.

  • What do you want to do with the replication script checker? Please show us the content of haproxy.cfg, /etc/xinetd.d/<replication_checker>?
    – quanta
    Jul 12 '12 at 3:15
  • I wanted to check if replication was working every time a connection was made through the proxy. I already gave the pertinent info from haproxy.cfg, and I know the xinetd service is running properly because I can telnet to the port and it runs the script. It is only when telling HAProxy to check the port for the replication checker that it fails. In any event, I just put the script to run every minute in crontab, which is suitable for my situation, although not exactly an answer to the question.
    – Joe Gibson
    Jul 12 '12 at 13:46
  • I need the full haproxy.cfg or at least MySQL backend section.
    – quanta
    Jul 12 '12 at 14:43

Your replication script run by xinetd should return HTTP 200 or 503, so HAProxy can detect the health of MySQL replication.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.