centos 7如何应对日志风暴和保证日志及时落盘

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介:


Centos7在出现系统异常的情况下,比如iscsi软件栈出错且有持续IO的情况下,很可能会出现持续大量的日志,就像短时强风暴一样,甚至导致日志丢失。



在调试阶段,这些日志都是需要的,为此需要解决此时出现的log drop。方法是修改/etc/rsyslog.conf,加入下面的几行:


$SystemLogRateLimitInterval 0

$SystemLogRateLimitBurst 0

$IMUXSockRateLimitInterval 0

$IMJournalRatelimitInterval 0

"/etc/rsyslog.conf" 106L, 3683C


此外,我们还要求日志能及时落盘,为此也需要修改journald配置文件/etc/systemd/journald.conf,更新下面几行:


Storage=persistent

RateLimitInterval=0

RateLimitBurst=0

SyncIntervalSec=2


除此之外,还需要disable 日志盘的写缓存:


[root@192.168.1.84:~]$ hdparm -W 0 /dev/sda


/dev/sda:

setting drive write-caching to 0 (off)

write-caching =  0 (off)


最后重启服务:

systemctl daemon-reload

[root@localhost etc]# systemctl restart systemd-journald.service

[root@localhost etc]# systemctl restart rsyslog.service


或者重启机器就可生效。在本人的机器上,重启多次之前kernel出错及不少日志丢失的问题,根据上面的改动都被解决了。


参考:

1. man journald.conf


RateLimitInterval=, RateLimitBurst=

Configures the rate limiting that is applied to all messages generated on the system. If, in the

time interval defined by RateLimitInterval=, more messages than specified in RateLimitBurst= are

logged by a service, all further messages within the interval are dropped until the interval is

over. A message about the number of dropped messages is generated. This rate limiting is applied

per-service, so that two services which log do not interfere with each other's limits. Defaults to

1000 messages in 30s. The time specification for RateLimitInterval= may be specified in the

following units: "s", "min", "h", "ms", "us". To turn off any kind of rate limiting, set either

value to 0.



SyncIntervalSec=

The timeout before synchronizing journal files to disk. After syncing, journal files are placed in

the OFFLINE state. Note that syncing is unconditionally done immediately after a log message of

priority CRIT, ALERT or EMERG has been logged. This setting hence applies only to messages of the

levels ERR, WARNING, NOTICE, INFO, DEBUG. The default timeout is 5 minutes.


2. man journalctl

3.http://www.jinbuguo.com/systemd/journald.conf.html















本文转自存储之厨51CTO博客,原文链接:http://blog.51cto.com/xiamachao/1935104 ,如需转载请自行联系原作者


相关实践学习
【涂鸦即艺术】基于云应用开发平台CAP部署AI实时生图绘板
【涂鸦即艺术】基于云应用开发平台CAP部署AI实时生图绘板
相关文章
|
Linux 应用服务中间件 nginx
【PUSDN】centos查看日志文件内容,包含某个关键字的前后5行日志内容,centos查看日志的几种方法
【PUSDN】centos查看日志文件内容,包含某个关键字的前后5行日志内容,centos查看日志的几种方法
480 0
|
存储 Linux Docker
centos系统清理docker日志文件
通过以上方法,可以有效清理和管理CentOS系统中的Docker日志文件,防止日志文件占用过多磁盘空间。选择合适的方法取决于具体的应用场景和需求,可以结合手动清理、logrotate和调整日志驱动等多种方式,确保系统的高效运行。
917 2
|
缓存 Linux 编译器
【C++】CentOS环境搭建-安装log4cplus日志组件包及报错解决方案
通过上述步骤,您应该能够在CentOS环境中成功安装并使用log4cplus日志组件。面对任何安装或使用过程中出现的问题,仔细检查错误信息,对照提供的解决方案进行调整,通常都能找到合适的解决之道。log4cplus的强大功能将为您的项目提供灵活、高效的日志管理方案,助力软件开发与维护。
451 0
|
Linux
linux centos7查看linux的登录日志
linux centos7查看linux的登录日志
644 2
linux centos7查看linux的登录日志
|
网络协议 应用服务中间件 Linux
centos7 Nginx Log日志统计分析 常用命令
centos7 Nginx Log日志统计分析 常用命令
530 2
|
Linux
开源日志平台GrayLog5.1.7 CentOS7一键安装脚本
开源日志平台GrayLog5.1.7 CentOS7一键安装脚本
332 1
|
Linux Shell
开源日志平台GrayLog5.1.10 CentOS7一键安装脚本
开源日志平台GrayLog5.1.10 CentOS7一键安装脚本
377 0
|
Linux
百度搜索:蓝易云【centos系统应用日志文件被删,空间无法释放怎么办】
通过以上方法,你应该能够解决应用日志文件被删除但空间无法释放的问题,并恢复磁盘空间。
230 1
|
应用服务中间件 Linux Java

热门文章

最新文章