Linux SWAP 交换分区配置说明

一.SWAP 说明

1.1 SWAP 概述


这个是SWAP 交换分区的作用。实际上,我们更关注的应该是SWAP分区的大小问题。 设置多大才是最优的。


4G以内的物理内存,SWAP 设置为内存的2倍。

4-8G的物理内存,SWAP 等于内存大小。

8-64G 的物理内存,SWAP 设置为8G。

64-256G物理内存,SWAP 设置为16G。


1.2 系统在什么情况下才会使用SWAP?

实际上,并不是等所有的物理内存都消耗完毕之后,才去使用swap的空间,什么时候使用是由swappiness 参数值控制。

[root@rhce ~]# cat /proc/sys/vm/swappiness



swappiness=0的时候表示最大限度使用物理内存,然后才是 swap空间,



1.3 如何修改swappiness参数?


[root@rhce ~]# sysctl vm.swappiness=10

vm.swappiness = 10

[root@rhce ~]# cat /proc/sys/vm/swappiness




在/etc/sysctl.conf 文件里添加如下参数:



[root@rhce ~]# echo ‘vm.swappiness=10’>> /etc/sysctl.conf


14 Responses so far.

  1. quest bars says:
    Hello, Neat post. There is an issue together with your site in web
    explorer, would check this? IE nonetheless is the market leader
    and a huge component to other folks will pass over your wonderful
    writing because of this problem.
  2. quest bars says:
    Thanks for sharing your thoughts on quest bars. Regards
  3. I pay a quick visit each day a few sites and blogs to read posts, but this
    blog provides quality based content.
  4. I love what you guys are up too. This kind of clever work and reporting!

    Keep up the good works guys I’ve you guys to my personal blogroll.

  5. It’s appropriate time to make some plans for the long run and it’s time to be happy.
    I’ve learn this submit and if I may just I want to recommend
    you few interesting things or suggestions. Maybe you could write
    subsequent articles relating to this article. I want to learn more issues about it!
  6. I have fun with, result in I found just what I used to be
    taking a look for. You have ended my four day long hunt!
    God Bless you man. Have a great day. Bye
  7. What’s up i am kavin, its my first time to commenting anyplace, when i read this piece of writing
    i thought i could also make comment due to this brilliant post.
  8. Hey! Do you know if they make any plugins to safeguard against hackers?
    I’m kinda paranoid about losing everything I’ve worked hard on. Any suggestions?
  9. Thanks to my father who told me regarding this webpage, this
    webpage is actually remarkable.
  10. I am regular visitor, how are you everybody? This article posted at this web page is in fact pleasant.
  11. Thank you for the auspicious writeup. It in fact was a amusement account it.

    Look advanced to more added agreeable from you! By the way, how could
    we communicate?

  12. It’s awesome for me to have a website, which is valuable in support
    of my know-how. thanks admin
  13. I must thank you for the efforts you have put in penning this blog.

    I’m hoping to see the same high-grade blog posts from you in the future
    as well. In truth, your creative writing abilities has encouraged me to get my very own site now 😉

  14. Howdy this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding knowledge so I wanted to get advice from someone with experience. Any help would be greatly appreciated!