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

简介:


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 ,如需转载请自行联系原作者


相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
1月前
|
Linux 应用服务中间件 nginx
【PUSDN】centos查看日志文件内容,包含某个关键字的前后5行日志内容,centos查看日志的几种方法
【PUSDN】centos查看日志文件内容,包含某个关键字的前后5行日志内容,centos查看日志的几种方法
46 0
|
4月前
|
缓存 关系型数据库 MySQL
MySQL Binlog--事务日志和BINLOG落盘参数对磁盘IO的影响
MySQL Binlog--事务日志和BINLOG落盘参数对磁盘IO的影响
44 0
|
11天前
|
网络协议 应用服务中间件 Linux
centos7 Nginx Log日志统计分析 常用命令
centos7 Nginx Log日志统计分析 常用命令
23 2
|
5月前
|
存储 关系型数据库 MySQL
CentOS7+Rsyslog+MySQL 搭建 Rsyslog 日志服务器
CentOS7+Rsyslog+MySQL 搭建 Rsyslog 日志服务器
127 0
|
3月前
|
Linux Shell
开源日志平台GrayLog5.1.10 CentOS7一键安装脚本
开源日志平台GrayLog5.1.10 CentOS7一键安装脚本
96 0
|
3月前
|
Linux
开源日志平台GrayLog5.1.7 CentOS7一键安装脚本
开源日志平台GrayLog5.1.7 CentOS7一键安装脚本
81 1
|
4月前
|
Linux
百度搜索:蓝易云【centos系统应用日志文件被删,空间无法释放怎么办】
通过以上方法,你应该能够解决应用日志文件被删除但空间无法释放的问题,并恢复磁盘空间。
31 1
|
18天前
|
Java
使用Java代码打印log日志
使用Java代码打印log日志
73 1
|
19天前
|
Linux Shell
Linux手动清理Linux脚本日志定时清理日志和log文件执行表达式
Linux手动清理Linux脚本日志定时清理日志和log文件执行表达式
72 1
|
23天前
|
SQL 关系型数据库 MySQL
MySQL数据库,可以使用二进制日志(binary log)进行时间点恢复
对于MySQL数据库,可以使用二进制日志(binary log)进行时间点恢复。二进制日志是MySQL中记录所有数据库更改操作的日志文件。要进行时间点恢复,您需要执行以下步骤: 1. 确保MySQL配置文件中启用了二进制日志功能。在配置文件(通常是my.cnf或my.ini)中找到以下行,并确保没有被注释掉: Copy code log_bin = /path/to/binary/log/file 2. 在需要进行恢复的时间点之前创建一个数据库备份。这将作为恢复的基准。 3. 找到您要恢复到的时间点的二进制日志文件和位置。可以通过执行以下命令来查看当前的二进制日志文件和位

热门文章

最新文章