/proc">

ubuntu20在关机的时候一直刷"echo 0 > /proc

2021-02-07  本文已影响0人  飞跑的蛤蟆

昨天电脑关机的时候,屏幕一直在刷东西,然后最后还报错了,当时拍了个照,然后今天查了查问题所在。

问题原因:

By default Linux uses up to 40% of the available memory for file system caching.
After this mark has been reached the file system flushes all outstanding data to disk causing all following IOs going synchronous.
For flushing out this data to disk this there is a time limit of 120 seconds by default.
In the case here the IO subsystem is not fast enough to flush the data withing 120 seconds.
This especially happens on systems with a lof of memory.

The problem is solved in later kernels and there is not “fix” from Oracle.
I fixed this by lowering the mark for flushing the cache from 40% to 10% by setting “vm.dirty_ratio=10″ in /etc/sysctl.conf.
This setting does not influence overall database performance since you hopefully use Direct IO and bypass the file system cache completely.

默认情况下, Linux会最多使用40%的可用内存作为文件系统缓存。当超过这个阈值后,文件系统会把将缓存中的内存全部写入磁盘, 导致后续的IO请求都是同步的。

将缓存写入磁盘时,有一个默认120秒的超时时间。 出现上面的问题的原因是IO子系统的处理速度不够快,不能在120秒将缓存中的数据全部写入磁盘。IO系统响应缓慢,导致越来越多的请求堆积,最终系统内存全部被占用,导致系统失去响应。

临时更改:

sysctl -w vm.dirty_ratio=10
sysctl -w vm.dirty_background_ratio=5
sysctl -p

永久更改,修改/etc/sysctl.conf文件,添加以下内容,然后进行重启

vm.dirty_ratio = 10
vm.dirty_background_ratio = 5

参数解释:

参考资料
linux主机hang住echo 0 > /proc/sys/kernel/hung_task_timeout_secs disables this message
Linux系统出现hung_task_timeout_secs和blocked for more than 120 seconds的解决方法

上一篇下一篇

猜你喜欢

热点阅读