Linux中扩展swap空间

在管理 oracle 的过程中经常会出现swap空间不足的情况,这时就要考虑扩展swap空间,以下为在linux中扩展swap的几种方法,供各位参考:

一.增加一个swap分割区
1.在root用户下执行fdisk
[root@OCS_Test root]#fdisk /dev/hda
然后选择n,新增一个分区:/dev/hda3,分配其大小,比如512M
然后选择t,改变该分区的system id为82
退出fdisk
2.[root@OCS_Test root]#mkswap /dev/hda3 –指定该SWAP分区
3.[root@OCS_Test root]#swapon /dev/hda3 –启用该swap分区
4.如需在开机时启用该swap,则在/etc/fstab添加如下内容:
    /dev/hda3    swap           swap    defaults        0 0
6.确认swap已经被使用:
  用free或cat /proc/swaps可察看哪个swap在使用
7.关闭swap
  swapoff /dev/hda3

二.增加一个文件
1. 先决定SWAP文件的大小,然后指定区块大小:bs,再指定区块数量count,则SWAP文件的大小是:count*bs
2. 在root用户下执行如下命令:
   [root@OCS_Test root]#dd if=/dev/zero of=/swapfile bs=1024 count=65536
   则产生的文件大小为64M
3. [root@OCS_Test root]#mkswap /swapfile
4. [root@OCS_Test root]#swapon /swapfile
5. 如需在开机时启用该swap,则在/etc/fstab添加如下内容:
   /swapfile    swap           swap    defaults        0 0
6.确认swap已经被使用:
  用free或cat /proc/swaps可察看哪个swap在使用
7.关闭swap
  swapoff /swapfile

  

No Comments

Be the first to comment on this entry.

Leave a comment

Name(required)
Mail (will not be published)(required)
Website

Fields in bold are required. Email addresses are never published or distributed.

Some HTML code is allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
URLs must be fully qualified (eg: http://www.dbifan.com),and all tags must be properly closed.

Line breaks and paragraphs are automatically converted.

Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.

    搜索本站

    站点日历

    5月 2005
    « 4   6 »
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031  

    订阅本站

    文章分类

    最新日志

    热点文章

    日志存档

    常用标签