[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內存,應當不是問題。
對167M的swap使用應當如何解釋?
從我目前了解到LINUX 內存知識來講
1 LINUX 系統為了保證 未來 某個進程申請內存量的需求 必須保存多少空閑內存. 為此 會把某些進程不經常使用的頁面 放到 SWAP上
FREE -M
公式計算:
TOTAL –> USED+FREE (16050=15567+483) 第1行; 按內存分配上看
TOTAL –> USED+FREE (16050=10123+5926) 第2行; 按實際使用上看
第2行的值
USED:10123=15567⑵02⑸240
FREE:5926=483+202+5240
2 內存是不是緊張 看SWAP的頁面是不是會頻繁地調入內存中. 當前可使用VMSTAT 來查看. 歷史的可以用SAR來查看,具體參數
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). 虛擬內存的頁導入(從SWAP DISK導入RAM)
so: Amount of memory swapped to disk (kB/s). 虛擬內存的頁導出.
LogName=”/var/log/sa/sadate --date='yesterday' +%d
”
sar -q -r
內存和交換空間監控
sar -r
輸出項說明:
kbmemfree 可用的空閑內存數量,單位為 KB
kbmemused 已使用的內存數量(不包括內核使用的內存),單位為 KB
%memused 已使用內存的百分數
kbbuffers 內核緩沖區(buffer)使用的內存數量,單位為 KB
kbcached 內核高速緩存(cache)數據使用的內存數量,單位為 KB
kbcommit:保證當前系統所需要的內存,即為了確保不溢出而需要的內存(RAM+swap)
%commit:這個值是kbcommit與內存總量(包括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
系統交換活動信息監控
sar -W:
pswpin/s:每秒系統換入的交換頁面(swap page)數量
pswpout/s:每秒系統換出的交換頁面(swap page)數量
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 每秒鐘從磁盤讀入的系統頁面的 KB 總數
pgpgout/s 每秒鐘向磁盤寫出的系統頁面的 KB 總數
fault/s 系統每秒產生的頁面失效(major + minor)數量
majflt/s 系統每秒產生的頁面失效(major)數量