Home > Workload Solutions > Oracle > Best Practices > Intel-Based Oracle Best Practices on Dell PowerEdge R750xs and PowerStore 5000T > Consolidated Best Practices > Red Hat Enterprise Linux: HugePages
In this best practice we used Oracle scripts to implement HugePages in the Linux operating system.
Overview
The Linux operating system default memory page size is 4 KB. While this size works well for many applications, the Oracle Shared Global Area (SGA) memory pool can be very large. The memory size of the SGA is large because it supports other components, like the database buffer cache, shared pool, large pool, and many other memory pools. Management of the SGA using 4 KB memory pages can cause excessive processing and wait times to access memory pages.
HugePages is a feature that is integrated into the Linux kernel 2.6. Enabling HugePages allows the operating system to support memory pages that are larger than the default. Using very large page sizes can improve system performance by reducing the amount of system resources required to access page table entries. For Oracle Databases, using HugePages reduces the operating system maintenance of page states, and increases TLB hit ratio. Oracle recommends using HugePages on Linux platform installations to obtain the best performance for Oracle Databases.
Implementation Steps
To enable the HugePages, complete the following steps:
# grep Huge /proc/meminfo
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
2. Edit memlock setting in /etc/security/limits.conf. 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. For example, if the server RAM size is 128GB, the memlock can be set 128GB * 90% = 120,795,955 KB and add the following lines into this file:
* soft memlock 120,795,955
* hard memlock 120,795,955
3. Log in as oracle user again and run the ulimit -l command to verify the new memlock setting:
$ ulimit -l
120795955
4. As root user, create a “hugepages_settings.sh” script provided by Oracle that computes the recommended values for HugePages configuration for the current shared memory segments:
!/bin/bash
#
# hugepages_settings.sh
#
# Linux bash script to compute values for the
# recommended HugePages/HugeTLB configuration
#
# Note: This script does calculation for all shared memory
# segments available when the script is run, no matter it
# is an Oracle RDBMS shared memory segment or not.
# Check for the kernel version
KERN=`uname -r | awk -F. '{ printf("%d.%d\n",$1,$2); }'`
# Find out the HugePage size
HPG_SZ=`grep Hugepagesize /proc/meminfo | awk {'print $2'}`
# Start from 1 pages to be on the safe side and guarantee 1 free HugePage
NUM_PG=1
# Cumulative number of pages required to handle the running shared memory segments
for SEG_BYTES in `ipcs -m | awk {'print $5'} | grep "[0-9][0-9]*"`
do
MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
if [ $MIN_PG -gt 0 ]; then
NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
fi
done
# Finish with results
case $KERN in
'2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
'2.6'|'3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
*) echo "Unrecognized kernel version $KERN. Exiting." ;;
esac
# End
5. Provide the execute permission of this script.
# chmod +x hugepages_settings.sh
And execute this script to get the values for hugepages configuration:
# ./hugepages_settings.sh
6. Set the following kernel parameter in the /etc/sysctl.conf file, where value is the HugePages value that you determined in step 5:
vm.nr_hugepages=value
7. Load the parameter:
# sysctl -p
8. Check the available HugePages
# grep Huge /proc/meminfo
Additional Resources
Oracle® Database Administrator's Reference: 19c for Linux and UNIX System-Based Operating Systems