All Apps and Add-ons

Disable THP in AWS (Linux AMI)

jtrujillo
Path Finder

How do you disable Transparent Hugepages in an Amazon AWS environment that doesn't support systemctl or systemd?

0 Karma
1 Solution

jtrujillo
Path Finder

Here is a way to keep THP turned off even after reboot.

Step1

sudo vi /etc/init.d/disable-transparent-hugepages

Step 2

#!/bin/sh
### BEGIN INIT INFO
# Provides:          disable-transparent-hugepages
# Required-Start:    $local_fs
# Required-Stop:
# X-Start-Before:    mongod mongodb-mms-automation-agent
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description:       Disable Linux transparent huge pages, to improve
#                    database performance.
### END INIT INFO

case $1 in   start)
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/transparent_hugepage
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/redhat_transparent_hugepage
    else
      return 0
    fi

    echo 'never' > ${thp_path}/enabled
    echo 'never' > ${thp_path}/defrag

    unset thp_path
    ;; 
esac 

Step 3

sudo chmod 755 /etc/init.d/disable-transparent-hugepages 

Step4

sudo chkconfig --add disable-transparent-hugepages

Reference:

http://serverfault.com/questions/688392/disable-thp-and-thp-defrag-on-centos-7-ec2-instance

View solution in original post

jtrujillo
Path Finder

Here is a way to keep THP turned off even after reboot.

Step1

sudo vi /etc/init.d/disable-transparent-hugepages

Step 2

#!/bin/sh
### BEGIN INIT INFO
# Provides:          disable-transparent-hugepages
# Required-Start:    $local_fs
# Required-Stop:
# X-Start-Before:    mongod mongodb-mms-automation-agent
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description:       Disable Linux transparent huge pages, to improve
#                    database performance.
### END INIT INFO

case $1 in   start)
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/transparent_hugepage
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/redhat_transparent_hugepage
    else
      return 0
    fi

    echo 'never' > ${thp_path}/enabled
    echo 'never' > ${thp_path}/defrag

    unset thp_path
    ;; 
esac 

Step 3

sudo chmod 755 /etc/init.d/disable-transparent-hugepages 

Step4

sudo chkconfig --add disable-transparent-hugepages

Reference:

http://serverfault.com/questions/688392/disable-thp-and-thp-defrag-on-centos-7-ec2-instance

Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...