Enable HugePages RHEL 7/OL 7 within Oracle Database 12c

This article explains how to set up the HugePage on Linux (RedHat 7, Oracle Linux 7 et CentOS 7) within the Oracle database 12c by enabling the use of the very large page sizes witch can improve system performance by reducing the amount of system resources required to access page table entries.

Plan:

1. HugePages

2. Transparent Huge Pages: Overview

3. Enable the HugePage on Linux

4. Oracle database 12 with HugePAges

 

1. HugePages:

1.1. Overview

Enabling HugePages makes it possible for the operating system to support memory pages greater than the default (usually 4 KB). For Oracle Databases, using HugePages reduces the operating system maintenance of page states, and increases Translation Lookaside Buffer (TLB) hit ratio. for more info.

Check the use and the size of the system HugePage:

hugepage-size-upload

 

 

Note: In my server, the size of the HugePage is 2048K.

1.2. Restrictions:

HugePages has the following limitations:

You must UNSET the AMM. When Oracle Database allocates SGA with AMM, HugePages are not reserved. To use HugePages on Oracle Database 12c, You must disable AMM.

1.3. Configuration:

Note: In my Server, the size of the HugePage is 2048K.

Note: The size of the SGA is about 400M, so we need at least about 200 HugePages.

For further utilisation, I am going to set up 500 pages in this article.

Edit the memlock setting in the /etc/security/limits.conf file. The memlock setting is specified in KB, and the maximum locked memory limit should be set to at least 90 percent of the current RAM when HugePages memory is enabled.

Note: memlock = 500*2048 = 1024000 KB

Add the memlock security parameter in this file: /etc/security/limits.conf

*   soft   memlock    1024000 
*   hard   memlock    1024000

 

2. Transparent Huge Pages: Overview

Transparent huge pages (THP) automatically optimize system settings for performance. By allowing all free memory to be used as cache, performance is increased.

Note (From Oracle): Transparent HugePages can cause memory allocation delays at runtime. To avoid performance issues, Oracle recommends that you disable .

# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

To disable the use of Transparent HugePage:

# echo never > /sys/kernel/mm/transparent_hugepage/enabled

3. Enable the HugePage on Linux:

Enable the HugePage on Linux 3.x kernel version (CentOS 7, RedHat 7 & ORacle Linux 7) with two solutions:

Note: In this configuration, we are going to use 500 HugePages.

Solution 1: Use the kernel parameter nr_hugepages:

echo 500 > /proc/sys/vm/nr_hugepages

For permanent use:

root@db12c ~]# sysctl -w "vm.nr_hugepages=600"
vm.nr_hugepages = 500
root@db12c ~]# sysctl -w "vm.nr_hugepages=500"  >> /etc/sysctl.conf

Solution 2: Use the hugepages parameter kernel grub.

# 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="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet transparent_hugepage=never hugepages=512"
GRUB_DISABLE_RECOVERY="true

Re-generate the GRUB configuration file.

# 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-2a613b27f9c249b293abc54bde50566f
Found initrd image: /boot/initramfs-0-rescue-2a613b27f9c249b293abc54bde50566f.img
done
[root@db12c ~]#

 

4. Oracle database 12c  with HugePAges:

To use HugePages on Oracle Database 12c, You must disable AMM and we are going to enable the ASMM.

Note: With AMM, the use ofthe shared memory under /dev/shm

df-h-before-upload

 

 

 

 

Diable the AMM by unset both the MEMORY_TARGET and MEMORY_MAX_TARGET initialization parameters

alter system set memory_max_target=0 scope=spfile;
alter system set memory_target=0 scope=spfile;

Enable ASMM (in my case, the memory size of the SGA is about 400M and the total PGA is about 100M)

alter system set sga_max_size=400M scope=spfile;
alter system set sga_target=400M scope=spfile;
alter system set pga_aggregate_target=100M scope=spfile;

Note: By default the initialisation parameter use_large_pages is true: so the use of large pages of Oracle database is enabled.

With the ASMM & HugePage:

Note 1: unset the use of the shared memory.

df-h-after-upload

 

 

 

 

 

Note 2: The use of the HugePages within Oracle database 12c from logfile.

logfile-2m-upload

 

 

 

 

Conclusion:

the use of the very large page sizes witch can improve system performance by reducing the amount of system resources required to access page table entries.

 

 

Share it now!
Bookmark the permalink.
Loading Facebook Comments ...

Leave a Reply