CentOS7 Disable Transparent Huge Pages
Transparent Huge Pages (THP) has been introduced since the CENTOS6 version, and this feature is enabled by default, starting with the CentOS7 version. Although THP is intended to improve memory performance, some database vendors recommend shutting down THP (such as Oracle, MARIADB, MONGODB, etc.) directly, which may cause performance degradation.
First check the enabled status of the THP:
[Root@localhost ~]# Cat/sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
[root@localhost ~] # cat/sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
This state is indicated to be enabled.
At this time we can certainly modify the above two files individually to disable THP, but if you want to make it permanent, take the following steps.
Edit Rc.local File:
[Root@localhost ~]# vim/etc/rc.d/rc.local
Add the following:
If Test-f/sys/kernel/mm/transparent_hugepage/enabled; Then
echo never >/sys/kernel/mm/transparent_hugepage/enabled
fi
if Test-f/sys/kernel/mm/ Transparent_hugepage/defrag; Then
echo never >/sys/kernel/mm/transparent_hugepage/defrag
fi
Save exit, and then give rc.local file execution permissions:
[Root@localhost ~]# chmod +x/etc/rc.d/rc.local
Finally reboot the system, later check THP should be disabled
[Root@localhost ~]# cat/sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
[ Root@localhost ~]# Cat/sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]
Thank you for reading, I hope to help you, thank you for your support for this site!