命名被杀害

每隔一段时间,我的服务器将杀死命名。 这被logging:

Apr 16 17:00:08 li127-203 kernel: Out of memory: Kill process 15723 (named) score 38 or sacrifice child Apr 16 17:00:08 li127-203 kernel: Killed process 15723 (named) total-vm:92096kB, anon-rss:5492kB, filers:0kB 

它看起来像我内存不足,但为什么它总是被命名,被杀害,而不是一些其他的过程? 有什么办法可以防止这个?

我在Linode VPS上运行CentOS 6.2。

OOM杀手是一个善变的女主人。 因为它被OOM杀手的逻辑认为是最好的目标,所以BIND变得有针对性。 在链接页面的代码注释中已经有很好的解释,但是它粘贴的是:

 /* * oom_badness - calculate a numeric value for how bad this task has been * @p: task struct of which task we should calculate * @p: current uptime in seconds * * The formula used is relatively simple and documented inline in the * function. The main rationale is that we want to select a good task * to kill when we run out of memory. * * Good in this context means that: * 1) we lose the minimum amount of work done * 2) we recover a large amount of memory * 3) we don't kill anything innocent of eating tons of memory * 4) we want to kill the minimum amount of processes (one) * 5) we try to kill the process the user expects us to kill, this * algorithm has been meticulously tuned to meet the principle * of least surprise ... (be careful when you change it) */ 

但是,这只能告诉你为什么它的目标是BIND。 解决scheme可能不是“把它定位于别的东西”,因为吸收大量内存的其他东西可能也很重要。 解决scheme更可能是“不要触发OOM杀手”。

你能增加这个系统可用的内存或交换空间,或者减less其他进程使用的内存吗? 这个系统上还运行着什么? 是BINDconfiguration为权威,或recursion(这将允许您限制其caching内存使用情况)?

stream程树中实际上有一个文件,允许您禁用或更改位于/proc/PROCESS_ID/oom_adj ( documentation )的OOM行为。 要禁用,你可以这样做:

 echo 17 > /proc/PROCESS_ID/oom_adj 

所以如果你想总是把这个应用到named ,你可以使用:

 echo 17 > /proc/$(pidof named)/oom_adj 

请记住, $(pidof named)可能会返回比运行pid多,但我认为 named只有一个进程正在运行。

希望这可以帮助!