系统日志架构
在Linux 7 中系统消息由systemd-journald和rsyslog负责。
系统日志消息由systemd-jourmald转发到rsyslog,而rsyslog经过处理,将日志文件写在/var/log下面。
linux日志文件概述
| 日志文件 | 用途 |
|---|---|
| var/log/messages | 大多数系统日志记录 |
| var/log/secure | 安全和身份认证相关的消息和错误的日志文件 |
| /var/log/maillog | 发送到系统或从系统发出的电子邮件的活动 |
| /var/log/cron | 与定期执行的相关文件 |
| /var/log/boot.log | 自检过程 |
查看日志文件
rsyslog的配置文件在/etc/rsyslog.conf中
日志文件由rsyslog负责维护,包括许多的应用的日志文件,有类似Apache Web日志也存在/var/log的对应的文件中。
rsyslog.conf中示例规则部分
#### 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
#*.* @xx.xx.xx.xx
//表示将本机日志存储到指定的服务器上
# 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. 在要备份日志的机器上
[student@localhos

本文介绍了Linux系统日志管理,包括日志架构、rsyslog配置、远程日志存储、日志轮转、监控日志文件、systemd日志查看与保存,以及如何使用chronyd保持准确时间。
最低0.47元/天 解锁文章
1080

被折叠的 条评论
为什么被折叠?



