如何在Centos 7上禁用mongodb的THP

我刚安装了一个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执行权限

现在每次启动时都会禁用。