AIX培训笔记——交换空间
交换空间,也即操作系统中的虚拟内存,本文简单介绍了一些交换空间管理的基本命令。
交换空间分配原则:
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
删除一个交换空间之前,该交换空间必须是非激活状态。