Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 修改共享記憶體上限 (shmmax) 優化 Oracle SGA

編輯:Linux 教學

問題背景

Oracle SGA 遠大於預設 kernel.shmmax (32MB),導致 SGA 被切成多段 (ipcs -m 顯示 10 段),嚴重影響效能。

簡易修改法 (免重編核心)

編輯 /etc/rc.d/rc.local (或 /etc/rc.local) 加入:

# 設定共享記憶體最大段為實體記憶體一半
# 256MB RAM → 134217728 (128MB)
# 512MB RAM → 268435456 (256MB)
echo 134217728 > /proc/sys/kernel/shmmax

永久生效 (sysctl.conf)

vi /etc/sysctl.conf
kernel.shmmax = 134217728
kernel.shmall = 32768        # 頁數 = shmmax / PAGE_SIZE (4KB)
sysctl -p

驗證

ipcs -m
# 修改前:Oracle 佔用 10 個共享記憶體段
# 修改後:僅 1 段,SGA 完整駐留單一段,效能顯著提升

補充參數

  • kernel.shmmni:全系統共享記憶體段最大數量 (預設 4096)。
  • kernel.shmmin:最小段大小 (通常 1)。
  • Oracle 官方建議:shmmax >= SGA_MAX_SIZE,shmall >= shmmax/4KB。
Copyright © Windows教程網 All Rights Reserved