Commit 2b9fb4aa by Fred Smith

Merge pull request #2381 from edx/derf/hugepages_upstart_script

hugepages upstart script
parents 67c280e5 8e230288
#!/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
;;
stop)
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 'always' > ${thp_path}/enabled
echo 'always' > ${thp_path}/defrag
unset thp_path
;;
status)
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
case $(cat ${thp_path}/enabled | sed -e 's/.*\[//' -e 's/\].*//') in
always)
echo "always"
return 1
;;
madvise)
echo "madvise"
return 1
;;
never)
echo "never"
return 0
;;
esac
unset thp_path
;;
esac
description "set transparent hugepage to never"
start on starting mongod
task
script
env thp_path=/sys/kernel/mm/transparent_hugepage
exec echo 'never' > ${thp_path}/enabled
exec echo 'never' > ${thp_path}/defrag
end script
......@@ -23,10 +23,19 @@
force=yes
when: mongodb_needs_upgrade.stat.exists and not MONGO_CLUSTERED
- name: remove old init script for hugepages
file: >
path=/etc/init.d/disable-transparent-hugepages
state=absent
tags:
- "hugepages"
- "install"
- "install:system-requirements"
- name: disable transparent huge pages on startup (http://docs.mongodb.org/manual/tutorial/transparent-huge-pages/)
copy: >
src=disable-transparent-hugepages
dest=/etc/init.d/disable-transparent-hugepages
src=disable-transparent-hugepages.conf
dest=/etc/init/disable-transparent-hugepages.conf
owner=root
group=root
mode=0755
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment