转自:http://www.toplee.com/blog/924.html
这几天给蹦心() 开发环境配置haproxy,遇到的这个问题困扰了我一个晚上,google和baidu了N次也没有找到解决办法,最后自己通读了syslogd和syslog.conf以及haproxy的log相关的man pages,经过若干次的syslogd -d (debug) ,终于在debug日志里面发现了端倪,有这么一个东西导致了日志不能正确的记录到haproxy指定的日志文件里面:
validate: dgram from IP 127.0.0.1, port 49336, name localhost.bengxin.com;
rejected in rule 0 due to port mismatch.
rejected in rule 1 due to port mismatch.
rejected in rule 2 due to port mismatch.
于是给syslogd启动参数加入了下面的内容:
-a 127.0.0.1/32:* -a localhost:* -a 192.168.222.0/16:*
于是乎,期待了很久的haproxy日志出现了!
dev# tail -f /var/log/haproxy/haproxy_3.log
Aug 22 15:32:06 localhost haproxy[64136]: Proxy www started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy cherokee started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy wap started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy pic started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy img started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy public started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy public started.
Aug 22 15:32:59 localhost haproxy[64137]: 219.142.128.30:6416 [22/Aug/2009:15:32:59.754] public stats/ 0/-1/-1/-1/0 200 17329 - - PR-- 0/0/0/0/0 0/0 "GET /?stats HTTP/1.1"
Aug 22 15:32:59 localhost haproxy[64137]: 219.142.128.30:6416 [22/Aug/2009:15:32:59.754] public stats/ 0/-1/-1/-1/0 200 17329 - - PR-- 0/0/0/0/0 0/0 "GET /?stats HTTP/1.1"
我的haproxy和日志相关的配置部分如下:
log global
mode http
option httplog
option dontlognull
log 127.0.0.1 local3
还有部分非常关键的东西需要注意,首先是syslog.conf里面必须使用作为分隔符,貌似空格就有问题,然后是需要写成下面的这个格式:
!*
local0.* /var/log/haproxy/haproxy_0.log
最后这一点要感谢bsd社区上的一个老外给我的帮助,回复maillist真是够迅速的!
finally,BS很多国外站点被封,查资料那叫一个不方便!!!!
以上内容,绝对是目前的终极可行的解决方案,查不到第二个!
Tags: haproxy, syslogd
阅读(1472) | 评论(0) | 转发(0) |