San*_*dra 19 linux windows vmware-esx vmware-esxi
在 VMware ESX 设置中,这些选项有何不同?:
我的意思是,在这两种情况下都使用了交换;
那么给 Linux VM 的交换分区有什么意义吗?
Sco*_*ren 15
忽略人们正在处理操作系统特定原因这一事实,我有两个原因为什么不使用交换分区/文件运行是个坏主意。
vor*_*aq7 10
是的。这是Unix的方式。
Unix(甚至 Linux)希望能够交换。当系统无法交换时,就会发生
不好的事情(因为它在没有交换分区的情况下配置错误或因为交换空间已满)。在 Linux 中,其中一个坏事是 Out Of Memory Killer,它会将一把刀插入它认为使用最多 RAM 的程序的后面(数据库服务器是最喜欢的目标)。
你设置了什么/proc/sys/vm/overcommit_memory
?来自内核文档:
0 - Heuristic overcommit handling. Obvious overcommits of
address space are refused. Used for a typical system. It
ensures a seriously wild allocation fails while allowing
overcommit to reduce swap usage. root is allowed to
allocate slightly more memory in this mode. This is the
default.
1 - Always overcommit. Appropriate for some scientific
applications.
2 - Don't overcommit. The total address space commit
for the system is not permitted to exceed swap + a
configurable percentage (default is 50) of physical RAM.
Depending on the percentage you use, in most situations
this means a process will not be killed while accessing
pages but will receive errors on memory allocation as
appropriate.
Run Code Online (Sandbox Code Playgroud)
因此,如果您使用 1,则没有区别。如果您使用 2 并且没有 Linux 交换文件,那么没有进程能够分配 512M 的(虚拟)内存。0 的结果不清楚。
编辑:来自http://utcc.utoronto.ca/~cks/space/blog/linux/LinuxVMOvercommit,这就是0的工作原理:
启发式过度使用尝试计算出如果系统回收了所有可能的内存并且没有其他进程使用比当前更多的 RAM,系统可以为您提供多少内存;如果您的要求超出此范围,您的分配将被拒绝。具体来说,理论“可用内存”数量是通过将可用交换空间、可用 RAM(如果您不是 root 则小于 1/32)以及统一缓冲区高速缓存和标记为可回收的内核数据使用的所有空间相加来计算的。 (减去一些保留页)。
所以它在计算中也使用了交换。一般来说,我会遵循 RHEL 的建议:
M = Amount of RAM in GB, and S = Amount of swap in GB, then
If M < 2
S = M *2
Else
S = M + 2
Run Code Online (Sandbox Code Playgroud)