Linux OOM-Killer机制和clear机制
参考博客:https://www.yundaiwei.com/post/508.html
1.Linux的OOM-Killer机制
介绍:OOM Killer的全称为Out of Memory (OOM) killer,它的作用简单点说就是,当系统的内存用光的时候,系统内核会自动的Kill掉一个或者一些进程,以使系统能继续的恢复到正常的运行状态。
如果当你一个进程被杀死,而且没有报出error信息,则有可能是被Linux内部的机制杀死,主动把整个进程kill掉
可以查看下系统级别的日志 信息
[root@xkhadoop ~]# cat /var/log/messages |grep oom
查询下因为OOM-Killer机制所杀死的进程
2.Linux的/tmp目录自动清理
介绍:Linux会把/tmp目录下的文件以一定规则来自动清理掉,而用户根目录下面的tmp目录不会自动清理
查看文件清理的规则
[root@xkhadoop ~]# cat /usr/lib/tmpfiles.d/tmp.conf
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# See tmpfiles.d(5) for details
# Clear tmp directories separately, to make them easier to override
v /tmp 1777 root root 10d
v /var/tmp 1777 root root 30d
# Exclude namespace mountpoints created with PrivateTmp=yes
x /tmp/systemd-private-%b-*
X /tmp/systemd-private-%b-*/tmp
x /var/tmp/systemd-private-%b-*
X /var/tmp/systemd-private-%b-*/tmp
[root@xkhadoop ~]# cat /usr/lib/tmpfiles.d/tmp.conf
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# See tmpfiles.d(5) for details
# Clear tmp directories separately, to make them easier to override
v /tmp 1777 root root 10d
v /var/tmp 1777 root root 30d
# Exclude namespace mountpoints created with PrivateTmp=yes
x /tmp/systemd-private-%b-*
X /tmp/systemd-private-%b-*/tmp
x /var/tmp/systemd-private-%b-*
X /var/tmp/systemd-private-%b-*/tmp
上文中的
v /tmp 1777 root root 10d 代表的是每十天会把/tmp自动清理掉
v:代表的是按照一定规则清理的文件
x:代表的是不会清理的文件
如果希望/tmp/hadoop下面的文件不想被清理掉,则配置
[root@xkhadoop ~]# vim /usr/lib/tmpfiles.d/tmp.conf
x /tmp/hadoop
这也配置即可