免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: wangrujun
打印 上一主题 下一主题

关于linux交换分区大小的问题 [复制链接]

论坛徽章:
0
51 [报告]
发表于 2005-06-23 10:32 |只看该作者

关于linux交换分区大小的问题

学到不少知识

论坛徽章:
0
52 [报告]
发表于 2005-06-23 13:53 |只看该作者

关于linux交换分区大小的问题

执著,专注!

值得学习!

论坛徽章:
0
53 [报告]
发表于 2005-06-23 14:03 |只看该作者

关于linux交换分区大小的问题

原帖由 "peng" 发表:

1、系统划分硬盘文件系统的时候,系统本身不支持2g文件。
2、oracle版本问题,32位的oracle也不能生成2g的数据,64bit的数据库可以。


不好意思,我对文件系统不太懂.
想在请教一下,如上面说,如果我的交换分区建的小了,想扩大,我可以用添加交换文件的方法解决,那如过我要添加4G的交换文件是不是就得添加2个,8G的就添加4个呢?

论坛徽章:
0
54 [报告]
发表于 2005-06-24 10:42 |只看该作者

关于linux交换分区大小的问题

xinyv:
可以建立4个G的交换文件,完成后激活就可以。

论坛徽章:
0
55 [报告]
发表于 2005-07-11 11:17 |只看该作者

关于linux交换分区大小的问题

关于本贴的最后答案,来自于Linus Torvalds和他的朋友们的讨论

2. Greater 2.4 Swap Requirements
7 Jan 2001 - 18 Jan 2001 (100 posts) Archive Link: "Subtle MM bug"
Topics: Virtual Memory
People: Rik van Riel, Linus Torvalds, Eric W. Biederman, Zlatko Calusic

In the course of discussion, it became clear that Linux 2.4.x required more swap than previous versions. Rik van Riel mentioned, "2.4 keeps dirty pages in the swap cache, so you will need more swap to run the same programs..." He asked Linus Torvalds, "is this something we want to keep or should we give the user the option to run in a mode where swap space is freed when we swap in something non-shared ?" Linus replied:

    I'd prefer just documenting it and keeping it. I'd hate to have two fairly different modes of behaviour. It's always been the suggested "twice the amount of RAM", although there's historically been the "Linux doesn't really need that much" that we just killed with 2.4.x.

    If you have 512MB of RAM, you can probably afford another 40GB or so of harddisk. They are disgustingly cheap these days.

Zlatko Calusic worried that more data in swap would degrade performance because the disk head would need more seek time to find data. He asked if Linus was sure this would be okay, and Linus replied, "I'm not _sure_, obviously. However, one thing I _am_ sure of is that the sticky page-cache simplifies some things enormously, and make some things possible that simply weren't possible before." . But in a nearby post he admitted, "the sticky allocation _might_ make the IO we do be more spread out." He felt it was important to consider these kinds of potential downsides, though he felt that in this case the benefits outweighed the drawbacks; and at one point Eric W. Biederman explained succinctly, "The tradeoff when implemented correctly is that writes will tend to be more spread out and reads should be better clustered together."

Zlatko ran some tests, and could not find any problems with the 2.4.0 memory management logic, though he added, "I have found that new kernel allocates 4 times more swap space under some circumstances. That may or may not be alarming, it remains to be seen." At one point, Linus gave his overall take on 2.2/2.4 performance issues. He said:

    I personally think 2.4.x is going to be as fast or faster at just about anything. We do have some MM issues still to hash out, and tuning to do, but I'm absolutely convinced that 2.4.x is going to be a _lot_ easier to tune than 2.2.x ever was. The "scan the page tables without doing any IO" thing just makes the 2.4.x memory management several orders of magnitude more flexible than 2.2.x ever was.

    (This is why I worked so hard at getting the PageDirty semantics right in the last two months or so - and why I released 2.4.0 when I did. Getting PageDirty right was the big step to make all of the VM stuff possible in the first place. Even if it probably looked a bit foolhardy to change the semantics of "writepage()" quite radically just before 2.4 was released).

