http://blog.csdn.net/tantexian/article/details/50056199 三大負載均衡軟件對比
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
chroot /usr/local/haproxy
uid nobody
gid nobody
daemon
#debug
#quiet
pidfile /root/Desktop/haproxy.pid
defaults
mode tcp #默認的模式mode { tcp|http|health },tcp是4層,http是7層,health只會返回OK
retries 3 #兩次連接失敗就認爲是服務器不可用,也可以通過後面設置
option redispatch #當serverId對應的服務器掛掉後,強制定向到其他健康的服務器
option abortonclose #當服務器負載很高的時候,自動結束掉當前隊列處理比較久的鏈接
maxconn 32000 #默認的最大連接數
timeout connect 5000ms #連接超時
timeout client 30000ms #客戶端超時
timeout server 30000ms #服務器超時
#timeout check 2000 #心跳檢測超時
listen test1
bind 0.0.0.0:8008
mode tcp
balance roundrobin
server s1 172.16.241.43:8010 weight 1 maxconn 10000 check inter 10s
server s1 172.16.241.43:8011 weight 1 maxconn 10000 check inter 10s
server s1 172.16.241.43:8012 weight 1 maxconn 10000 check inter 10s
haproxy.sh
#!/bin/sh
/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/conf/haproxy.cfg
查看啓動成功,ps -ef |grep haproxy