16

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?

thanuja
  • 516
  • 1
  • 6
  • 18

5 Answers5

14

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.

Dmitriusan
  • 8,724
  • 2
  • 31
  • 35
14

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

Mehdi LAMRANI
  • 10,556
  • 13
  • 74
  • 115
Anthony
  • 7,121
  • 3
  • 33
  • 66
13

To disable Transparent Huge Pages (THP) permanently choose one of the following options:

  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)

  1. 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.

Brendon Muir
  • 4,289
  • 2
  • 27
  • 49
MrRolling
  • 1,705
  • 1
  • 20
  • 30
  • 1
    might be worth being more clear that you only need to do either #1 or #2 and not both –  Oct 12 '18 at 13:38
9

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
PKSingh
  • 441
  • 4
  • 4
  • 1
    `/etc/rc.local` contains `exit 0` as last line in my case. All scripts should be added before `exit`. Use `sed` command instead `sudo sed -i '$i hugeadm --thp-never' /etc/rc.local`. It will insert line before the last one. – dlopatin Sep 18 '18 at 11:32
4

All of these answers are out of date. Tried all of them, and the values keep getting overwritten.

The guide here actually works: https://docs.mongodb.com/manual/tutorial/transparent-huge-pages/

It needs to be a service that runs at startup properly, just follow this guide

Worked on Ubuntu 19.04, finally suppressed the redis warnings

slothstronaut
  • 758
  • 1
  • 8
  • 14