重启haproxy
http://www.google.com.hk/search?hl=en&safe=active&sa=X&ei=mnC_Tff4D4quuQPSwMiuBA&ved=0CBcQvwUoAQ&q=%E9%87%8D%E5%90%AFhaproxy&spell=1
http://hx100.blog.iyunv.com/44326/344020
启动haproxy
# /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg
重启haproxy
# /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg -st `cat /usr/local/haproxy/haproxy.pid`
停止haproxy
# killall haproxy
http://weizhifeng.net/2011/03/26/haproxy-configuration-log-issue/
Haproxy 配置(日志问题解决)
2011年03月26日 in HAProxy
Haproxy是一个负载均衡服务器,能够提供4层,7层代理,并能支持上万级别的
连接,你可以直接在WEB服务器前端加上它,而不影响应用的访问,完全透明。
1. 安装1wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.8.tar.gz
2tar -zxvf haproxy-1.4.8.tar.gz
3cd haproxy-1.4.8
4./configure --prefix=/path/to/haproxy
5make && make install
2.配置
首先要添加haproxy:haproxy用户:1groupadd haproxy
2useradd -g haproxy haproxy
3sudo cat /etc/passwd |grep haproxyc #查看uid和gid
编辑haproxy.cfg,添加如下内容:01global
02 log 127.0.0.1 local3
03 maxconn 4096 #最大连接数
04 chroot /path/to/haproxy #安装目录
05 uid 535#用户haproxy
06 gid 520#组haproxy
07 daemon #守护进程运行
08 nbproc 1 #进程数量
09 pidfile logs/haproxy.pid
10defaults
11 log 127.0.0.1 local3
12 mode http#layer 7代理
13 optionhttplog
14 optionhttpclose
15 optiondontlognull
16 optionforwardfor
17 retries 2
18 maxconn 2000
19 balance roundrobin
20 stats uri /haproxy-stats
21 contimeout 5000
22 clitimeout 50000
23 srvtimeout 50000
24
25frontend http-in
26 bind *:80 #监听地址
27 default_backend pool1
28
29backend pool1
30 optionhttpchk GET /test.php #用来做健康检查
31 stats refresh 2
32 server server1 192.168.1.1:82 weight 3 maxconn 32 check #check表示对这个server进行健康检查
33 server server2 192.168.1.2:82 weight 3 maxconn 32 check
查看后端server状态:
http://example.com/haproxy-stats1#启动
2sudo ./sbin/haproxy -f haproxy.cfg
3#重启
4sudo ./sbin/haproxy -f haproxy.cfg -st `cat logs/haproxy.pid`
3.日志问题
有童鞋说日志怎么也写不进去,我也遇到了这个问题,在这里分享下。
编辑/etc/syslog.conf文件,添加:1local3.* /var/log/haproxy.log
编辑/etc/sysconfig/syslog文件,把SYSLOGD_OPTIONS=”-m 0″ 改成 SYSLOGD_OPTIONS=”-r -m 0″ #enables logging from remote machines
重启syslogd: /etc/init.d/syslog restart
tail -f -n 30 /var/log/haproxy.log 应该可以看到日志输出了:)
参考:
http://blog.chenlb.com/2009/06/install-haproxy-and-configure-load-balance.html
http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
页:
[1]