欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

增加swap空间

程序员文章站 2024-01-20 15:53:58
...

因java加压包 耗费大量内存,且频率高,centos 服务器16G内存,完全被cached 占满。

[[email protected] home]# free
             total       used       free     shared    buffers     cached
Mem:      16315436   15693128     622308         64     103564   13778428
-/+ buffers/cache:    1811136   14504300

手动释命令

释放方法有三种(系统默认值是0,释放之后你可以再改回0值):

To free pagecache: echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes: echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes: echo 3 > /proc/sys/vm/drop_caches

手动释放后不能解决问题,且操作文件因cache被清,速度慢。

想到增加swap空间

[[email protected] home]# mkswap /home/swapfile 
mkswap: /home/swapfile: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 33554428 KiB
no label, UUID=ab40acb5-66be-4b4c-b706-cd66629a9b27
[[email protected] home]# swapon /home/swapfile 
[[email protected] home]# vim /etc/fstab 
/home/swapfile  swap    swap    defaults        0 0  ##添加到文件中

[[email protected] home]# mount -a
[[email protected] home]# free
             total       used       free     shared    buffers     cached
Mem:      16315436   15113992    1201444         64     101892   13707604
-/+ buffers/cache:    1304496   15010940
Swap:     41787384      64408   41722976

完成。

相关标签: swap