您现在的位置是:网站首页> 编程资料编程资料
Centos如何增加swap分区文件?Centos增加swap分区文件的方法_RedHat/Centos_操作系统_
2023-03-23
815人已围观
简介 Centos如何增加swap分区文件?Centos增加swap分区文件的方法_RedHat/Centos_操作系统_
准备学习ORACLE,搭建环境的时候老是提示SWAP空间不足,特意记录下增加SWAP空间的方法!
Linux中增加swap分区文件的步骤方法:
1、检查当前的分区情况(使用free -m或cat /proc/swaps ):
[root@db2 root]# free -m
total used free shared buffers cached
Mem: 1006 84 922 0 11 38
-/+ buffers/cache: 35 971
Swap: 0 0 0
[root@db2 root]#
2、增加交换分区文件及大小:
检查没有swap,下面就需要增加:
判定新交换文件的大小,将大小乘以1024来判定块的大小。例如,大小为64MB的交换文件的块大小为65536,在 shell 提示下以根用户身份键入以下命令,其中的 count 等于想要的块大小。
[root@db2 root]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000
1024000+0 records in
1024000+0 records out
[root@db2 root]#
使用以下命令来设置交换文件:
[root@db2 root]# mkswap /home/swap
Setting up swapspace version 1, size = 1023996 KiB
[root@db2 root]#
3、启用交换分区文件:
要立即启用交换文件而不是在引导时自动启用,使用以下命令:
[root@db2 root]# swapon /home/swap
检查增加后的交换情况:
[root@db2 root]# free -m
total used free shared buffers cached
Mem: 1006 994 12 0 4 929
-/+ buffers/cache: 60 946
Swap: 999 0 999
[root@db2 root]#
要在引导时启用,编辑 /etc/fstab 文件来包含以下行(/home/swap swap swap defaults 0 0 ):
[root@db2 root]# vi /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext2 defaults 1 2 /home/swap swap swap defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
LABEL=/usr /usr ext3 defaults 1 2
/dev/sda5 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
/home/swap swap swap defaults 0 0
系统下次引导时,它就会启用新建的交换文件
再次检查添加后的情况:
[root@db2 oracledb]# free -m
total used free shared buffers cached
Mem: 1006 979 27 0 6 917
-/+ buffers/cache: 54 952
Swap: 999 0 999
[root@db2 oracledb]#
相关内容
- 如何解决Centos口令周期设置生效问题?_RedHat/Centos_操作系统_
- Centos下为程序如何设置超时?Centos下为程序设置超时的方法_RedHat/Centos_操作系统_
- Centos下如何为进程绑定CPU?Centos下为进程绑定CPU的方法_RedHat/Centos_操作系统_
- Centos下rpm包如何制作?Centos下rpm包制作的方法_RedHat/Centos_操作系统_
- Centos中如何临时禁用用户?Centos中临时禁用用户的方法_RedHat/Centos_操作系统_
- CentOS中文件夹基本操作命令的讲解_RedHat/Centos_操作系统_
- CentOS系统如何添加用户操作日志?CentOS系统添加用户操作日志的方法_RedHat/Centos_操作系统_
- Centos进程状态详解_RedHat/Centos_操作系统_
- CentOS EXT4文件系统的详解_RedHat/Centos_操作系统_
- CentOS系统备份脚本详解_RedHat/Centos_操作系统_
