0

I am running 2 dedicated servers on which each has HAProxy keepalived running, MySQL in master/master and Apache.

Load Balancing for Apache already works, but I can not get MySQL LB running.

HAProxy stats says: DB2 down "access denied for haproxy_check@db2 "

From a tutorial I have learned that I have to prepare mysql:

mysql -u root -p -e "INSERT INTO mysql.user (Host,User) values ('10.0.0.10','haproxy_check'); FLUSH PRIVILEGES;"

My haproxy config looks like this:

listen mysql-cluster
    bind 10.0.0.10:3306
    mode tcp
    option mysql-check user haproxy_check
    balance roundrobin
    server db1 10.0.0.120:3307 check
    server db2 10.0.0.130:3307 check

Why is HAProxy trying to connect from 10.0.0.130 instead of his VIP 10.0.0.10?

I could of course grant access to 10.0.0.130 but this will ruin the idea of failover. This works by the way.

0

According to the HAProxy manual, you can use the source keyword to force a backend or listen block to use a particular IP when connecting to servers.

Your listen block would then look like:

listen mysql-cluster
  bind 10.0.0.10:3306
  mode tcp
  option mysql-check user haproxy_check
  balance roundrobin
  source 10.0.0.10
  server db1 10.0.0.120:3307 check
  server db2 10.0.0.130:3307 check

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.