Linux

伺服器記憶體不足

  • May 17, 2012

在此處輸入圖像描述伺服器記憶體不足並開始終止程序,頂部使用應用程序消耗的總 PSS 記憶體(從常駐記憶體中使用的實際記憶體)小於系統上的總記憶體,我想找出這個額外的記憶體使用發生在哪裡?任何想法,下面是 meminfo,smem,free -m 的輸出,

任何建議將不勝感激???

cat /proc/meminfo

MemTotal:        5976008 kB
MemFree:          138768 kB
Buffers:            2292 kB
Cached:            57444 kB
SwapCached:        85980 kB
Active:           324332 kB
Inactive:         121836 kB
Active(anon):     309264 kB
Inactive(anon):    77992 kB
Active(file):      15068 kB
Inactive(file):    43844 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       8159224 kB
SwapFree:        6836184 kB
Dirty:               572 kB
Writeback:             0 kB
AnonPages:        372160 kB
Mapped:            13976 kB
Shmem:               472 kB
Slab:             328216 kB
SReclaimable:      92544 kB
SUnreclaim:       235672 kB
KernelStack:        4824 kB
PageTables:        14732 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8159224 kB
Committed_AS:    4940480 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      102424 kB
VmallocChunk:   34359584392 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:        6384 kB
DirectMap2M:     2080768 kB
DirectMap1G:     4194304 kB

SMEM usage:

30971 root     python /usr/local/scripts/s     2432      660      860     1204
23296 root     /usr/bin/spamd -d -c -m5 -H    58296     1460     1564     1868
2763 ufc      csrv -c /home/ufc/ufclient/   116000    12768    12792    13084
55819 root     /usr/bin/python /bin/smem          0    22356    22988    24364
2101 root     clamd                         189228    41224    41280    41700
32914 root     /opt/safesquid/safesquid/sa   831120     5808   138619   271844


[root@server sysadmin]# free -m
            total       used       free     shared    buffers     cached
Mem:          5835       5695        140          0          1         19
-/+ buffers/cache:       5674        161
Swap:         7967       1315       6652

更新:

伺服器現在恢復正常,但記憶體使用呈指數級增長,直到 7 小時後應用程序被殺死

Out of memory: Kill process 14585 (safesquid) score 81 or sacrifice child
Killed process 16141, UID 500, (python) total-vm:79284kB, anon-rss:2656kB, file-rss:680kB



top - 21:58:16 up 16 days, 11:10,  1 user,  load average: 0.46, 0.74,
   0.78 Tasks: 243 total,   1 running, 242 sleeping,   0 stopped,   0 zombie Cpu(s):  5.7%us,  5.8%sy,  0.0%ni, 88.3%id,  0.1%wa,  0.0%hi, 
   0.1%si,  0.0%st Mem:   5976008k total,  5830648k used,   145360k free,    35724k buffers Swap:  8159224k total,   445384k used,  7713840k free,  3684540k cached


PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND  
4960 ssquid    20   0 1000m 534m 3068 S 20.6  9.2  90:19.40 safesquid  
2101 clamav    20   0 4153m  85m 1672 S  2.0  1.5 536:42.26 clamd 
23333 root      20   0  244m  50m 1940 S  0.0  0.9   2:10.84 spamd  
2763 ufc       20   0 1628m  32m  25m S  1.0  0.5 399:12.74 csrv 
61303 root      20   0 97876 4380 3304 S  0.0  0.1   0:00.28 sshd 
23296 root 20   0  227m 3424  928 S  0.0  0.1   0:07.87 spamd

盒子正在執行規則空間、蛤蜊和safesquid代理。

在記憶體圖中,最大的下降是當應用程序被殺死時,我重新啟動了 safesquid 服務……

@David Schwartz:我很確定核心 OOM 殺手會殺死該程序。是的,我們需要知道哪個程序被殺死了。

我很確定被殺死的程序在某種程度上行為不端(或崩潰),結果它用盡了大部分可用記憶體,此時核心的 OOM 殺手決定將其關閉。例如,這種行為在大約十年前非常猖獗(以我為例),當時 Mozilla/firefox 比現在更容易洩漏記憶體。它只會越來越多地使用,突然間它就消失了……你明白了。

引用自:https://serverfault.com/questions/389758