Haproxy在Freebsd下不能记录日志的问题

这几天给蹦心(bengxin.com) 开发环境配置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/<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/<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很多国外站点被封,查资料那叫一个不方便!!!!

以上内容,绝对是目前的终极可行的解决方案,查不到第二个!

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
8 Responses
  1. 金融危机的影响 says:

    自己动手 丰衣足食。。 很多时候XX知道的东西 答案都很多水分的

  2. Michael says:

    [Comment ID #31684 Will Be Quoted Here]

    没错,官方文档+源码最靠谱! 不过有些时候,他人的经验还是不错的。

  3. 减肥方法 says:

    看你博客写的都很专业的 一定很厉害

  4. 百度优化 says:

    确实好专业 天天来拜读了

  5. 英语翻译器 says:

    讲的好啊

  6. 土匪头 says:

    NB!

  7. test says:

    请问下,你这个参数加载那个文件里面,-a 127.0.0.1/32:* -a localhost:* -a 192.168.222.0/16:* 是加入到syslogd这个文件中么?麻烦指点下,谢谢!

  8. Michael says:

    自己动手 丰衣足食。。很多时候XX知道的东西 答案都很多水分的

    这个参数加到 /etc/rc.conf里面,类似下面的

    syslogd_flags=”-a localhost:* -a 127.0.0.1/32:* -a 192.168.222.0/16:*”

  9. Hello, this weekend is fastidious designed for me, because this time i am
    reading this impressive informative article here at my home.

  10. I like reading through an article that can make people think.
    Also, many thanks for allowing me to comment!

  11. It’s a shame you don’t have a donate button! I’d without
    a doubt donate to this brilliant blog! I guess for now i’ll settle for
    book-marking and adding your RSS feed to my Google account.
    I look forward to new updates and will share this site with my Facebook group.

    Talk soon!

  12. Terrific article! This is the kind of information that are
    supposed to be shared around the internet. Disgrace on the seek engines for not positioning this submit higher!
    Come on over and consult with my web site . Thank you =)

  13. What’s up, yup this paragraph is truly pleasant and I have
    learned lot of things from it concerning blogging.
    thanks.

  14. Coconut Oil says:

    I was wondering if you ever thought of changing
    the page layout of your website? Its very well written; I love what youve
    got to say. But maybe you could a little more in the way
    of content so people could connect with it better.
    Youve got an awful lot of text for only having 1 or
    two images. Maybe you could space it out better?

  15. Hey there! I’ve been reading your website for some time now
    and finally got the courage to go ahead and give you a shout out from Lubbock Texas!
    Just wanted to mention keep up the good job!

  16. Hi to every , because I am in fact keen of reading this web site’s post to be updated daily.
    It consists of good data.

  17. Greetings from Carolina! I’m bored to tears at work so I decided
    to browse your site on my iphone during lunch break.
    I really like the knowledge you provide here and can’t wait to take
    a look when I get home. I’m surprised at how quick your blog loaded on my phone
    .. I’m not even using WIFI, just 3G .. Anyhow, awesome blog!

  18. bookmarked!!, I really like your web site!

  19. Sling TV says:

    Aw, this was a really good post. Taking a few minutes and
    actual effort to create a superb article… but what can I say… I put things off a lot and never
    manage to get nearly anything done.

  20. I think the admin of this website is actually working hard in favor of his web site,
    since here every material is quality based material.

  21. Sling tv coupons and promo codes for november 2018
    Hi there, You have done a fantastic job. I’ll definitely digg it and personally suggest to my friends.
    I am sure they will be benefited from this web site.
    Sling tv coupons and promo codes for november 2018

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image