LINUX下安装ORACLE时SWAP不足的两种解决方法

来源:互联网 发布:喵萝捏脸数据 百度云 编辑:程序博客网 时间:2024/06/05 09:21

当前磁盘分区及SWAP分区情况如下:

[root@bys3 ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2078    16587112+  83  Linux
/dev/sda3            2079        2600     4192965   82  Linux swap / Solaris
[root@bys3 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          2013       1850        163          0        131       1274
-/+ buffers/cache:        444       1568
Swap:         4094          0       4094
增加SWAP交换分区有两种方法:关于tmpfs的使用详见:http://blog.csdn.net/haibusuanyun/article/details/17199617点击打开链接
1. 使用dd命令新建一个文件并挂载为SWAP

2. 增加一个新交换分区

增加的步骤都是:

1.free ---查看内存状态命令,可以显示memory,swap,buffer cache等的大小及使用状况;
2.dd ---读取,转换并输出数据命令;fdisk切分新分区
3.mkswap ---设置交换区
4.swapon ---启用交换区,相当于mount;swapoff ---关闭交换区,相当于umount

5.设置开机自动挂载/etc/fstab

#########################################################

1.使用DD命令创建一个文件

[root@bys3 ~]# dd if=/dev/zero of=/root/swap bs=1024 count=1024000   ---这里bs=是bytes,count blocks 个块,这里的就是1024bytes=1K,1024000K=1000M
1024000+0 records in
1024000+0 records out
1048576000 bytes (1.0 GB) copied, 43.5605 seconds, 24.1 MB/s
[root@bys3 ~]# mkswap /root/swap
Setting up swapspace version 1, size = 1048571 kB
[root@bys3 ~]# swapon /root/swap
[root@bys3 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          2013       1864        149          0         37       1389
-/+ buffers/cache:        436       1577
Swap:         5094          0       5094    --与最开始的相比,增加了近1000M。
设置开机自动挂载-
[root@bys3 ~]# vi /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda3         swap                    swap    defaults        0 0
/root/swap              swap                    swap    defaults        0 0
[root@bys3 ~]# mount -a    --无报错,修改/etc/fstab成功
重启后查看:--SWAP空间包含了新增加的空间。
[oracle@bys3 ~]$ free -m
             total       used       free     shared    buffers     cached
Mem:          2013        214       1799          0         15        150
-/+ buffers/cache:         48       1964
Swap:         5094          0       5094
###############################################################################

2.用FDISK将未使用的分区格式化并挂载为SWAP分区

[root@bys3 ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2078    16587112+  83  Linux
/dev/sda3            2079        2600     4192965   82  Linux swap / Solaris
[root@bys3 ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2078    16587112+  83  Linux
/dev/sda3            2079        2600     4192965   82  Linux swap / Solaris
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Selected partition 4
First cylinder (2601-2610, default 2601):
Using default value 2601
Last cylinder or +size or +sizeM or +sizeK (2601-2610, default 2610): +50m   ---新增加个50M的扩展分区。
Command (m for help): p
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2078    16587112+  83  Linux
/dev/sda3            2079        2600     4192965   82  Linux swap / Solaris
/dev/sda4            2601        2607       56227+   5  Extended
Command (m for help): n
First cylinder (2601-2607, default 2601):
Using default value 2601
Last cylinder or +size or +sizeM or +sizeK (2601-2607, default 2607):
Using default value 2607

Command (m for help): p
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2078    16587112+  83  Linux
/dev/sda3            2079        2600     4192965   82  Linux swap / Solaris
/dev/sda4            2601        2607       56227+   5  Extended
/dev/sda5            2601        2607       56196   83  Linux

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@bys3 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          2013        218       1795          0         15        153
-/+ buffers/cache:         49       1964
Swap:         5094          0       5094
[root@bys3 ~]# swapoff /root/swap   关闭一个SWAP空间
[root@bys3 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          2013        218       1795          0         15        153
-/+ buffers/cache:         49       1964
Swap:         4094          0       4094
[root@bys3 ~]# mkswap /dev/sda5
/dev/sda5: No such file or directory
[root@bys3 ~]#  partprobe    ---同步下分区表的意思
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
Segmentation fault
[root@bys3 ~]# mkswap /dev/sda5
Setting up swapspace version 1, size = 57540 kB
[root@bys3 ~]# swapon /dev/sda5
[root@bys3 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          2013        218       1795          0         15        153
-/+ buffers/cache:         49       1964
Swap:         4149          0       4149

###############

开机时自动挂载的配置

[root@bys3 ~]# vi /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda3         swap                    swap    defaults        0 0
/dev/sda5               swap                    swap    defaults        0 0
"/etc/fstab" 8L, 568C written
[root@bys3 ~]# mount -a
#########################################
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 苹果笔记本电脑屏幕坏了怎么办 平板开关键坏了怎么办 平板电脑电池坏了怎么办 平板电脑充电口坏了怎么办 平板电脑系统坏了怎么办 平板电脑充电器坏了怎么办 平板电脑触摸屏坏了怎么办 平板电脑关不了机怎么办 平板电脑触摸屏没反应怎么办 平板电脑声音太小怎么办 平板电脑频碎了怎么办? 淘宝直播展示频道排后怎么办 网店头像改不了怎么办 被骗了7500追不回来怎么办 steam中国版原来的游戏怎么办 老公买驾照被骗妻子应该怎么办 被淘密码骗了怎么办 逛街手机没电了怎么办 电脑登入密码忘了怎么办 晚上睡不好觉经常做梦怎么办 开淘宝店开始零销量怎么办 淘宝店开直通车后销量怎么办 淘宝直播一开始直播没人该怎么办 淘宝店铺访客数据下滑怎么办 2个ctrl键都失灵怎么办 淘宝上搜索不到很久以前订单怎么办 关键词找不到了是不是被降权怎么办 购买小程序关键词想退款怎么办? 浏览器审查元素不拆分关键词怎么办 拼多多商品想重新编辑怎么办 新开店铺没有销量怎么办 新开的店铺没有销量怎么办 淘宝的商品权重下降是怎么办 360n5手机耗电快怎么办 怪兽充电宝丢了怎么办 有已处置的评价怎么办 淘宝降权了怎么办2018 使用虚假广告词被工商查到怎么办 为什么手机淘宝店关注不了怎么办 淘宝买东西付钱后卖家不发货怎么办 微信销售群没人买东西怎么办