mongodb 如何在 Centos 7 上禁用 THP

How to disable THP on Centos 7 for mongodb

我刚刚安装了 Centos 7 的全新实例

Linux version 3.10.0-229.1.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Fri Mar 27 03:04:26 UTC 2015

我安装了 mongodb 3.0,当我连接时,我收到了这条奇怪的消息:

2015-04-15T07:48:55.583+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-04-15T07:48:55.583+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-04-15T07:48:55.583+0000 I CONTROL  [initandlisten]
2015-04-15T07:48:55.583+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-04-15T07:48:55.583+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'

如何禁用此版本的 THP?

我尝试过但没有成功的事情

我可以禁用它运行这个命令:

echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

但是当我重新启动时,问题又出现了。

我试图修改 /etc/rc.local 添加这些行:

if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
  echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
  echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
exit 0

重新启动但没有结果

我也试过修改/etc/default/grub ...

我遇到了同样的问题,并通过在 /etc/rc.local:

中写入解决了这个问题
echo never > /sys/kernel/mm/transparent_hugepage/enabled;
echo never > /sys/kernel/mm/transparent_hugepage/defrag;

我也给了/etc/rc.d/rc.local

执行权限

现在每次启动时它们都被禁用。