2012/07/16

HAproxy


設定檔

global
 log 127.0.0.1 local0
 #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 192.168.0.111:25

 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 192.168.0.113:25 check ###后端真实服务器
 server smtpb 192.168.0.114:25 check ###后端真实服务器


安裝


cd /tmp/
useradd haproxy
wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.21.tar.gz
tar -xf haproxy-1.4.21.tar.gz
cd haproxy-1.4.21
make TARGET=linux26 PREFIX=/usr/local/haproxy
make install
vi /usr/local/haproxy/haproxy.cfg
haproxy -f /usr/local/haproxy/haproxy.cfg


啟動

/usr/local/sbin/haproxy -f /etc/haproxy/haproxy.cfg

停止

ps aux |grep haproxy

kill (pid number)



No comments: