Separate XtraDB Clusters managed via HAProxy?

I’d like to use HAProxy to direct traffic between completely separate MySQL environments within 1 HAProxy installation, but without having to deviate from the standard port.

Is it possible for HAProxy to direct TCP traffic on multiple addresses but on the same port?

When I try the config below, I get a “cannot bind socket” error, as the address/port is already being used.

In TCP mode, can haproxy distinguish between hostnames?

Thanks in advance!

Example:

#-------------------

PRODUCTION CLUSTER

#-------------------
listen prod_cluster
bind production.example.com:3306
mode tcp
balance roundrobin
option httpchk

server prodDB1 proddb1.example.com:3306 check port 9200 inter 2000 rise 3 fall 3
server prodDB2 proddb2.example.com:3306 check port 9200 inter 2000 rise 3 fall 3 backup
server prodDB3 proddb3.example.com:3306 check port 9200 inter 2000 rise 3 fall 3 backup


#-------------------

STAGE CLUSTER

#-------------------
listen stage_cluster
bind staging.example.com:3306
mode tcp
balance roundrobin
option httpchk

server stageDB1 stagedb1.example.com:3306 check port 9200 inter 2000 rise 3 fall 3
server stageDB2 stagedb2.example.com:3306 check port 9200 inter 2000 rise 3 fall 3 backup
server stageDB3 stagedb3.example.com:3306 check port 9200 inter 2000 rise 3 fall 3 backup

  1. You can not do HA proxy port3306 on same servers which running one cluster server. You need to assigned different port to HAproxy.

  2. You can use same port3306 in HAProxy if you are running HAproxy on different servers.

Did you try binding pure IP address (not FQDN)?