🔍 登录 注册

centos创建交换分区

大 大苹果 2023-12-18 mysql 👁 14690 ⏱ 2min

创建分区文件

// 在根目录创建分区文件swapfile 大小2048000k
dd if=/dev/zero of=/swapfile bs=1k count=2048000

生成swap文件系统

mkswap /swapfile

激活swap文件

swapon /swapfile

这样激活交换分区就可以使用了,但是重启系统后不会自动挂载交换分区,如果要自动挂载就需要修改fstab文件

vim /etc/fstab
# 增加如下内容
/swapfile swap swap defaults 0 0

这样每次重启系统都会自动挂载swap文件了

如果不想使用需要删除只需要执行swapoff /swapfile

swappiness

swappiness的值的大小对如何使用swap分区是有着很大的联系的。swappiness=0的时候表示最大限度使用物理内存,然后才是 swap空间,swappiness=100的时候表示积极的使用swap分区,并且把内存上的数据及时的搬运到swap空间里面。linux的基本默认设置为60,具体如下:

cat /proc/sys/vm/swappiness

也就是说,你的内存在使用到100-60=40%的时候,就开始出现有交换分区的使用。大家知道,内存的速度会比磁盘快很多,这样子会加大系统io,同时造的成大量页的换进换出,严重影响系统的性能,所以我们在操作系统层面,要尽可能使用内存,对该参数进行调整。

临时调整

sysctl vm.swappiness=10
cat /proc/sys/vm/swappiness

这只是临时调整的方法,重启后会回到默认设置的

永久调整

cat /etc/sysctl.conf
# 增加如下内容
vm.swappiness=10
# 激活设置
sysctl -p
# 查看当前设置值
sysctl -q vm.swappiness

读完了?给作者一点支持

本文采用 CC BY 4.0 协议转载 · © 大苹果

评论(0)

登录 后参与评论。

  • 还没有评论,来抢沙发。

🔗 相关文章

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "ServletContext resource [/index]")

### 错误信息 ```plaintext org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "ServletContext resource [/index]") at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:235) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE] at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE] at o

2023/12/19👍 0

Spring Boot + Thymeleaf ERROR java.lang.ClassNotFoundException: org.thymeleaf.dom.Attribute

### 错误如下 ```plaintext org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'layoutDialect' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$ThymeleafWebLayoutConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [nz.net.ultraq.thymeleaf.LayoutDialect]: Factory method 'layoutDialect' threw exc

2023/12/19👍 0

centos下mysql5.7的编译安装

### 下载mysql - 下载地址 ``` ``` [https://dev.mysql.com/downloads/mysql/](https://dev.mysql.com/downloads/mysql/) ![image.png](http://e.cdn.go90.cn/okgoes/blog/editor1702868367997_image.png) - 上传服务器解压 ``` tar -zxvf mysql-boost-5.7.44.tar.gz ``` - 安装依赖 ```bash yum install -y make gcc gcc-c++ ncurses-devel yum install bison* -y yum install ncurses* -y yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel perl-Data-Dumper net-tools ``` - 编

2023/12/18👍 0