How to disable Transparent Huge Pages (THP) in Ubuntu 16.04LTS

微笑、不失礼 提交于 2019-12-18 19:00:55

问题


I am setting up an ambari cluster with 3 virtualbox VMs running Ubuntu 16.04LTS. However I get the below warning:

The following hosts have Transparent Huge Pages (THP) enabled. 
THP should be disabled to avoid potential Hadoop performance issues.

How can I disable THP in Ubuntu 16.04?


回答1:


Did you try this command:

sudo su
echo never > /sys/kernel/mm/transparent_hugepage/enabled

?

Alternatively, you may install hugepages

sudo su
apt-get install hugepages
hugeadm --thp-never

As mentioned by @Anthony, the effect would not persist after a reboot. Use your distribution-specific method to do that every time after reboot.




回答2:


Install :

sudo apt install hugepages

Then run :

sudo hugeadm --thp-never

To persist the changes you can add this last command to /etc/rc.local




回答3:


To disable Transparent Huge Pages (THP) permanently:

  1. Via GRUB options (preferred):

    Edit /etc/default/grub to add transparent_hugepage=never to the GRUB_CMDLINE_LINUX_DEFAULT option:

    GRUB_CMDLINE_LINUX_DEFAULT="transparent_hugepage=never quiet splash"
    

    After that, run update-grub command. (Need reboot to take effect)

  2. With rc.local:

    Edit /etc/rc.local and put following script before exit 0

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

* To avoid reboot (as mentioned before), you can disable it by # echo never > /sys/kernel/mm/transparent_hugepage/enabled command.




回答4:


Below 3 commands fix the issue over Ubuntu(14.x/16.x) and also make it persistent on system boots.

  1. sudo apt-get install hugepages
  2. sudo hugeadm --thp-never
  3. sudo /bin/sed -i '$i /usr/bin/hugeadm --thp-never' /etc/rc.local


来源:https://stackoverflow.com/questions/44800633/how-to-disable-transparent-huge-pages-thp-in-ubuntu-16-04lts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!