How to Setting Oracle Huagepages Parameters

Oracle Database - Enterprise Edition - version 11.2.0.4.0

  • memlock: KB, At least 90 percent of the current RAM when HugePages memory is enabled and at least 3145728 KB (3 GB) when HugePages memory is disabled.

  • kernel.shmmax: Byte, This parameter defines the maximum size in bytes of a single shared memory segment that a Linux process can allocate in its virtual address space. Recommended half the size of physical memory in bytes.

  • kernel.shmall: This parameter sets the total amount of shared memory pages that can be used system wide for SGA. Hence, it should always be at least ceil(SHMMAX / PAGESIZE).

  • vm.nr_hugepages: value = TotalSharedMemory / Hugepagesize

Example

physical memory: 12288 MB
sga_target: 6144 MB
pga_aggregate_target: 2048 MB

MemTotal:

~]# grep MemTotal /proc/meminfo
MemTotal: 12077768 kB

~]# free -k
total used free shared buff/cache available
Mem: 12077768 9707116 533356 221304 1837296 1843296
Swap: 8278012 2460812 5817200

~]# ipcs -m | grep 0x | awk '{sum+=$5} END{print sum/1024/2048}'

Script: get_oracle_hugepages.sh

#!/bin/bash

# Find out the Page size
PG_SIZE=`getconf PAGESIZE`

# Find out the HugePage size
HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
if [[ -z "$HPG_SZ" ]]; then
echo "The hugepages may not be supported in the system where the script is being executed."
exit 1
fi

# Initialize the counter
NUM_PG=0

read -p 'Please input sga_target expect value (GB): ' SGA_SIZE
MEM_LOCK=`free -k | awk '/Mem/ {printf "%d\n",$2*0.9+1}'`
SGE_MAX_BYTES=`free -b | awk '/Mem/ {printf "%d\n",$2*0.5+1}'`
ALL_SGES=`echo "($SGA_SIZE+1)*1024*1024*1024/$PG_SIZE" | bc -q`
NUM_PG=`echo "($SGA_SIZE+1)*1024*1024/$HPG_SZ" | bc -q`
echo "memlock = $MEM_LOCK"
echo "shmmax = $SGE_MAX_BYTES"
echo "shmall = $ALL_SGES"
echo "nr_hugepages = $NUM_PG"

Output:

Please input sga_target expect value (GB): 6
memlock = 10869992
shmmax = 6183817217
shmall = 1835008
nr_hugepages = 3584