我们有一台 RHEL 7 机器,只有 2G 的可用内存:
free -g
total used free shared buff/cache available
Mem: 31 28 0 0 1 2
Swap: 15 9 5
Run Code Online (Sandbox Code Playgroud)
所以我们决定用vm.swappiness = 100
in/etc/sysctl.conf
而不是 10将swappiness 增加到最大值,并用于sysctl -p
应用设置。
一段时间后,我们再次检查状态:
free -g
total used free shared buff/cache available
Mem: 31 28 0 0 2 2
Swap: 15 9 5
Run Code Online (Sandbox Code Playgroud)
正如我们所看到的,尽管有新的 swappiness 设置,但我们看到free -g
可用 RAM 保持在 2G。为什么?这里有什么问题?
我们预计会看到 15G 的已用交换。
我们还检查了:
cat /proc/sys/vm/swappiness
100
Run Code Online (Sandbox Code Playgroud)
所以一切都应该根据新设置工作,但free
显示相同的情况。这是怎么回事?