Disable Linux THP on Debian distros

This commit is contained in:
Oleg Vivtash 2015-04-08 20:18:19 +03:00
parent 6309afc1cf
commit f864abe29d
4 changed files with 25 additions and 0 deletions

View File

@ -14,6 +14,7 @@ mongodb_package: mongodb-org
mongodb_force_wait_for_port: false # When not forced, the role will wait for mongod port to become available only with systemd
mongodb_pymongo_from_pip: false # Install latest PyMongo via PIP or package manager
mongodb_disable_thp: true
mongodb_user: mongodb
mongodb_daemon_name: "{{ 'mongod' if ('mongodb-org' in mongodb_package) else 'mongodb' }}"

View File

@ -3,6 +3,7 @@
mongodb_package: mongodb-org
mongodb_force_wait_for_port: false
mongodb_pymongo_from_pip: false # Install latest PyMongo via PIP or package manager
mongodb_disable_thp: true
mongodb_user: mongodb
mongodb_daemon_name: "{{ 'mongod' if ('mongodb-org' in mongodb_package) else 'mongodb' }}"

11
files/disable_thp.sh Normal file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
if test -f /sys/kernel/mm/transparent_hugepage/khugepaged/defrag; then
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi

View File

@ -50,6 +50,18 @@
template: src=mongod.conf.j2 dest=/etc/mongod.conf backup=yes owner=root group=root mode=0644
register: config_result
- name: Install disable_thp script
copy: src=disable_thp.sh dest=/usr/local/bin/disable_thp.sh mode='u=rwx,g=rx,o=rx'
when: ansible_os_family == 'Debian' and mongodb_disable_thp
- name: Disable Linux transparent hugepages now
command: /usr/local/bin/disable_thp.sh
when: ansible_os_family == 'Debian' and mongodb_disable_thp
- name: Disable Linux transparent hugepages on boot
lineinfile: dest=/etc/rc.local regexp='/usr/local/bin/disable_thp.sh' line='if test -f '/usr/local/bin/disable_thp.sh'; /usr/local/bin/disable_thp.sh; fi'
when: ansible_os_family == 'Debian' and mongodb_disable_thp
- name: mongodb restart
service: name={{ mongodb_daemon_name }} state=restarted
when: config_result|changed