在寻找这个并且只找到那些没有正确解释“缓存”数字的人的帖子后,我决定问这个问题.
我手头有一些服务器,这很奇怪.也就是说,他们的RAM使用率非常高,没有明显的原因.好像一个看不见的进程有很多“使用过的”RAM(我的意思是“使用”).
这是一些信息:
>所有服务器都运行SLES 11
>内核是3.0.76
>所有服务器在VMWare ESX基础架构下作为guest虚拟机运行
>我没有设置服务器,在操作系统选择方面没有发言权,也没有访问虚拟化基础架构
>所有服务器都设置相似,它们运行相同的软件集(它是一个集群,是的,我知道,虚拟集群,yada yada,如上所述:我曾经并且没有发言权)
root@good-server:# free -m
total used free shared buffers cached
Mem: 15953 14780 1173 0 737 8982
-/+ buffers/cache: 5059 10894
Swap: 31731 0 31731
root@good-server:# python ps_mem.py
[... all processes neatly listed ...]
---------------------------------
4.7 GiB
=================================
root@bad-server:# free -m
total used free shared buffers cached
Mem: 15953 15830 123 0 124 1335
-/+ buffers/cache: 14370 1583
Swap: 31731 15 31716
root@bad-server:# python ps_mem.py
[... all processes neatly listed ...]
---------------------------------
4.0 GiB
=================================
好服务器的/ proc / meminfo的内容
MemTotal: 16336860 kB
MemFree: 112356 kB
Buffers: 138384 kB
Cached: 1145208 kB
SwapCached: 1244 kB
Active: 4344336 kB
Inactive: 1028744 kB
Active(anon): 3706796 kB
Inactive(anon): 382724 kB
Active(file): 637540 kB
Inactive(file): 646020 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 32493560 kB
SwapFree: 32477728 kB
Dirty: 1248 kB
Writeback: 0 kB
AnonPages: 4087776 kB
Mapped: 60132 kB
Shmem: 156 kB
Slab: 274968 kB
SReclaimable: 225864 kB
SUnreclaim: 49104 kB
KernelStack: 4352 kB
PageTables: 16400 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 40661988 kB
Committed_AS: 6576912 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 311400 kB
VmallocChunk: 34359418748 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 73728 kB
DirectMap2M: 16703488 kB
坏服务器的/ proc / meminfo的内容
MemTotal: 16336860 kB
MemFree: 1182320 kB
Buffers: 756244 kB
Cached: 8695688 kB
SwapCached: 0 kB
Active: 13499680 kB
Inactive: 843208 kB
Active(anon): 4853460 kB
Inactive(anon): 37372 kB
Active(file): 8646220 kB
Inactive(file): 805836 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 32493560 kB
SwapFree: 32493560 kB
Dirty: 1268 kB
Writeback: 0 kB
AnonPages: 4890180 kB
Mapped: 84672 kB
Shmem: 252 kB
Slab: 586084 kB
SReclaimable: 503716 kB
SUnreclaim: 82368 kB
KernelStack: 5176 kB
PageTables: 19684 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 40661988 kB
Committed_AS: 6794180 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 311400 kB
VmallocChunk: 34359419468 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 112640 kB
DirectMap2M: 16664576 kB
TL; DR – 如果你将它们并排比较,这里是主要区别(BADserver – GOODserver):
MemFree -1070 MB
Cached -7550 MB
Active -9155 MB
Active(anon) -1147 MB
Active(file) -8009 MB
AnonPages - 802 MB
其他差异相当小,并且在人们可能期望的范围内(但你可以亲眼看到)
正如您所看到的,在良好的服务器上,所有进程的所有RES和SHR内存的总和几乎与free -m的“used – / buffers / cache”值的输出一致 – 这正是您所期望的,对吧?
现在看一下坏的服务器:free -m的“used – / buffers / cache”值的输出大约是你预期的3倍,总结ps可以告诉你的一切.
这也符合/ proc / meminfo告诉我的内容.
到目前为止,我不知道这是怎么回事.这可能会发生什么?