【问题标题】:Same rsyslog config on two servers, different output两台服务器上相同的 rsyslog 配置,不同的输出
【发布时间】:2015-07-06 17:07:41
【问题描述】:

我开始使用 rsyslog 将日志文件数据发送到远程服务器。

我有一个开发 (server1) 和生产 (server2)。两个系统都使用相同版本的 CentOS 和 rsyslog。 rsyslog.conf 和 httpd 配置文件是相同的(保存上面的服务器名称)。

问题是其中一个系统正在将它自己的 IP 添加到 rsyslog 流中,而另一个没有。在下面的日志数据中,我的本地 IP 是 1.2.3.4,而服务器 IP 在 99.99.99.X 子网中。


server1 - CentOS 6.5(开发版,99.99.99.77)

Name        : rsyslog
Arch        : x86_64
Version     : 5.8.10
Release     : 10.el6_6

httpd 配置:

ErrorLog "| tee -a /var/log/httpd/error_log | logger -thttpd_server1_ssl_error -plocal6.err"

CustomLog "|tee -a /var/log/httpd/access_log | logger -thttpd_server1_ssl_access -plocal5.notice" 合并

rsyslog 输出: 注意只包含远程 IP...

消息:7 月 6 日 11:57:24 server1 httpd_access:1.2.3.4 - - [06/Jul/2015:11:57:23 -0400] "GET /somepage.html HTTP/ 1.1" 200 - "https://server1.top.level.domain/" "text/html" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0"


server2 - CentOS 6.5(产品,99.99.99.99)

Name        : rsyslog
Arch        : x86_64
Version     : 5.8.10
Release     : 10.el6_6

httpd 配置:

ErrorLog "| tee -a /var/log/httpd/error_log | logger -thttpd_server2_ssl_error -plocal6.err"

CustomLog "|tee -a /var/log/httpd/access_log | logger -thttpd_server2_ssl_access -plocal5.notice" 合并

rsyslog 输出: 请注意,远程和服务器 IP 都包括在内...

消息:7 月 6 日 11:58:49 server2 httpd_access:1.2.3.4 99.99.99.99 - - [06/Jul/2015:11:58:49 -0400] "GET https://server1.top.level.domain/ HTTP/1.1" 200 443 20


【问题讨论】:

    标签: rsyslog


    【解决方案1】:

    问题在于两台服务器之间httpd.conf 文件中的LogFormat 存在差异。

    server2上,我改变了

    LogFormat "%h %A %l %u %t \"%r\" %>s %p %b" combined
    

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{Content-Type}o\" \"%{User-Agent}i\"" combined
    

    server1 上的内容匹配。

    然后我重新启动了 apache,现在两台服务器都有相同的 rsyslog 数据流(这意味着我在出站日志数据中看到的是远程用户 IP,而不是远程和服务器 IP)。 p>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-29
      • 1970-01-01
      • 1970-01-01
      • 2015-01-27
      相关资源
      最近更新 更多