Last active
August 9, 2016 16:38
-
-
Save mhelmstetter/bcc0b847be2bf2d10c1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
re='^[0-1]+$' | |
if [[ `cat ${thp_path}/khugepaged/defrag` =~ $re ]] | |
then | |
# RHEL 7 | |
echo 0 > ${thp_path}/khugepaged/defrag | |
else | |
# RHEL 6 | |
echo 'no' > ${thp_path}/khugepaged/defrag | |
fi | |
unset thp_path | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment