You want to reconfigure your MySQL server to only bind to the IP address
you want it to, rather than to *:3306 so your haproxy instance can bind
to 3306 on the VIP.
On 4/16/15 4:19 PM, Tim Dunphy wrote:
Hello,
I'm trying to get haproxy to work with two database servers. But I'm
getting stuck on an error when trying to start up haproxy. Saying that
it can't bind to the socket.
[root@aoadbld00036la haproxy]# service haproxy start
Starting haproxy: [ALERT] 105/160506 (29040) : Starting proxy
mysql-cluster: cannot bind socket
[FAILED]
Mysql is running and listening on port 3306 on all interfaces:
[root@aoadbld00036la haproxy]# lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 28711 mysql 22u IPv4 6614552 0t0 TCP *:mysql (LISTEN)
mysqld 28711 mysql 44u IPv4 6614952 0t0 TCP
aoadbld00036la:mysql->aoadbld00036lb.stg-tfayd.com:56669
<http://aoadbld00036lb.stg-tfayd.com:56669> (ESTABLISHED)
I have a virtual IP being provided by keepalived. I have a mysql
database listening to this ip. I'm not using the real IP for this
post. But I can log into the database using this virtual IP.
I have non local binds setup in sysctl.conf :
[root@aoadbld00036la ~]# grep ipv4 /etc/sysctl.conf | grep bind
net.ipv4.ip_nonlocal_bind = 1
But for some reason this configuration still isn't giving me any luck!
global
log 127.0.0.1 local0 notice
user haproxy
group haproxy
defaults
log global
retries 2
timeout connect 3000
timeout server 5000
timeout client 5000
listen mysql-cluster
bind 10.10.10.163:3306 <http://10.10.10.163:3306>
mode tcp
option mysql-check user haproxy_check
balance roundrobin
server mysql-1 10.10.10.248:3306 <http://10.10.10.248:3306> check
server mysql-2 10.10.10.249:3306 <http://10.10.10.249:3306> check
listen stats *:80
mode http
stats enable
stats uri /
stats realm Strictly\ Private
stats auth admin:secret
Can someone please help me out on the solution here?
I think the answer may be to get mysql to listen on a different port
locally. And have the VIP address provide the service on the load
balacned VIP address.
Please correct me if I'm wrong there.
Thanks,
Tim
--
GPG me!!
gpg --keyserver pool.sks-keyservers.net
<http://pool.sks-keyservers.net> --recv-keys F186197B