今天线上有一台服务器的DB宕机了。其实那台机器内存不少,64G,但是跑了三个实例。DB crash之后,根据Oracle的建议,增加Swap。
Linux上的方式是dd出一个文件,然后mkswap,swapon。在Solaris上相对简单,不用dd。
1)建立swap文件
mkfile 48G /var/swapfile
2)加入到系统swap里
swap -a /var/swapfile
3)查看swap
swap -l
root@localhost:~ # swap -l
swapfile dev swaplo blocks free
/dev/md/dsk/d20 85,20 16 16586864 16586864
/var/swapfile - 16 71303152 71303152
swap -s
root@localhost:~ # swap -s
total: 11537920k bytes allocated + 7256976k reserved = 18794896k used, 74469472k available
4)加到vfstab,重启之后不会丢失
vi /etc/vfstab
/var/swapfile - - swap - no -
Done!
------------------------------------------------------------------
solaris下增加swap空间失败: is not valid for swapping
# ls
bin home net proc u01
dev kernel opt sbin u02
etc lib oradiag_root system usr
export mnt platform tmp var
# mkfile 10m /swapfile
# ls -al swapfile
-rw------- 1 root root 10485760 Oct 14 11:33 swapfile
# swap -a /swapfile
"/swapfile" is not valid for swapping.
It must be a block device or a regular file with the
"save user text on execution" bit set.
哪位高手指点一下!
------解决方案--------------------------------------------------------
它说你那个块设备或者文件必须要设置sticky bit才能作为swap文件系统。
For regular files on some older systems, the
bit saves the program’s text image on the swap device so it will load more quickly
when run; this is called the sticky bit.
所以你可以这么做。
# chmod 1777 /swapfile