t...@iredmail.org [2016-10-21 00:11 +0200] : > We use the floating IP address (handled by KeepAlived) in Postfix config > file, we expect Postfix can always connect to a mysql server.
I have a similar set up (instead of MySQL I use OpenLDAP though). Assuming that your servers are in a VPN, why don't you configure Postfix to use one (or both) of your proxies via their private addresses? The proxies will then distribute the traffic to available MySQL instances. > The problem is, Postfix keeps persist sql connection to this > server itself, if currently connected mysql server is down, > HAProxy will redispatch the mysql request to another backend > (this is expected), this breaks the persist sql connection > maintained by Postfix itself, so Postfix will raise error and > cannot reconnect. Have you configured no option http-server-close http://cbonte.github.io/haproxy-dconv/1.6/configuration.html#no%20option%20http-server-close for your MySQL frontend/backend in HAProxy? > *) Postfix supports auto reconnecting to another mysql server if we list > several mysql servers in its config file, but we have only one - the > floating IP address. You have: The two private addresses of your proxies. > *) Postfix also supports auto reconnecting if we use a domain name (with > multiple A records in DNS) or multiple mysql nodes IPs as sql server > address. although no error raised with this method, we lose the load-balance > feature for mysql request. You could configure your own DNS that does support this idea.