rsyslog 无法向/var/log/messages
外部 syslog 收集器发送消息或向其发送消息,如下所述。
我有一个 AWS EC2 RHEL 7 实例和一个本地 RHEL 7 实例。它们都是最小安装、标准 AMI 等。rsyslog
除了添加.conf
文件/etc/rsyslog.d/
以将日志记录发送到外部 syslog 收集器外,配置是默认配置。本地实例将系统日志发送到本地收集器。AWS 实例将其发送到基于 EC2 的收集器。两个收集器在相同的配置中运行相同的软件,并从其他来源接收事件,否则正常运行。
/etc/rsyslog.conf
在两个实例之间是相同的。以下是未注释的行:
# grep -v "^#\|^$" /etc/rsyslog.conf
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imjournal # provides access to the systemd journal
$WorkDirectory /var/lib/rsyslog
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$IncludeConfig /etc/rsyslog.d/*.conf
$OmitLocalLogging on
$IMJournalStateFile imjournal.state
*.*;mail.none;authpriv.none;cron.none /var/log/messages
authpriv.* /var/log/secure
mail.* -/var/log/maillog
cron.* /var/log/cron
*.emerg :omusrmsg:*
uucp,news.crit /var/log/spooler
local7.* /var/log/boot.log
在云实例上添加了/etc/rsyslog.d/21-cloudinit.conf
:
# Log cloudinit generated log messages to file
:syslogtag, isequal, "[CLOUDINIT]" /var/log/cloud-init.log
# comment out the following line to allow CLOUDINIT messages through.
# Doing so means you'll also get CLOUDINIT messages in /var/log/syslog
& stop
在这两种情况下还有/etc/rsyslog.d/listen.conf
:
# cat /etc/rsyslog.d/listen.conf
$SystemLogSocketName /run/systemd/journal/syslog
在这两个实例/etc/rsylog.d/xdr.conf
上都添加了。它仅因系统日志消息的目的地而异,见下文。
云实例:
# cat /proc/version
Linux version 3.10.0-1160.62.1.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Wed Mar 23 09:04:02 UTC 2022
# yum list installed | grep rsyslog
rsyslog.x86_64 8.24.0-57.el7_9.2 @rhel-7-server-rhui-rpms
# cat /etc/rsyslog.d/xdr.conf
# Forward all log messages to Taegis XDR
# AWS Collector
*.* @@aws-v-xxxxxx-xxxxxx-xxxxxxxxxxxxx.elb.us-east-1.amazonaws.com:601
# On-Prem Collector
#*.* @@scwx-collector.xxx.local:601
本地实例:
# cat /proc/version
Linux version 3.10.0-1160.62.1.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Wed Mar 23 09:04:02 UTC 2022
# yum list installed | grep rsyslog
rsyslog.x86_64 8.24.0-57.el7_9.2 @rhel-7-server-rpms
# cat /etc/rsyslog.d/xdr.conf
# Forward all log messages to Taegis XDR
# AWS Collector
#*.* @@aws-v-xxxxxx-xxxxxx-xxxxxxxxxxxxx.elb.us-east-1.amazonaws.com:601
# On-Prem Collector
*.* @@scwx-collector.xxx.local:601
xdr.conf
可以从端口 601 上的每个实例访问中列出的端点。我通过快速telnet
会话独立确认。
# telnet scwx-collector.xxx.local 601
Trying 10.100.11.37...
Connected to scwx-collector.xxx.local.
Escape character is '^]'.
# telnet aws-v-xxxxxx-xxxxxx-xxxxxxxxxxxxx.elb.us-east-1.amazonaws.com 601
Trying 10.200.2.89...
Connected to aws-v-xxxxxx-xxxxxx-xxxxxxxxxxxxx.elb.us-east-1.amazonaws.com.
Escape character is '^]'.
AWS 实例工作正常。Syslog 消息被传送到收集器和/var/log/messages
. 本地服务器无法将消息传递到这两个位置。
在本地服务器上,如果我重命名并重新启动xdr.conf
服务,则会立即开始填充。启用后它们是空的 - 没有更多的条目出现。外部 syslog 收集器不显示任何接收到的事件,也不显示在 syslog 端点之间传输的任何数据包。xdr.conf.bak
rsyslog
/var/log/messages
xdr.conf
tcpdump
为什么 rsyslog 既不向/var/log/messages
外部收集器也不向外部收集器发送消息?唯一的区别是它将消息发送到的端点,据我所知,这些端点既可访问又正常运行。甚至 syslog 收集器端点也是相同的配置。两个操作系统是一样的,rsyslog是同一个版本。我该如何进一步解决这个问题?