linux - 某工的centos7 启动了rsyslog之后,日志/var/log/messages等都不产生日志了,都是空的。求大神解决!

查看:1850
本文介绍了linux - 某工的centos7 启动了rsyslog之后,日志/var/log/messages等都不产生日志了,都是空的。求大神解决!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

之前一直有日志生成的,正常运行,自从前几天搞了下好像重启了下rsyslog ,最后一次轮替日志之后,/var/log/message, /var/log/secure等都不记录了,并且都是空文件。

求高手帮忙看看,我想知道怎么解决,也想知道这是什么原因。感激不尽。

配置文件/etc/rsyslog.conf

# 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

/var/log/secure等都是空的,除了*-20161211是保留到截止9号的日志

/var/log/secure等都是空的

rsyslog也是重启过的

也就是从8号就开始不正常记录日志了,这个是fail2ban-20161211那个日志最后几行截图

解决方案

变找bug边刷新此页面,都等不来大神的解救,这位@StormerZ还给哥回答了不相关的,占页面且刷分给差评,点名批评!
到此为止,终于找到解决办法,生活总是这样,有时候还是自问自答。
首先我是reboot重启服务器,没用。
然后我在修改了syslog配置文件,在/ect/logroate.d/syslog, 重启systemctl restart rsyslog
依然没用。

/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
    missingok
    sharedscripts
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    /bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

后来干脆把/var/log/messages手动删掉重新运行rsyslog, 结果可预测,还是没用。
至此,依然不知道问题出在哪里。
好吧,真烦。
很想出去奔跑。

最后决定重装下rsyslog,于是
yum reinstall rsyslog
重启了rsyslog,结果还是没用。
这是为啥子为啥子,看来是配置文件有问题咯!
好吧,那来找一下配置文件/etc/rsyslog.conf,网站找了下其他人的配置,改成如下:

#$ModLoad imjournal # provides access to the systemd journal
#Enable by uncommenting
$ModLoad imklog # reads kernel messages (the same are read from journald)

#Comment out
#$OmitLocalLogging on

#Comment out
#$IMJournalStateFile imjournal.state

重启rsyslog

$ systemctl stop rsyslog.service
$ systemctl start rsyslog.service

$ tail -f /var/log/secure
终于可以啦~ 有记录啦。

于是为了验证确实是这个问题,我再/etc/rsyslog.conf改回原来的样子,重启rsyslog.
依然可以。

这我就奇怪了。
不过,问题解决了。
有人告诉我这是为啥吗?回复里评论。
问题我先关闭了,反正也没人看了,希望后面看到的知道原因的回复告诉我下,在这里先感谢啦!

这篇关于linux - 某工的centos7 启动了rsyslog之后,日志/var/log/messages等都不产生日志了,都是空的。求大神解决!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