[root@ZHXDB2 ~]# free -m
total used free shared buffers cached
Mem: 16050 15567 483 0 202 5240
-/+ buffers/cache: 10123 5926
Swap: 18047 167 17880
還有5926M內(nèi)存,應(yīng)當不是問題。
對167M的swap使用應(yīng)當如何解釋?
從我目前了解到LINUX 內(nèi)存知識來講
1 LINUX 系統(tǒng)為了保證 未來 某個進程申請內(nèi)存量的需求 必須保存多少空閑內(nèi)存. 為此 會把某些進程不經(jīng)常使用的頁面 放到 SWAP上
FREE -M
公式計算:
TOTAL –> USED+FREE (16050=15567+483) 第1行; 按內(nèi)存分配上看
TOTAL –> USED+FREE (16050=10123+5926) 第2行; 按實際使用上看
第2行的值
USED:10123=15567⑵02⑸240
FREE:5926=483+202+5240
2 內(nèi)存是不是緊張 看SWAP的頁面是不是會頻繁地調(diào)入內(nèi)存中. 當前可使用VMSTAT 來查看. 歷史的可以用SAR來查看,具體參數(shù)
2.1 vmstat
vmstat 1 100
procs ———–memory———- —swap– —–io—- –system– —–cpu—–
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 778616 22848 102556 0 0 0 0 12 6 0 0 100 0 0
0 0 0 778616 22848 102556 0 0 0 0 10 8 0 0 100 0 0
0 0 0 778616 22848 102556 0 0 0 0 15 12 0 1 99 0 0
0 0 0 778616 22848 102556 0 0 0 0 19 21 0 0 100 0 0
Swap
si: Amount of memory swapped in from disk (kB/s). 虛擬內(nèi)存的頁導(dǎo)入(從SWAP DISK導(dǎo)入RAM)
so: Amount of memory swapped to disk (kB/s). 虛擬內(nèi)存的頁導(dǎo)出.
LogName=”/var/log/sa/sadate --date='yesterday' +%d
”
sar -q -r
內(nèi)存和交換空間監(jiān)控
sar -r
輸出項說明:
kbmemfree 可用的空閑內(nèi)存數(shù)量,單位為 KB
kbmemused 已使用的內(nèi)存數(shù)量(不包括內(nèi)核使用的內(nèi)存),單位為 KB
%memused 已使用內(nèi)存的百分數(shù)
kbbuffers 內(nèi)核緩沖區(qū)(buffer)使用的內(nèi)存數(shù)量,單位為 KB
kbcached 內(nèi)核高速緩存(cache)數(shù)據(jù)使用的內(nèi)存數(shù)量,單位為 KB
kbcommit:保證當前系統(tǒng)所需要的內(nèi)存,即為了確保不溢出而需要的內(nèi)存(RAM+swap)
%commit:這個值是kbcommit與內(nèi)存總量(包括swap)的1個百分比.
Linux 2.6.32⑸04.23.4.el6.x86_64 (oraclemain) 06/27/16 x86_64 (8 CPU)
00:00:01 kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit
00:10:01 1007260 31873136 96.94 254128 27907488 13547280 25.16
系統(tǒng)交換活動信息監(jiān)控
sar -W:
pswpin/s:每秒系統(tǒng)換入的交換頁面(swap page)數(shù)量
pswpout/s:每秒系統(tǒng)換出的交換頁面(swap page)數(shù)量
Linux 2.6.32⑸04.23.4.el6.x86_64 (oraclemain) 06/27/16 x86_64 (8 CPU)
[root@cnetos5 ~]# sar -B
Linux 2.6.18⑸3.el5 (cnetos5) 01/22/2008
12:00:01 AM pgpgin/s pgpgout/s fault/s majflt/s
12:10:01 AM 0.00 4.17 9.74 0.00
12:20:01 AM 0.00 2.71 2.24 0.00
12:30:01 AM 0.00 2.69 2.25 0.00
Average: 0.00 3.17 4.07 0.00
輸出項說明:
pgpgin/s 每秒鐘從磁盤讀入的系統(tǒng)頁面的 KB 總數(shù)
pgpgout/s 每秒鐘向磁盤寫出的系統(tǒng)頁面的 KB 總數(shù)
fault/s 系統(tǒng)每秒產(chǎn)生的頁面失效(major + minor)數(shù)量
majflt/s 系統(tǒng)每秒產(chǎn)生的頁面失效(major)數(shù)量