交換空間,也即作業系統中的虛擬記憶體,本文簡單介紹了一些交換空間管理的基本命令。
交換空間分配原則:
Only one paging space per disk;
Use disks with the least activity;
Paging spaces roughly the same size;
Do not extend paging space to multiple physical volumes;
Use multiple disk controllers;
查看交換空間使用方式:
#lsps -a
Page Space
Physical Volume
Volume Group
Size %Used Active
Auto
Type
paging00
hdisk4
rootvg
8192MB
31
yes
yes
lv
hd6
hdisk3
rootvg
8192MB
31
yes
yes
lv
查看實體記憶體數:
#lsattr -El sys0 -a realmem
realmem 33554432 Amount of usable physical memory in Kbytes False
或者:
#lsattr -El mem0
goodsize 32768 Amount of usable physical memory in Mbytes False
size
32768 Total amount of physical memory in Mbytes
False
查看系統啟動時啟用的交換空間:
#cat /etc/swapspaces
* /etc/swapspaces
*
* This file lists all the paging spaces that are automatically put into
* service on each system restart (the 'swapon -a' command executed from
* /etc/rc swaps on every device listed here).
*
* WARNING: Only paging space devices should be listed here.
*
* This file is modified by the chps, mkps and rmps commands and referenced
* by the lsps and swapon commands.
hd6:
dev = /dev/hd6
paging00:
dev = /dev/paging00
對以下資訊需要特別注意,一旦發現,應立即通知系統管理員進行處理:
"INIT: Paging space is low"
"ksh: cannot fork no swap space"
"Not enough memory"
"Fork function failed"
"fork () system call failed"
"Unable to fork, too may processes"
"Fork failure - not enough memory available"
"Fork function not allowed. Not enough memory available."
"Cannot fork: Not enough space"
如何建立交換空間,可以用
smit
或
mkps
命令來完成,
mkps
命令格式如下:
mkps [-a] [-n] [-t type] -s NumLPs Vgname Pvname
Vgname
交換空間所在的卷組(
volume group
)名
Pvname
交換空間所在的物理卷(
physical volume
)名
-s NumLPs
交換空間所佔用的邏輯分區(
logical partition
)數
-a
在下次系統啟動時啟用該交護岸空間
(
將該交換空間加入到
/etc/swapspaces
檔案中
)
-n
立即啟用該交換空間
-t type
指定交換空間類型(
lv
或者
nfs
)
以下命令在名字為
rootvg
的卷組
(
volume group
)
中建立一個大小為
4
個邏輯分區
(
logical partition
)
大小的交換空間,在建立完成後立即啟用該交換空間,並且在下次系統啟動時啟用該交換空間:
# mkps -s 4 -n -a rootvg
改命令執行後,系統中會增加一個名字為
/dev/pagingnn
的一個交換空間,其中
nn
是一個順序號,例如
00
、
01
等。
如果交換空間在建立時沒有啟用,可以使用如下命令啟用:
#swapon
/dev/paging00
Swap –a
命令可以啟用
/etc/swapspaces
中定義的所有交換空間,該命令一般在系統啟動時自動執行。
如下命令可以使一個已經啟用的交換空間變為非啟用:
#swapoff
/dev/paging00
該命令可能由於
I/O
錯誤或者沒有足夠的交換空間容納
paging00
上的交換頁面而失敗。
可以使用如下命令動態修改一個交換空間的大小:
#chps –d 1 paging00
#
從交換空間
paging00
中刪除
1
個
LP
;
#chps –s 1 paging00
#
給交換空間
paging00
中增加
1
個
LP
;
注意,該命令不能使主交換空間(通常是
hd6
)減小到
32M以下。
如下命令可用來刪除一個交換空間:
#rmps paging00
刪除一個交換空間之前,該交換空間必須是非啟用狀態。