Elsewhere, he considered the case of swapless or low-swap machines:

    If you don't have any swap, or if you run out of swap, the major difference between 2.2.x and 2.4.x is probably going to be the oom handling: I suspect that 2.4.x might be more likely to kill things off sooner (but it tries to be graceful about which processes to kill).

    Not having any swap is going to be a performance issue for both 2.2.x and 2.4.x - Linux likes to push inactive dirty pages out to swap where they can lie around without bothering anybody, even if there is no _major_ memory crunch going on.

    If you do have swap, but it's smaller than your available physical RAM, I suspect that the Linux-2.4 swap pre-allocate may cause that kind of performance degradation earlier than 2.2.x would have. Another way of putting this: in 2.2.x you could use a fairly small swap partition to pick up some of the slack, and in 2.4.x a really small swap-partition doesn't really buy you much anything.


在讨论中,Linus明确的说明了,在Linux2.4.x中,内存管理(MM)策略的改变。就如Windows98向Windows2000转变一样,微软在内存和交换区中保存了更多的脏页,而不是及时回收内存,大幅提高了系统的效率。(见Widnows核心编程第18章的论述)。

Linus明确的指出,即使是512M内存,也可以分配高达40G的交换区,以提高系统的性能。Zlatko 在向Linus提出性能的质疑后,自己进行了验证。实验表明大交换区策略,没有增加磁盘I/O的流量。

最后,关于本贴早先的问题,究竟分多大的分区为宜,在查阅了一些资料后,对本问题我目前的最终看法,并且我也将按照如下方法分配交换区:

1.  交换区最小不低于4G
     建立两个各为2G的交换区,做为基础的4G交换分区

2.  建立8个2G的交换文件,做为扩展的交换分区
    这样总的交换分区大概在20G左右,如果硬盘更大,可以增加最多。

     谢谢网中人提出的一系列问题,我也可以对您的按照系统运行状况来分配交换区的提议,做出答复:按照Linus的建议,可以不必要考虑这些。Linux 2.4.x内核会在大的交换区情况下,运行的更好。

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
56 [报告]
发表于 2005-07-11 13:41 |只看该作者

关于linux交换分区大小的问题

呵.... 就是這篇!

不過, 我所提的 total usage, 是指 mem 的真實用量, 這包含了 app 與 kernel 還有其他各種用途...

若 total 只用 64M , 你真的認為 4G swap 有幫助?
若你還堅持, 那好吧, 那我沒啥話要說了!

论坛徽章:
0
57 [报告]
发表于 2005-07-11 14:55 |只看该作者

关于linux交换分区大小的问题

呵呵,如果是64M,4G swap也许真的有所帮助。你看Linus说512M就可以使用40G的swap,那么64M为何不可能使用4G的swap呢?这里Linus有个基本的前提,就是磁盘已经非常便宜,下雨天打孩子,闲着也是闲着呢。

也许您还可以最其它的例子,比如512K的Memory,是否需要4G的swap。那...这样的话,就扯得远了。其实我在第一贴的提问中,说明了基本的配置情况,这里有一个理性的限定范围吧。

论坛徽章:
0
58 [报告]
发表于 2005-07-11 15:35 |只看该作者

关于linux交换分区大小的问题

看了大家的发言,懂了不少.但是说什么的都有.所以还是有点晕.
     现在我的服务器是IBM x445系列,内存4G,安装的Linux企业版4,还有Weblogic8.1,分配的是4G的swap,机器运行的时候很慢,尤其是用SSH从服务器上拷贝东西下来时,简直让人受不了!
    还请各位大侠支招啊!
rlneo 该用户已被删除
59 [报告]
发表于 2005-07-11 16:40 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
60 [报告]
发表于 2005-07-12 08:59 |只看该作者

关于linux交换分区大小的问题

楼上说的这个情况,我还是第一次看到。学习中。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP