Linux OOM-Killer机制和/tmp目录自动清理

                               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

这也配置即可

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值