已开启
/etc/logrotate.d/rsyslog 默认配置打满根目录问题 #85
zhaoxiaohu创建于  4月10日
zhaoxiaohu
zhaoxiaohu
4月10日 创建

image.png

/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
    maxage 365 	 # 且保留时间最长365天
    rotate 30		# 最多保留 30 个轮转文件
    notifempty
    missingok
    size +4096k
    sharedscripts
    postrotate
        /usr/bin/systemctl reload rsyslog.service >/dev/null 2>&1 || true
    endscript
}

问题:互联网容器场景:/var/log/message 一般天级日志大小在 >= 2G 大小,30份就是 >=60G,严重挤占 /跟目录空间导致100%占用
--如果系统日志量巨大(比如你有入kubelet 、debug、内核、网络、审计日志等),文件可能在一天内快速变成几个 GB,轮转机制仍然只按“每天一次”触发,而不会中断生成或限制增长。

用户使用角度:
1)小白用户:增加了严重的隐患问题,出问题才会发现
2)专家OS运维:会把message 日志,单独配置,限制保留文件份数和轮转打下

上游默认设置:
只保留 4份日志
image.png

建议修改:
1)同步对齐上游配置
2)单独拆分 messages 日志配置

sed -i '\|/var/log/messages|d' /etc/logrotate.d/rsyslog

vim /etc/logrotate.d/messages 
/var/log/messages
{
    missingok
    size +500M
    sharedscripts
    postrotate
        /usr/bin/systemctl kill -s HUP rsyslog.service >/dev/null 2>&1 || true
    endscript
}
likedislike
openeuler-ci-botopeneuler-ci-bot成员
4月10日 添加了label:sig/Base-service
openeuler-ci-bot
openeuler-ci-bot成员
4月10日 评论:

Welcome To openEuler Community

Hey @Z1142143860Z , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.

Contact Guide

If you have any questions, please contact the SIG: Base-service ,
and any of the maintainers: @dillon_chen, @licihua, @overweight, @shenyangyang, @zhujianwei001 ,
and any of the committers: @yanan-rock .

likedislike
刘德华海淀分华刘德华海淀分华成员
6月21日 关联了pull request:reduce logrotate retention from 30 to 4 to prevent root partition exhaustion