How to prevent a process to be a target of oom-killer?

219 篇文章 2 订阅

 

How to prevent a process to be a target of oom-killer?

 SOLUTION 已验证 - 已更新 2015年七月21日14:38 - 

English 

环境

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7

问题

  • Important applications killed by oom-killer when there's memory starvation
  • How could we prevent this process killed by oom-killer

决议

  • This can be achived by using '-17' in oom_adj (RHEL5) or oom_score_adj (RHEL6/7).
  • Here's the way to set it.

  • RHEL5

Raw

$ echo '-17' > /proc/<pid>/oom_adj
  • RHEL6/7

Raw

$ echo '-1000' > /proc/<pid>/oom_score_adj
  • From /usr/share/doc/kernel-doc-/Documentation/filesystems/proc.txt

Raw

For backwards compatibility with previous kernels, /proc/<pid>/oom_adj may also
be used to tune the badness score.  Its acceptable values range from -16
(OOM_ADJUST_MIN) to +15 (OOM_ADJUST_MAX) and a special value of -17
(OOM_DISABLE) to disable oom killing entirely for that task.  Its value is
scaled linearly with /proc/<pid>/oom_score_adj.

The value of /proc/<pid>/oom_score_adj is added to the badness score before it
is used to determine which task to kill.  Acceptable values range from -1000
(OOM_SCORE_ADJ_MIN) to +1000 (OOM_SCORE_ADJ_MAX).  This allows userspace to
polarize the preference for oom killing either by always preferring a certain
task or completely disabling it.  The lowest possible value, -1000, is
equivalent to disabling oom killing entirely for that task since it will always
report a badness score of 0.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值