关于swappiness是否可以设置0?

2023年 10月 19日 38.6k 0

直接参考oracle官方建议吧:

建议在linux环境下设置1~10之间即可,默认的60太大了。

vm.swappiness=1

vm.swappiness - 0 or 1? (Doc ID 1917687.1)

Should I use 0 or 1 for vm.swappiness?

SOLUTION
These instructions are valid for Red Hat Enterprise Linux and Oracle Linux systems, but should be similar for other Linux distros.

There is some confusion about using a value of 0 or 1 for the vm.swappiness kernel parameter.

The confusion about vm.swappiness comes from the fact that in older Red Hat kernels, a value of 0 for vm.swappiness resulted in the minimal amount of swapping to avoid an out of memory condition. In newer kernels (as of RHEL kernel 2.6.32-303), a value of 0 will completely disable swap, but a value of 1 will provide the minimal amount of swapping to avoid an out of memory condition.

My general recommendation is to set vm.swappiness to a value of 1 for a dedicated MySQL server. There is not much practical difference between a value of 0 and a value of 1 on older kernels, but 1 is the safe setting to avoid an OOM condition on newer kernels (assuming that some swap space is available, of course).

To set vm.swappiness to 1 and make it persistent across reboots:

echo "vm.swappiness=1" >> /etc/sysctl.conf

sysctl -p

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论