Thursday, 19 June 2025

Filled under:

 #!/bin/bash


# Oracle HugePages Configuration Helper

# Make sure to run as root


# Estimated SGA in GB (Change if needed)

SGA_GB=128

SGA_MB=$((SGA_GB * 1024))

SGA_KB=$((SGA_MB * 1024))


echo "๐Ÿ” Checking system memory..."

TOTAL_MEM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}')

TOTAL_MEM_GB=$((TOTAL_MEM_KB / 1024 / 1024))

echo "✔️ Total Memory: ${TOTAL_MEM_GB} GB"


echo -e "\n๐Ÿ“ฆ Estimating HugePages needed for ${SGA_GB} GB SGA..."

HP_SIZE_KB=$(grep Hugepagesize /proc/meminfo | awk '{print $2}')

HP_SIZE_MB=$((HP_SIZE_KB / 1024))

REQUIRED_HUGEPAGES=$((SGA_MB / HP_SIZE_MB))

echo "✔️ HugePage Size: ${HP_SIZE_MB} MB"

echo "๐Ÿงฎ Required HugePages: ${REQUIRED_HUGEPAGES}"


echo -e "\n๐Ÿงช Checking current HugePages settings..."

grep Huge /proc/meminfo


echo -e "\n๐Ÿ› ️ Recommended /etc/sysctl.conf entries:"

echo "vm.nr_hugepages = ${REQUIRED_HUGEPAGES}"

echo "kernel.shmmax = $((SGA_GB * 1024 * 1024 * 1024))"

echo "kernel.shmall = $((SGA_KB / 4))  # (SGA / 4KB pages)"


echo -e "\n๐Ÿ› ️ Recommended limits.conf entries for oracle user:"

echo "oracle soft memlock $SGA_KB"

echo "oracle hard memlock $SGA_KB"

echo "oracle soft nofile 65536"

echo "oracle hard nofile 65536"

echo "oracle soft nproc 16384"

echo "oracle hard nproc 16384"


echo -e "\n๐Ÿ” Disable AMM if enabled and use ASMM in Oracle:"

echo "ALTER SYSTEM SET MEMORY_TARGET=0 SCOPE=SPFILE;"

echo "ALTER SYSTEM SET MEMORY_MAX_TARGET=0 SCOPE=SPFILE;"

echo "ALTER SYSTEM SET SGA_MAX_SIZE=${SGA_GB}G SCOPE=SPFILE;"

echo "ALTER SYSTEM SET SGA_TARGET=${SGA_GB}G SCOPE=SPFILE;"


echo -e "\n๐Ÿงน After setting up, reboot the server and verify HugePages are in use."

0 comments:

Post a Comment