一、為何要關閉透明大頁
A--MOS獲取 .
#翻譯 由於透明超大頁面已知會導致意外的節點重新啟動並導致RAC出現性能問題,因此Oracle強烈建議禁用透明超大頁面。 另外,即使在單實例數據庫環境中,透明超大頁面也可能會導致問題,並出現意外的性能問題或延遲。 因此,Oracle建議在運行Oracle的所有數據庫服務器上禁用透明超大頁面 #原版: 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
B--https://blog.csdn.net/wzx19840423/article/details/53667809 --博客截取
透明大頁塊:可以動態將系統默認內存葉塊4kb,交換為Huge pages,在這個過程中,對於操作系統的內存的各種分配活動,都需要各種內存鎖,直接影響程序的內存訪問性能,
這個過程對應用是透明的,在應用層面不可控制,對於專門優化4K page優化的程序來說,造成隨機的性能下降問題。 Transparent Huge Pages (THP) are enabled by default in RHEL 6 for all applications. The kernel attempts to allocate
hugepages whenever possible and any Linux process will receive 2MB pages if the mmap region is 2MB naturally aligned.
The main kernel address space itself is mapped with hugepages, reducing TLB pressure from kernel code. For general
information on Hugepages, see: What are Huge Pages and what are the advantages of using them? The kernel will always attempt to satisfy a memory allocation using hugepages. If no hugepages are available
(due to non availability of physically continuous memory for example) the kernel will fall back to the regular 4KB pages.
THP are also swappable (unlike hugetlbfs). This is achieved by breaking the huge page to smaller 4KB pages,
which are then swapped out normally. But to use hugepages effectively, the kernel must find physically continuous areas of memory big enough to satisfy the request,
and also properly aligned. For this, a khugepaged kernel thread has been added. This thread will occasionally
attempt to substitute smaller pages being used currently with a hugepage allocation, thus maximizing THP usage. In userland, no modifications to the applications are necessary (hence transparent). But there are ways to optimize its use.
For applications that want to use hugepages, use of posix_memalign() can also help ensure that large allocations are
aligned to huge page (2MB) boundaries. Also, THP is only enabled for anonymous memory regions. There are plans to add support for tmpfs and page cache.
THP tunables are found in the /sys tree under /sys/kernel/mm/redhat_transparent_hugepage.
--博客鏈接--描述配置大頁的好處
https://blog.csdn.net/g__hk/article/details/44955587
1.頁表數量減少
2.sga不會存在內存交換
二、禁用透明大頁區在哪?
從RedHat6,OL6,SLES11和UEK2內核開始,實現並啟用透明超大頁面(默認)以嘗試改進內存管理。
透明HugePages類似於以前Linux版本中可用的HugePages。主要區別在於透明HugePages是在運行時由內核中的khugepaged線程動態設置的,
而常規的HugePages必須在啟動時預先分配
#禁用后,內存大頁將在系統啟動后初始化分配,內存大頁不會動態調整
三、關閉透明大頁步驟:
可以參考MOS文檔:
![]() |
Oracle Linux 7 - How to disable Transparent HugePages for RHCK kernel? (Doc ID 2066217.1) |
系統版本:
#CentOS release 6.9
[root@bogon data]# lsb_release -a
Description: CentOS release 6.9 (Final)
Release: 6.9
# cp /etc/grub.conf /etc/grub.conf.bak
# vi /etc/grub.conf 本次配置
#boot=/dev/sda default=1 #解釋說明,默認系統啟動,使用標題,引導序列1 timeout=5 splashimage=(hd0,0)/boot/grub/splash.xpm.gz hiddenmenu title CentOS (4.4.132-1.el6.elrepo.x86_64) --引導,啟動序列0 root (hd0,0) kernel /boot/vmlinuz-4.4.132-1.el6.elrepo.x86_64 ro root=UUID=e1c11d33-6775-4772-966a-1575e1660833 rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet transparent_hugepage=never--可以不修改 initrd /boot/initramfs-4.4.132-1.el6.elrepo.x86_64.img title CentOS (2.6.32-696.28.1.el6.x86_64) --引導,啟動序列1 root (hd0,0) kernel /boot/vmlinuz-2.6.32-696.28.1.el6.x86_64 ro #內核---參數 root=UUID=e1c11d33-6775-4772-966a-1575e1660833 rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet transparent_hugepage=never 修改 initrd /boot/initramfs-2.6.32-696.28.1.el6.x86_64.img --初始化
【在quiet之后,空格加上transparent_hugepage=never,博客發出去有換行,修改請注意】
#LINUX 7
[root@bdp04 ~]# cat /proc/version Linux version 3.10.0-693.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) )
#1 SMP Tue Aug 22 21:09:27 UTC 2017 # [root@bdp04 etc]# cd /etc/default/ [root@bdp04 default]# cp grub grub_bak_180508 [root@bdp04 default]# vi grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet transparent_hugepage=never" GRUB_DISABLE_RECOVERY="true" 生效配置 [root@bdp04 default]# cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg_bak180508 [root@bdp04 default]# grub2-mkconfig -o /boot/grub2/grub.cfg
Linux7 第二種方式 在/etc/rc.local中加入如下兩行--先備份,修改后重啟系統 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 請相應地將RHEL內核的文件路徑更改為/ sys / kernel / mm / redhat_transparent_hugepage /
四、驗證查詢是否關閉:配置重啟系統后
#A,認為最簡單方便的:查詢大頁配置
oracle@bdp04 ~]$ grep Huge /proc/meminfo
AnonHugePages: 0 kB 與透明大頁有關,透明大頁關閉,則顯示0
HugePages_Total: 65560 大頁總數量
HugePages_Free: 65560
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
[https://toutiao.io/posts/n4hzg1/preview 可獲得AnonHugePages 解釋說明
#B 【never】
[root@testhost ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]