我想将 IP 电话上的系统日志导出到远程系统日志服务器。我已经设置好了一切,执行 tcpdump 时可以看到系统日志数据包到达服务器,但我没有在日志文件中的任何位置看到系统日志。我假设这些应该记录到 /var/log/messages 中,但我没有在那里看到它。我做错了什么?
服务器正在运行:
# systemctl status rsyslog
● rsyslog.service - System Logging Service
Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2018-02-06 18:44:04 EST; 1 weeks 1 days ago
Main PID: 22533 (rsyslogd)
CGroup: /system.slice/rsyslog.service
└─22533 /usr/sbin/rsyslogd -n
这是 /etc/rsyslog.conf
# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514
#### GLOBAL DIRECTIVES ####
# Where to place auxiliary files
$WorkDirectory /var/lib/rsyslog
# Use default timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# File syncing capability is disabled by default. This feature is usually not required,
# not useful and an extreme performance hit
#$ActionFileEnableSync on
# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf
# Turn off message reception via local log socket;
# local messages are retrieved through imjournal now.
$OmitLocalLogging on
# File to store the position in the journal
$IMJournalStateFile imjournal.state
#### RULES ####
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
# The authpriv file has restricted access.
authpriv.* /var/log/secure
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
*.emerg :omusrmsg:*
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
# ### begin forwarding rule ###
# The statement between the begin ... end define a SINGLE forwarding
# rule. They belong together, do NOT split them. If you create multiple
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.
#$ActionQueueFileName fwdRule1 # unique name prefix for spool files
#$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
#$ActionQueueType LinkedList # run asynchronously
#$ActionResumeRetryCount -1 # infinite retries if host is down
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
#*.* @@remote-host:514
# ### end of the forwarding rule ###
# ss -anup
State Recv-Q Send-Q Local Address:Port Peer Address:Port
UNCONN 0 0 192.168.122.1:53 *:* users:(("dnsmasq",pid=2450,fd=5))
UNCONN 0 0 *%virbr0:67 *:* users:(("dnsmasq",pid=2450,fd=3))
UNCONN 0 0 127.0.0.1:323 *:* users:(("chronyd",pid=798,fd=1))
UNCONN 0 0 *:514 *:* users:(("rsyslogd",pid=2358,fd=3))
UNCONN 0 0 *:5353 *:* users:(("avahi-daemon",pid=753,fd=12))
UNCONN 0 0 *:48448 *:* users:(("avahi-daemon",pid=753,fd=13))
UNCONN 0 0 ::1:323 :::* users:(("chronyd",pid=798,fd=2))
UNCONN 0 0 :::514 :::* users:(("rsyslogd",pid=2358,fd=4))
答案1
Active: active (running) since Tue 2018-02-06 18:44:04 EST; 1 weeks 1 days ago
重新启动一下怎么样?
systemctl restart rsyslog
检查是否监听 UDP:
ss -anup
答案2
将 OmitLocalLogging 更改为关闭:
$OmitLocalLogging 关闭
这是通过本地日志套接字接收的问题。