HA mail server configuration

clusterdovecotemailpostfix

I have a mail domain and two servers (machines) with Centos 6.4 and public IP addresses. Postfix mail server and Dovecot IMAP/POP3 Server are installed on both.

How would I set them up redundantly so that they would be in sync permanently so I could send and receive using any one of them and there would be no visible outage if one of the servers were down? Should the Inbox and all messages be stored on both servers for redundancy?

Best Answer

You would need to cluster your Dovecot service. This is commonly done using a highly-available shared storage (which can be a distributed file system like GlusterFS / RedHat GFS2), see the Dovecot Wiki for details.

It also seems possible to use the dsync mailbox replication engine for keeping your instances in sync without the need for shared storage. A design draft dealing with the details of such an implementation has been published on the Dovecot blog. Make sure to use the latest 2.2 release of DoveCot if you take this route.

The SMTP service for incoming mail would not need clustering as such - the protocol is designed for fault-tolerant implementations without a single point of failure. You simply can set up two independent Postfix instances delivering to your Dovecot cluster and provide MX records pointing to each of them.

To have users connect seamlessly to your SMTP and IMAP services during an outage, consider providing a virtual IP address using a cluster resource manager service similar to Pacemaker which would be set up to direct users to the functioning server immediately and any outages would go truly unnoticed. If you cannot spare another IPv4 address for the use as a virtual IP, just setting up your both servers' IP addresses as A records for a single label in the DNS would do the job too, but clients might notice inconsistent behavior or prolonged connection times while trying to connect to an unavailable or malfunctioning server.