| Line 70: |
Line 70: |
| | <nowiki>security: | | <nowiki>security: |
| | authorization: enabled</nowiki> | | authorization: enabled</nowiki> |
| | + | === Disable Transparent Huge Pages (THP) === |
| | + | Create the init.d script.<br /> |
| | + | Create the following file at /etc/init.d/disable-transparent-hugepages: |
| | + | <source lang="bash">#!/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</source> |
| | + | Make it executable: |
| | + | sudo chmod 755 /etc/init.d/disable-transparent-hugepages |
| | + | Configure your operating system to run it on boot.<br /> |
| | + | |
| | + | Use the appropriate command to configure the new init script on your Linux distribution.<br /> |
| | + | |
| | + | Distribution Command<br /> |
| | + | |
| | + | Ubuntu and Debian sudo update-rc.d disable-transparent-hugepages defaults<br /> |
| | + | SUSE sudo insserv /etc/init.d/disable-transparent-hugepages<br /> |
| | + | Red Hat, CentOS, Amazon Linux, and derivatives sudo chkconfig --add disable-transparent-hugepages<br /> |
| | | | |
| | == Start/Stop/Restart MongoDB == | | == Start/Stop/Restart MongoDB == |