关闭透明大页和开启大页
参考MOS 文档HugePages on Linux: What It Is... and What It Is Not... (Doc ID 361323.1)
开大页的优点,我们直接拿MOS的说明吧,原汁原味
Advantages of HugePages Over Normal Sharing Or AMM
Not swappable: HugePages are not swappable. Therefore there is no page-in/page-out mechanism overhead.HugePages are universally regarded as pinned.
Relief of TLB pressure:
Hugepge uses fewer pages to cover the physical address space, so the size of “book keeping” (mapping from the virtual to the physical address) decreases, so it requiring fewer entries in the TLB
TLB entries will cover a larger part of the address space when use HugePages, there will be fewer TLB misses before the entire or most of the SGA is mapped in the SGA
Fewer TLB entries for the SGA also means more for other parts of the address space
Decreased page table overhead: Each page table entry can be as large as 64 bytes and if we are trying to handle 50GB of RAM, the pagetable will be approximately 800MB in size which is practically will not fit in 880MB size lowmem (in 2.4 kernels - the page table is not necessarily in lowmem in 2.6 kernels and later) considering the other uses of lowmem. When 95% of memory is accessed via 256MB hugepages, this can work with a page table of approximately 40MB in total. See also Document 361468.1.
Eliminated page table lookup overhead: Since the pages are not subject to replacement, page table lookups are not required.
Faster overall memory performance: On virtual memory systems each memory operation is actually two abstract memory operations. Since there are fewer pages to work on, the possible bottleneck on page table access is clearly avoided.
并且在配置大页时,要按照脚本计算的实际大小设置,太大,太小都有问题,具体如下所示:
What if Not Enough HugePages Configured?
Configuring your Linux OS for HugePages is a delicate process where if you do not configure properly, the system may experience serious problems. If you do not have enough HugePages configured you may encounter:
- HugePages not used (HugePages_Total = HugePages_Free) at all wasting the amount configured for
- Poor database performance
- System running out of memory or excessive swapping
- Some or any database instance cannot be started
- Crucial system services failing (e.g.: CRS)
To avoid / help with such situations Bug 10153816 was filed to introduce a database initialization parameter in 11.2.0.2 (use_large_pages) to help manage which SGAs will use huge pages and potentially give warnings or not start up at all if they cannot get those pages.
What if Too Much HugePages Configured?
It is of course technically possible to configure more than needed. When that is done, the unused part of HugePages allocation will not be available for other purposes on the system and memory shortage can be encountered. Please make sure to configure only for needed amount of hugepages.
关闭透明大页码开启大页的具体流程如下
1 关闭透明大页
[root@rac1 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
[root@rac1 ~]# cat /etc/default/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="crashkernel=auto rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
[root@rac1 ~]# vi /etc/default/grub
[root@rac1 ~]# cat /etc/default/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="crashkernel=auto rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true
使用grub2-mkconfig -o /boot/grub2/grub.cfg更新信息失败
[root@rac1 transparent_hugepage]# grub2-mkconfig -o /boot/grub2/grub.cfg
sed: can't read /etc/system-release: No such file or directory
解决方法:
[root@rac1 etc]# cp redhat-release redhat-release.bak
[root@rac1 etc]# mv redhat-release oracle-release
[root@rac1 etc]# ln -s oracle-release system-release
[root@rac1 etc]# ls -lrt *release*
-rw-r--r--. 1 root root 31 Aug 8 2019 system-release-cpe
-rw-r--r--. 1 root root 452 Aug 8 2019 os-release
-rw-r--r--. 1 root root 52 Aug 8 2019 oracle-release
-rw-r--r-- 1 root root 52 Nov 10 15:03 redhat-release.bak
lrwxrwxrwx 1 root root 14 Nov 10 15:04 system-release -> oracle-release
[root@rac1 etc]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.14.35-1902.3.2.el7uek.x86_64
Found initrd image: /boot/initramfs-4.14.35-1902.3.2.el7uek.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1062.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1062.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-3baf707adafe294dacf813593befdc9a
Found initrd image: /boot/initramfs-0-rescue-3baf707adafe294dacf813593befdc9a.img
done
重启后验证是否关闭
[root@rac1 etc]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
2 开启大页
执行脚本计算大页数量
[root@rac1 ~]# sh hugepage.sh
Press Enter to proceed...
Recommended setting: vm.nr_hugepages = 1302
在/etc/sysctl.conf内增加大页参数
vi /etc/sysctl.conf
vm.nr_hugepages = 1302
[root@rac1 ~]# grep HugePages /proc/meminfo
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
HugePages_Total: 1302
HugePages_Free: 22
HugePages_Rsvd: 1
HugePages_Surp: 0
当然大页多少也可以通过统计算,下面是2.6G,跟脚本计算的差不多,还是推荐使用脚本计算
[root@rac1 ~]# ipcs -m | awk '{print $5}' | awk '{sum+=$1}END{print sum/1024/1024}'
2593.36
相关文章