使用Haproxy搭建smtp邮件服务器集群

适应适合版本的Linux版本和任意MTA(postfix/sendmail/Qmail)

前端代理我选择了CentOS 5 32位系统
怎么通过rpm安装即可,下载地址是http://download.fedora.redhat.com/pub/epel/5/i386/haproxy-1.3.25-1.el5.i386.rpm
执行
rpm -ivh http://download.fedora.redhat.com/pub/epel/5/i386/haproxy-1.3.25-1.el5.i386.rpm
即完成安装
haproxy默认配置文件放在/etc/haproxy/haproxy.cfg
举例我的配置文件

global
log 127.0.0.1 local2
#chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon

listen stats 184.82.2.32:808 ###查看状态的地址和端口http://184.82.2.32:808/haproxy?stats
balance
mode http
stats enable
stats auth taobao:Tao@2011
timeout connect 10000 # default 10 second time out if a backend is not found
timeout client 300000
timeout server 300000
maxconn 60000
retries 3

listen smtp 184.82.2.32:25 ###服务实例监听的IP和端口
mode tcp
log global
timeout connect 10000 # default 10 second time out if a backend is not found
timeout client 300000
timeout server 300000
maxconn 60000
retries 3

balance roundrobin ###负载策略
server smtpb 173.224.219.253:25 check ###后端真实服务器
server smtpc 173.212.221.25:25 check ###后端真实服务器

再执行/etc/init.d/haproxy start启动haproxy即可