在LINUX的不同版本中,关闭Transparent HugePages的方法也有差异,此处汇总LINUX6.5/6.8/7.0/7.2的关闭方法,如下: 

参考MOS文档汇总: 

ALERT: Disable Transparent HugePages on SLES11, RHEL6, OL6 and UEK2 Kernels (文档 ID 1557478.1) 

Oracle Linux 7 - How to disable Transparent HugePages for RHCK kernel? (文档 ID 2066217.1) 

Transparent Hugepage is not getting disabled (文档 ID 2279458.1) 

HugePages on Oracle Linux 64-bit (文档 ID 361468.1) 

http://blog.csdn.net/msdnchina/article/details/72968215

Transparent HugePages概念及危害:

Starting with RedHat6, OL6, SLES11 and UEK2 kernels, Transparent HugePages are implemented and enabled (default) in an attempt to improve the memory management. Transparent HugePages are similar to the HugePages that have been available in previous Linux releases. The main difference is that the Transparent HugePages are set up dynamically at run time by the khugepaged thread in kernel while the regular HugePages had to be preallocated at the boot up time. Because Transparent HugePages are known to cause unexpected node reboots and performance problems with RAC, Oracle strongly advises to disable the use of Transparent HugePages. In addition, Transparent Hugepages may cause problems even in a single-instance database environment with unexpected performance problems or delays. As such, Oracle recommends disabling Transparent HugePages on all Database servers running Oracle.

RHEL6.4/6.5版本禁用THP方法:

参考:ALERT: Disable Transparent HugePages on SLES11, RHEL6, RHEL7, OL6, OL7, and UEK2 and above (文档 ID 1557478.1) 如果是RHEL6/OEL6 操作系统需要关闭这个特性,修改好了之后,需要重启操作系统生效。修改/etc/grub.conf文件,在Kernel行末尾加上下列参数: transparent_hugepage=never 经查阅相关资料,并实际验证在OEL6.5中,Transparent HugePages已经被关闭。 If Transparent HugePages is removed from the kernel, then the /sys/kernel/mm/transparent_hugepage or /sys/kernel/mm/redhat_transparent_hugepage files do not exist.Transparent HugePages memory is enabled by default with Red Hat Enterprise Linux 6, SUSE Linux Enterprise Server 11, and Oracle Linux 6 with earlier releases of Oracle Linux Unbreakable Enterprise Kernel 2 (UEK2) kernels. Transparent HugePages memory is disabled in later releases of Oracle Linux UEK2 kernels.

RHEL6.8版本禁用THP方法:

参考:Transparent Hugepage is not getting disabled (文档 ID 2279458.1) 不能使用GRUB配置中直接修改的原因是ktune service.在/etc/tune-profiles/enterprise-storage/ktune.sh配置文件中有set_transparent_hugepages always字样。 解决方法:

#service tuned stop
#chkconfig tuned off
#service ktune stop
#chkconfig ktune off
Append transparent_hugepage=never to kernel command line in /boot/grub/grub.conf file

/etc/grub.conf:
...
kernel /vmlinuz-2.6.32-642.3.1.el6.x86_64 ro root=/dev/mapper/vg_ho02db02-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_ho02db02/lv_swap rd_LVM_LV=vg_ho02db02/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=off transparent_hugepage=never fnic.fnic_max_qdepth=256
...--->>>在kernel末尾增加transparent_hugepage=never

Reboot the server and check if /sys/kernel/mm/transparent_hugepage/enabled changed
#cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

RHEL7.0版本禁用THP方法:

参考:Oracle Linux 7 - How to disable Transparent HugePages for RHCK kernel? (文档 ID 2066217.1)

#Modify the file "/usr/lib/tuned/throughput-performance/tuned.conf" as following
transparent_hugepages=always
to 
transparent_hugepages=never

b) Reboot the server and verify the outcome. 
#uname -r
3.10.0-229.el7.x86_64
#cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never] <<--- THP Disabled

RHEL7.2版本禁用THP方法:

参考类总文章:http://blog.csdn.net/msdnchina/article/details/72968215
 tmp]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.2 (Maipo) 
# uname -r 
3.10.0-327.el7.x86_64 
修改/etc/default/grub文件,如下是修改之后的效果: 
# cat /etc/default/grub 
………… 
GRUB_CMDLINE_LINUX="rhgb quiet transparent_hugepage=never" ---->>> transparent_hugepage=never是新加的

# grub2-mkconfig -o /boot/grub2/grub.cfg ---->>执行该命令 
Generating grub configuration file ... 
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64 
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img 
Found linux image: /boot/vmlinuz-0-rescue-3b932bfbe4f94ccf93c11ba19641e845 
Found initrd image: /boot/initramfs-0-rescue-3b932bfbe4f94ccf93c11ba19641e845.img
done 
# init 6 -------->>>>重启生效

os重启之后,查看效果
# cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz-3.10.0-327.el7.x86_64 root=UUID=0dd676f4-cb3b-469d-b5e6-73defbc87f4e ro rhgb quiet transparent_hugepage=never ---->>>有此行。 

# cat /sys/kernel/mm/transparent_hugepage/enabled 
always madvise [never] ---->>>[never]表示成功禁用THP。 
# grep AnonHugePages /proc/meminfo 
AnonHugePages: 0 kB ---------->>>返回值若是零,代表成功禁用THP。
Logo

更多推荐