运行 Almalinux 8.5,rsyslog
版本 8.2102.0-5.el8。几周前,我的所有系统日志(、、secure
... )开始显示 0 字节值。结果他们不再收到期刊的消息了。程序特定日志(例如 Apache)工作正常。messages
cron
到目前为止,我已经启动/重新启动了两者,rsyslog
并且systemd-journald
都确认了运行。旋转日志 - 什么也没有。尝试查看是否是权限问题:
然:ls -ld /var/log
drwxr-xr-x 9 root root 4096 Nov 28 02:42 /var/log
还跑了:ls -l /var/log
total 30076
-rw-r--r-- 1 root root 57930 Oct 1 11:16 almalinux-deploy.debug.log
-rw-r--r-- 1 root root 340552 Oct 1 11:16 almalinux-deploy.log
-rw-rw---- 1 root utmp 11740416 Nov 30 15:32 btmp
-rw-rw---- 1 root utmp 1536 Oct 6 22:55 btmp-20211101
-rw------- 1 root root 0 Nov 28 02:42 cron
-rw------- 1 root root 856453 Nov 7 02:42 cron-20211107
-rw------- 1 root root 56894 Nov 7 14:03 cron-20211114
-rw------- 1 root root 0 Nov 14 02:42 cron-20211121
-rw------- 1 root root 158412 Nov 27 09:39 cron-20211128
-rw-r--r-- 1 root root 619845 Nov 30 15:38 dnf.librepo.log
-rw-r--r-- 1 root root 409954 Nov 30 15:38 dnf.log
-rw-r--r-- 1 root root 1048575 Nov 18 01:53 dnf.log.1
-rw-r--r-- 1 root root 168211 Nov 30 15:38 dnf.rpm.log
-rw------- 1 root root 0 Nov 17 02:42 dovecot-lmtp-errors.log
-rw------- 1 root root 4240 Oct 7 15:29 dovecot-lmtp-errors.log-20211009
-rw------- 1 root root 1424 Oct 21 23:41 dovecot-lmtp-errors.log-20211022
-rw------- 1 root root 1424 Oct 27 18:02 dovecot-lmtp-errors.log-20211029
-rw------- 1 root root 1232 Nov 9 10:05 dovecot-lmtp-errors.log-20211110
-rw------- 1 root root 85 Nov 16 18:57 dovecot-lmtp-errors.log-20211117
-rw------- 1 root root 0 Nov 9 10:03 dovecot-lmtp.log
drwx------ 2 mail mail 4096 Nov 28 02:42 exim
-rw-r----- 1 root root 186 Oct 1 11:08 firewalld
-rw-r--r-- 1 root root 1980 Nov 30 15:38 hawkey.log
-rw-r--r-- 1 root root 960 Nov 6 06:38 hawkey.log-20211107
-rw-r--r-- 1 root root 3420 Nov 13 23:56 hawkey.log-20211114
-rw-r--r-- 1 root root 3960 Nov 21 02:39 hawkey.log-20211121
-rw-r--r-- 1 root root 3060 Nov 28 00:31 hawkey.log-20211128
drwx--x--- 3 apache root 4096 Nov 30 00:10 httpd
drwxr-sr-x+ 3 root systemd-journal 4096 Oct 1 11:07 journal
-rw-rw-r-- 1 root utmp 292584 Nov 30 16:00 lastlog
-rw------- 1 root root 77008 Nov 30 16:16 lfd.log
-rw------- 1 root root 7480 Nov 28 02:40 lfd.log-20211128.gz
-rw------- 1 root root 0 Nov 28 02:42 maillog
-rw------- 1 root root 94207 Nov 7 01:39 maillog-20211107
-rw------- 1 root root 7274 Nov 7 14:03 maillog-20211114
-rw------- 1 root root 0 Nov 14 02:42 maillog-20211121
-rw------- 1 root root 10025 Nov 27 09:39 maillog-20211128
-rw------- 1 root root 273 Nov 30 15:19 messages
-rw------- 1 root root 11607290 Nov 7 02:42 messages-20211107
-rw------- 1 root root 805384 Nov 7 14:03 messages-20211114
-rw------- 1 root root 0 Nov 14 02:42 messages-20211121
-rw------- 1 root root 2458409 Nov 27 09:39 messages-20211128
lrwxrwxrwx 1 root root 36 Oct 1 11:53 php-fpm74.log -> /usr/local/php74/var/log/php-fpm.log
lrwxrwxrwx 1 root root 36 Oct 1 14:25 php-fpm80.log -> /usr/local/php80/var/log/php-fpm.log
drwx------ 2 root root 4096 Jan 19 2021 private
-rw------- 1 root root 0 Nov 10 01:22 pureftpd.log
drwx------ 3 root root 4096 Oct 9 16:51 samba
-rw------- 1 root root 0 Nov 28 02:42 secure
-rw------- 1 root root 5895 Nov 6 04:23 secure-20211107
-rw------- 1 root root 67 Nov 7 14:03 secure-20211114
-rw------- 1 root root 0 Nov 14 02:42 secure-20211121
-rw------- 1 root root 12178 Nov 27 09:39 secure-20211128
-rw------- 1 root root 0 Nov 28 02:42 spooler
-rw------- 1 root root 0 Oct 31 02:42 spooler-20211107
-rw------- 1 root root 0 Nov 7 02:42 spooler-20211114
-rw------- 1 root root 0 Nov 14 02:42 spooler-20211121
-rw------- 1 root root 0 Nov 21 02:42 spooler-20211128
drwx--x--x 2 root root 4096 Nov 30 00:10 user_logs
-rw-rw-r-- 1 root utmp 71808 Nov 30 16:00 wtmp
rsyslog 没有单独的用户,一切都从 root 运行,所以这不应该是一个问题。还尝试删除imjournal.state
文件并重新启动日志服务 - 从十月初该服务器的重建中收到一堆消息。 Journalctl 确实显示了最近的条目,包括失败的 SSH 登录等,所以日志服务并不是死了 - 正在发生某种断开连接......
我的文件内容rsyslog.conf
供参考:
#### MODULES ####
module(load="imuxsock" # provides support for local system logging (e.g. via logger command)
SysSock.Use="off") # Turn off message reception via local log socket;
# local messages are retrieved through imjournal now.
module(load="imjournal" # provides access to the systemd journal
StateFile="imjournal.state") # File to store the position in the journal
#module(load="imklog") # reads kernel messages (the same are read from journald)
#module(load="immark") # provides --MARK-- message capability
# Provides UDP syslog reception
# for parameters see http://www.rsyslog.com/doc/imudp.html
#module(load="imudp") # needs to be done just once
#input(type="imudp" port="514")
# Provides TCP syslog reception
# for parameters see http://www.rsyslog.com/doc/imtcp.html
#module(load="imtcp") # needs to be done just once
#input(type="imtcp" port="514")
#### GLOBAL DIRECTIVES ####
# Where to place auxiliary files
global(workDirectory="/var/lib/rsyslog")
# Use default timestamp format
module(load="builtin:omfile" Template="RSYSLOG_TraditionalFileFormat")
# Include all config files in /etc/rsyslog.d/
include(file="/etc/rsyslog.d/*.conf" mode="optional")
#### 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
我确信这是一些明显被忽视的事情。有任何想法吗?
答案1
我在我的家庭服务器上也遇到同样的情况。
我找到了一个可能的解决方案不再写入系统日志,也不再创建文件:
systemctl restart systemd-journald.socket
systemctl restart systemd-journald
systemctl restart rsyslog
目前看来这对我有用。文章的一部分还建议采取措施stat /dev/log
确保它的存在。这是给我的,但无论如何我运行了上面的内容,现在有了日志记录。
答案2
我的日志(邮件、消息等)也为空。我无法启动 rsyslogd。原来是selinux的问题。以下内容有所帮助。从测试开始:
logger -p mail.info "testing maillog"
这应该在maillog
.起初它不起作用。
getenforce # -> Enforcing
setenforce 0
getenforce # -> Permissive
logger -p mail.info "testing maillog" # works now
setenforce 1
getenforce # -> Enforcing
在另一台机器上我安装了 AlmaLinux 8 最小化。它是如此之小以至于没有安装 rsyslog。有一个从/etc/systemd/system/syslog.service
到rsyslog
in 的符号链接/usr
。由于 rsyslog 不存在,链接已损坏。我不得不说
dnf install rsyslog
systemctl enable rsyslog --now