When an Oracle database starts up, it has to create the System Global Area (SGA) in shared memory. The way Linux allows this is controlled by two critical kernel parameters: SHMMAX and SHMALL.
Misconfigured values are one of the most common reasons for ORA-27102: out of memory errors during database startup. This guide explains exactly what these parameters do, how Oracle uses them, and the practical way to set them correctly.
What are SHMMAX and SHMALL?
- SHMMAX = Maximum size of a single shared memory segment (in bytes)
- SHMALL = Total size of all shared memory segments system-wide (in pages)
[root@ORACLEDBASECRETS01 ~] # cat /proc/sys/kernel/shmmax 536870912 [root@ORACLEDBASECRETS01 ~] # cat /proc/sys/kernel/shmall 1415577
Important: SHMMAX is in bytes, but SHMALL is in pages (usually 4KB each).
How Oracle Uses These Parameters
During database startup, Oracle tries to create the SGA using one of three memory models (in this order):
- One-segment model → Entire SGA in a single shared memory segment (best performance)
- Contiguous multi-segment model → Multiple contiguous segments
- Non-contiguous multi-segment model → Multiple fragmented segments (least efficient)
If SHMMAX > SGA_TARGET → Oracle uses the efficient one-segment model.
If SHMMAX < SGA_TARGET → Oracle falls back to multi-segment models.
Optimal Value for SHMALL
SHMALL should be large enough to hold the sum of all SGA sizes on the server, but it must always be less than physical RAM.
Example: System has 6GB physical RAM
→ Reserve 1GB for OS kernel
→ Dedicate 5GB to Oracle databases
# Step 1: Check page size [root@ORACLEDBASECRETS01 ~] # getconf PAGE_SIZE 4096 # Step 2: Calculate SHMALL (5GB in pages) [root@ORACLEDBASECRETS01 ~] # echo "(5 * 1024 * 1024 * 1024) / 4096" | bc -l 1310720.00000000000000000000
Optimal Value for SHMMAX
Set SHMMAX to the size of the largest SGA on the server (or slightly higher).
Oracle documentation (11g) recommends 4GB – 1 byte or half of physical RAM, whichever is lower.
On 64-bit systems you can safely go higher than 4GB.
Goal: Let Oracle use the one-segment model for best performance.
Configuration Steps
1. Set SHMALL dynamically
[root@ORACLEDBASECRETS01 ~] # echo "1310720" > /proc/sys/kernel/shmall [root@ORACLEDBASECRETS01 ~] # sysctl -p
2. Set SHMMAX dynamically
[root@ORACLEDBASECRETS01 ~] # echo "536870912" > /proc/sys/kernel/shmmax [root@ORACLEDBASECRETS01 ~] # sysctl -p
3. Make changes permanent
[root@ORACLEDBASECRETS01 ~] # echo "kernel.shmall = 1310720" >> /etc/sysctl.conf [root@ORACLEDBASECRETS01 ~] # echo "kernel.shmmax = 536870912" >> /etc/sysctl.conf
4. Enable sysctl on boot (if needed)
[root@ORACLEDBASECRETS01 ~] # chkconfig boot.sysctl on
Verification
[root@ORACLEDBASECRETS01 ~] # sysctl -a | grep -E 'shmmax|shmall' kernel.shmmax = 536870912 kernel.shmall = 1310720 [root@ORACLEDBASECRETS01 ~] # ipcs -lm ------ Shared Memory Limits -------- max number of segments = 4096 max seg size (kbytes) = 524288 /* SHMMAX */ max total shared memory (kbytes) = 5242880 /* SHMALL */
Common Error You Will See
ORA-27102: out of memory
Linux-x86_64 Error: 28: No space left on device.
This usually means SHMALL is too low or you have reached the total shared memory limit on the server.
Key Takeaways
• SHMMAX controls the largest single SGA segment
• SHMALL controls total shared memory available system-wide
• Set SHMMAX > largest SGA_TARGET to get the efficient one-segment model
• SHMALL should be ~ (Physical RAM – 1GB for OS) converted to pages
• Always make changes in /etc/sysctl.conf for persistence
• Verify with ipcs -lm before starting databases
Conclusion
SHMMAX and SHMALL are the foundation of how Oracle allocates SGA on Linux. Setting them correctly prevents startup failures and ensures Oracle can use the most efficient memory model.Spend 10 minutes now to calculate and configure these two parameters properly — it will save you hours of debugging “out of memory” errors later.
Toufique Khan

No comments:
Post a Comment