#!/bin/bash
SGA_GB=128
SGA_MB=$((SGA_GB * 1024))
SGA_KB=$((SGA_MB * 1024))
echo "š Oracle SGA Feasibility + Recommendation (Target: ${SGA_GB} GB)"
echo "-------------------------------------------------------------"
# Get system memory
TOTAL_MEM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}')
TOTAL_MEM_GB=$((TOTAL_MEM_KB / 1024 / 1024))
echo "š§ Total Physical Memory: ${TOTAL_MEM_GB} GB"
# Get HugePages info
HP_SIZE_KB=$(grep Hugepagesize /proc/meminfo | awk '{print $2}')
HP_TOTAL=$(grep HugePages_Total /proc/meminfo | awk '{print $2}')
HP_FREE=$(grep HugePages_Free /proc/meminfo | awk '{print $2}')
HP_RSVD=$(grep HugePages_Rsvd /proc/meminfo | awk '{print $2}')
HP_USED=$((HP_TOTAL - HP_FREE))
# Required HugePages
REQUIRED_HUGEPAGES=$((SGA_KB / HP_SIZE_KB))
HP_TOTAL_KB=$((HP_TOTAL * HP_SIZE_KB))
HP_FREE_KB=$((HP_FREE * HP_SIZE_KB))
# Print HugePages summary
echo "š¦ HugePage Size: $((HP_SIZE_KB / 1024)) MB"
echo "š¦ HugePages Configured: ${HP_TOTAL} (${HP_TOTAL_KB} KB)"
echo "š¦ HugePages Free: ${HP_FREE} (${HP_FREE_KB} KB)"
echo "š Required HugePages for ${SGA_GB} GB SGA: ${REQUIRED_HUGEPAGES}"
echo "-------------------------------------------------------------"
# Evaluation
if [ "$TOTAL_MEM_KB" -lt "$((SGA_KB + 10485760))" ]; then
echo "❌ ERROR: Not enough physical memory for ${SGA_GB} GB SGA + OS overhead."
exit 1
fi
if [ "$HP_TOTAL" -lt "$REQUIRED_HUGEPAGES" ]; then
echo "❌ ERROR: HugePages configured are less than required."
echo "➡️ You need at least $REQUIRED_HUGEPAGES HugePages."
echo -e "\nš ️ Suggested /etc/sysctl.conf settings:"
echo "vm.nr_hugepages = ${REQUIRED_HUGEPAGES}"
echo "kernel.shmmax = $((SGA_GB * 1024 * 1024 * 1024))"
echo "kernel.shmall = $((SGA_KB / 4)) # (SGA / 4KB)"
echo -e "\nš ️ Suggested /etc/security/limits.conf for oracle:"
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⚠️ Don't forget to disable MEMORY_TARGET and MEMORY_MAX_TARGET 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 "➡️ Then restart the DB."
exit 1
fi
if [ "$HP_FREE" -lt "$REQUIRED_HUGEPAGES" ]; then
echo "⚠️ WARNING: Not enough HugePages FREE at the moment."
echo "➡️ You may need to stop other Oracle instances or reboot the system."
exit 1
fi
echo "✅ YES: Server is READY for ${SGA_GB} GB SGA allocation using HugePages!"
exit 0





0 comments:
Post a Comment