1

I'm trying to configure haproxy to cluster a couple of mysql servers (galera cluster), but it seems that haproxy does not accept dns name in the server directive.

e.g. config

listen mysql 127.0.0.1:3306
  timeout connect 10000
        option clitcpka
        option srvtcpka
        option abortonclose
        mode tcp
        option mysql-check
        balance roundrobin
        # this works
        server mysql-001 1.2.3.4:3306 check port 3306 check inter 5000
        server mysql-002 1.2.3.5:3306 check port 3306 check inter 5000
        # this doesn't
        server mysql-003 ec2-1-2-3-6.eu-west-01.compute.amazonaws.com:3306 check port 3306 check inter 5000

It complains with error:

[ALERT] 241/152647 (27025) : parsing [/etc/haproxy/haproxy.cfg:26] : 'server mysql-003' : invalid address: 'ec2-1-2-3-6.eu-west-01.compute.amazonaws.com' in 'ec2-1-2-3-6.eu-west-01.compute.amazonaws.com:3306'

The reason I would like to use DNS name here is to simplify the security-group confguration, and be able to use elastic IPs on the nodes.

Is there a way around this problem?

Yoav Aner
  • 561
  • 2
  • 6
  • 13
  • HAProxy doesn't appear to support hostnames. https://code.google.com/p/haproxy-docs/wiki/ServerOptions – ceejayoz Aug 30 '13 at 16:00
  • Yes, I know. I wonder why. I'm trying to find a solution around that, which will ideally play nice with AWS security groups... – Yoav Aner Aug 30 '13 at 16:18
  • HAProxy recently added hostname support in version 1.6. – SunSparc Nov 10 '15 at 22:28
  • @ceejayoz - According to https://cbonte.github.io/haproxy-dconv/configuration-1.6.html#5.3, names are supported: "
    is the IPv4 or IPv6 address of the server. Alternatively, a resolvable hostname is supported, but this name will be resolved during start-up"
    – Don Branson Nov 18 '15 at 21:41
  • @DonBranson I'd note that this question was posted in 2013. :-p – ceejayoz Nov 18 '15 at 21:54
  • Yeah, just an update for passersby. – Don Branson Nov 18 '15 at 22:16

0 Answers0