2

当机器处于极重负载下时,某些服务应用程序可能会耗尽所有内存并且交换也被充分利用。Linux 会自行启动 kill 进程,通常 shell 已被杀死,当您发现该问题时屏幕会疯狂滚动。

这是机器内存不足时的日志(类似的错误重复使屏幕滚动)

[11988288.358984] Mem-info:
[11988288.358987] DMA per-cpu:
[11988288.358992] CPU    0: hi:    0, btch:   1 usd:   0
[11988288.358997] CPU    1: hi:    0, btch:   1 usd:   0
[11988288.359002] DMA32 per-cpu:
[11988288.359006] CPU    0: hi:  186, btch:  31 usd: 171
[11988288.359012] CPU    1: hi:  186, btch:  31 usd: 180
[11988288.359019] Active:490848 inactive:2177 dirty:0 writeback:0 unstable:0
[11988288.359021]  free:3441 slab:3328 mapped:20 pagetables:0 bounce:0
[11988288.359032] DMA free:8084kB min:44kB low:52kB high:64kB active:1908kB inactive:1732kB present:16160kB pages_scanned:9935 all_unreclaimable? yes
[11988288.359041] lowmem_reserve[]: 0 2012 2012 2012
[11988288.359052] DMA32 free:5680kB min:5716kB low:7144kB high:8572kB active:1961484kB inactive:6976kB present:2060400kB pages_scanned:972601 all_unreclaimable? no
[11988288.359063] lowmem_reserve[]: 0 0 0 0
[11988288.359071] DMA: 13*4kB 16*8kB 16*16kB 17*32kB 25*64kB 29*128kB 1*256kB 1*512kB 1*1024kB 0*2048kB 0*4096kB = 8084kB
[11988288.359093] DMA32: 108*4kB 0*8kB 0*16kB 2*32kB 1*64kB 0*128kB 0*256kB 0*512kB 1*1024kB 0*2048kB 1*4096kB = 5680kB
[11988288.359112] 66 total pagecache pages
[11988288.359117] Swap cache: add 603678, delete 603677, find 189475/220048
[11988288.359123] Free swap  = 0kB
[11988288.359126] Total swap = 1048568kB
[11988288.372922] 526336 pages of RAM
[11988288.372937] 11131 reserved pages
[11988288.372942] 451075 pages shared
[11988288.372946] 1 pages swap cached
[11988288.372952] Out of memory: kill process 14767 (exim4) score 4076 or a child
[11988288.372998] Killed process 14767 (exim4)

我的问题

  1. 当你想拯救这种内存耗尽的机器时,有什么可以做的吗?(除了重置机器)?
  2. 可以设置任何系统配置以使 Linux 内核更强大并在内存不足时保持活动状态?
4

1 回答 1

3

您可以通过调整每个进程的值来帮助 OOM 杀手选择它的目标:

echo some_value > /proc/pid/oom_score_adj

该值被添加到 oom 杀手计算的分数中,以选择它的下一个受害者。如果使用负值,它可以用于保护某些进程,或者用于相反的情况,即增加进程成为 OOM 杀手目标的可能性。

于 2013-04-03T11:11:06.463 回答