ORA-27125 Unable to Create Shared Memory Segment - System Resource Guide
ORA-27125: Unable to Create Shared Memory Segment
Section titled “ORA-27125: Unable to Create Shared Memory Segment”Error Overview
Section titled “Error Overview”Error Text: ORA-27125: unable to create shared memory segment
This critical system-level error prevents Oracle database startup by blocking shared memory allocation. ORA-27125 occurs when the Oracle instance cannot create the required shared memory segments due to operating system limitations, configuration issues, or resource constraints.
Understanding Shared Memory in Oracle
Section titled “Understanding Shared Memory in Oracle”Memory Architecture
Section titled “Memory Architecture”Oracle Memory Structure├── System Global Area (SGA)│ ├── Database Buffer Cache│ ├── Shared Pool│ ├── Redo Log Buffer│ └── Large Pool├── Program Global Area (PGA)└── Operating System Shared Memory ├── /dev/shm (Linux) ├── SHMMAX/SHMALL (System V) └── Memory-mapped files
Shared Memory Requirements
Section titled “Shared Memory Requirements”- SGA Size - Configured memory for database instance
- Operating System Limits - Kernel parameters for shared memory
- File System Space - Available space in /dev/shm or similar
- Process Limits - Per-process memory allocation limits
Common Causes
Section titled “Common Causes”1. Insufficient /dev/shm Space (Linux)
Section titled “1. Insufficient /dev/shm Space (Linux)”- /dev/shm filesystem too small for SGA
- Other processes consuming shared memory
- Temporary files in /dev/shm
- Multiple Oracle instances competing for space
2. Operating System Limits
Section titled “2. Operating System Limits”- SHMMAX parameter smaller than required SGA size
- SHMALL parameter limiting total shared memory
- Process memory limits (ulimits)
- System-wide memory constraints
3. Configuration Issues
Section titled “3. Configuration Issues”- SGA_TARGET or MEMORY_TARGET too large
- Automatic Memory Management misconfiguration
- Hugepages configuration conflicts
- SELinux or security restrictions
4. Resource Competition
Section titled “4. Resource Competition”- Multiple Oracle instances on same server
- Other applications using shared memory
- System memory pressure
- Virtual memory exhaustion
Diagnostic Steps
Section titled “Diagnostic Steps”1. Check Current Memory Configuration
Section titled “1. Check Current Memory Configuration”-- Check Oracle memory parametersSELECT name, value, descriptionFROM v$parameterWHERE name IN ( 'sga_target', 'memory_target', 'memory_max_target', 'pga_aggregate_target', 'shared_pool_size', 'db_cache_size', 'java_pool_size', 'large_pool_size')ORDER BY name;
-- Check actual SGA allocationSELECT name, ROUND(value/1024/1024, 2) as size_mb, ROUND(value/1024/1024/1024, 2) as size_gbFROM v$sgaORDER BY value DESC;
-- Memory allocation summarySELECT ROUND(SUM(value)/1024/1024/1024, 2) as total_sga_gbFROM v$sga;
2. Check Operating System Limits (Linux)
Section titled “2. Check Operating System Limits (Linux)”# Check /dev/shm filesystemdf -h /dev/shmmount | grep shm
# Check system shared memory limitsipcs -lm
# Check current shared memory usageipcs -m
# Check kernel parameterssysctl -a | grep shmcat /proc/sys/kernel/shmmaxcat /proc/sys/kernel/shmallcat /proc/sys/kernel/shmmni
# Check process limitsulimit -a
# Check available memoryfree -hcat /proc/meminfo | grep -E "(MemTotal|MemFree|MemAvailable)"
3. Check System Resources
Section titled “3. Check System Resources”# Check memory pressurevmstat 1 5sar -r 1 5
# Check for memory-intensive processesps aux --sort=-%mem | head -20
# Check for Oracle processes already runningps -ef | grep oracleps -ef | grep smon
# Check system logs for memory-related errorsdmesg | grep -i memoryjournalctl -u oracle-* | grep -i memory
4. Analyze Error Details
Section titled “4. Analyze Error Details”# Check Oracle alert log for specific error detailstail -n 100 $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace/alert_$ORACLE_SID.log
# Look for specific error patterns:# - Cannot create shared memory segment# - SHMGET failed# - Not enough space# - Permission denied
# Check trace files for additional detailsls -la $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace/*.trc
Immediate Solutions
Section titled “Immediate Solutions”Solution 1: Increase /dev/shm Size (Linux)
Section titled “Solution 1: Increase /dev/shm Size (Linux)”Resize /dev/shm Temporarily
Section titled “Resize /dev/shm Temporarily”# Check current sizedf -h /dev/shm
# Calculate required size (SGA + overhead)# Recommended: (SGA_SIZE * 1.2) + 1GB for overhead
# Resize /dev/shm (requires root)sudo mount -o remount,size=16G /dev/shm
# Verify new sizedf -h /dev/shm
Make /dev/shm Resize Permanent
Section titled “Make /dev/shm Resize Permanent”# Edit /etc/fstab (requires root)sudo vi /etc/fstab
# Add or modify the line:tmpfs /dev/shm tmpfs defaults,size=16G 0 0
# Or modify existing line:# tmpfs /dev/shm tmpfs defaults,nodev,nosuid,noexec,size=16G 0 0
# Test the configurationsudo mount -o remount /dev/shmdf -h /dev/shm
Solution 2: Adjust Kernel Shared Memory Parameters
Section titled “Solution 2: Adjust Kernel Shared Memory Parameters”Check and Set SHMMAX
Section titled “Check and Set SHMMAX”# Check current SHMMAX (maximum shared memory segment size)cat /proc/sys/kernel/shmmax
# Calculate required SHMMAX (should be >= SGA size)# For SGA of 12GB: 12 * 1024 * 1024 * 1024 = 12884901888
# Set SHMMAX temporarilysudo sysctl -w kernel.shmmax=12884901888
# Verify settingcat /proc/sys/kernel/shmmax
Check and Set SHMALL
Section titled “Check and Set SHMALL”# Check current SHMALL (total shared memory pages)cat /proc/sys/kernel/shmall
# Get page sizegetconf PAGE_SIZE
# Calculate required SHMALL# SHMALL = (Total shared memory needed) / PAGE_SIZE# For 16GB total: 16 * 1024^3 / 4096 = 4194304
# Set SHMALL temporarilysudo sysctl -w kernel.shmall=4194304
# Verify settingcat /proc/sys/kernel/shmall
Make Kernel Parameters Permanent
Section titled “Make Kernel Parameters Permanent”# Edit sysctl configurationsudo vi /etc/sysctl.conf
# Add these lines:kernel.shmmax = 12884901888kernel.shmall = 4194304kernel.shmmni = 4096
# Apply the configurationsudo sysctl -p
# Verify all settingssysctl -a | grep shm
Solution 3: Reduce Oracle Memory Configuration
Section titled “Solution 3: Reduce Oracle Memory Configuration”Lower SGA_TARGET
Section titled “Lower SGA_TARGET”-- Connect as SYSDBA to adjust memory parametersCONNECT / AS SYSDBA
-- Check current memory settingsSHOW PARAMETER memory_target;SHOW PARAMETER sga_target;
-- Reduce memory allocation (adjust based on available system memory)-- Example: Reduce from 12GB to 8GBALTER SYSTEM SET sga_target = 8G SCOPE = SPFILE;ALTER SYSTEM SET memory_target = 10G SCOPE = SPFILE;
-- Alternative: Disable automatic memory managementALTER SYSTEM SET memory_target = 0 SCOPE = SPFILE;ALTER SYSTEM SET sga_target = 8G SCOPE = SPFILE;ALTER SYSTEM SET pga_aggregate_target = 2G SCOPE = SPFILE;
-- Restart database for changes to take effectSHUTDOWN IMMEDIATE;STARTUP;
Manual Memory Component Sizing
Section titled “Manual Memory Component Sizing”-- Disable automatic memory management and set individual componentsALTER SYSTEM SET memory_target = 0 SCOPE = SPFILE;ALTER SYSTEM SET sga_target = 0 SCOPE = SPFILE;
-- Set individual SGA componentsALTER SYSTEM SET shared_pool_size = 1G SCOPE = SPFILE;ALTER SYSTEM SET db_cache_size = 4G SCOPE = SPFILE;ALTER SYSTEM SET large_pool_size = 512M SCOPE = SPFILE;ALTER SYSTEM SET java_pool_size = 256M SCOPE = SPFILE;ALTER SYSTEM SET log_buffer = 64M SCOPE = SPFILE;
-- Set PGAALTER SYSTEM SET pga_aggregate_target = 2G SCOPE = SPFILE;
-- Restart databaseSHUTDOWN IMMEDIATE;STARTUP;
Long-Term Solutions
Section titled “Long-Term Solutions”1. System Configuration Optimization
Section titled “1. System Configuration Optimization”Configure Hugepages (Linux)
Section titled “Configure Hugepages (Linux)”# Calculate required hugepages# Hugepage size (usually 2MB)grep Hugepagesize /proc/meminfo
# Calculate pages needed: SGA_SIZE / Hugepage_size# For 8GB SGA with 2MB hugepages: 8192MB / 2MB = 4096 pages
# Set hugepages temporarilysudo sysctl -w vm.nr_hugepages=4096
# Check hugepage allocationcat /proc/meminfo | grep -i huge
# Make permanentsudo vi /etc/sysctl.conf# Add: vm.nr_hugepages = 4096
# Configure Oracle to use hugepagesALTER SYSTEM SET use_large_pages = TRUE SCOPE = SPFILE;
Memory Overcommit Configuration
Section titled “Memory Overcommit Configuration”# Check current overcommit settingscat /proc/sys/vm/overcommit_memorycat /proc/sys/vm/overcommit_ratio
# Set conservative overcommit (recommended for Oracle)sudo sysctl -w vm.overcommit_memory=2sudo sysctl -w vm.overcommit_ratio=80
# Make permanentsudo vi /etc/sysctl.conf# Add:# vm.overcommit_memory = 2# vm.overcommit_ratio = 80
2. Container and Cloud Environments
Section titled “2. Container and Cloud Environments”Docker Configuration
Section titled “Docker Configuration”# Dockerfile for Oracle containerFROM oracle/database:19.3.0-ee
# Configure shared memoryRUN echo "tmpfs /dev/shm tmpfs defaults,size=8G 0 0" >> /etc/fstab
# Set kernel parametersRUN echo "kernel.shmmax = 8589934592" >> /etc/sysctl.confRUN echo "kernel.shmall = 2097152" >> /etc/sysctl.conf
# Run container with increased shared memorydocker run -d \ --name oracle-db \ --shm-size=8g \ -e ORACLE_SID=ORCL \ -e ORACLE_PDB=PDB1 \ -e ORACLE_PWD=YourPassword \ oracle/database:19.3.0-ee
# Kubernetes deployment with shared memoryapiVersion: v1kind: Podspec: containers: - name: oracle image: oracle/database:19.3.0-ee resources: requests: memory: "12Gi" limits: memory: "16Gi" volumeMounts: - name: dshm mountPath: /dev/shm volumes: - name: dshm emptyDir: medium: Memory sizeLimit: 8Gi
Cloud Instance Optimization
Section titled “Cloud Instance Optimization”# AWS EC2 instance configuration# Ensure sufficient memory for instance type# r5.2xlarge: 64GB RAM (good for 32GB+ Oracle workloads)# r5.4xlarge: 128GB RAM (good for 64GB+ Oracle workloads)
# Check instance memoryfree -hlscpu
# Monitor memory usage during startupwatch -n 1 'free -h && echo "--- SHM ---" && df -h /dev/shm'
Prevention Strategies
Section titled “Prevention Strategies”1. Capacity Planning
Section titled “1. Capacity Planning”# Create memory assessment script#!/bin/bashecho "=== System Memory Assessment ==="echo "Total Memory: $(grep MemTotal /proc/meminfo)"echo "Available Memory: $(grep MemAvailable /proc/meminfo)"echo ""
echo "=== Shared Memory Limits ==="echo "SHMMAX: $(cat /proc/sys/kernel/shmmax) bytes"echo "SHMALL: $(cat /proc/sys/kernel/shmall) pages"echo "Page Size: $(getconf PAGE_SIZE) bytes"echo ""
echo "=== /dev/shm Status ==="df -h /dev/shmecho ""
echo "=== Current Shared Memory Usage ==="ipcs -m -uecho ""
echo "=== Hugepages ==="grep -i huge /proc/meminfoecho ""
echo "=== Memory Recommendations ==="TOTAL_MEM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}')TOTAL_MEM_GB=$((TOTAL_MEM_KB / 1024 / 1024))RECOMMENDED_SGA_GB=$((TOTAL_MEM_GB * 60 / 100))
echo "Total System Memory: ${TOTAL_MEM_GB}GB"echo "Recommended max SGA: ${RECOMMENDED_SGA_GB}GB (60% of total)"echo "Recommended /dev/shm: $((RECOMMENDED_SGA_GB + 2))GB"
2. Monitoring Setup
Section titled “2. Monitoring Setup”-- Create memory monitoring procedureCREATE OR REPLACE PROCEDURE monitor_memory_usage AS v_sga_size NUMBER; v_pga_size NUMBER; v_total_memory NUMBER;BEGIN -- Get SGA size SELECT SUM(value) INTO v_sga_size FROM v$sga;
-- Get PGA size SELECT value INTO v_pga_size FROM v$pgastat WHERE name = 'total PGA allocated';
v_total_memory := v_sga_size + v_pga_size;
-- Log memory usage INSERT INTO memory_usage_log ( log_time, sga_size_mb, pga_size_mb, total_memory_mb ) VALUES ( SYSTIMESTAMP, ROUND(v_sga_size/1024/1024, 2), ROUND(v_pga_size/1024/1024, 2), ROUND(v_total_memory/1024/1024, 2) );
COMMIT;
-- Alert if memory usage is high IF v_total_memory > 32 * 1024 * 1024 * 1024 THEN -- 32GB threshold DBMS_OUTPUT.PUT_LINE('WARNING: High memory usage detected'); END IF;END;/
-- Create monitoring tableCREATE TABLE memory_usage_log ( log_time TIMESTAMP, sga_size_mb NUMBER, pga_size_mb NUMBER, total_memory_mb NUMBER);
3. Automated System Checks
Section titled “3. Automated System Checks”#!/bin/bash# oracle_memory_check.sh - Pre-startup validation
ORACLE_SID=${1:-ORCL}REQUIRED_SGA_GB=${2:-8}
echo "Checking memory requirements for Oracle instance $ORACLE_SID"echo "Required SGA size: ${REQUIRED_SGA_GB}GB"
# Check /dev/shm spaceSHM_AVAILABLE_GB=$(df /dev/shm | awk 'NR==2 {print int($4/1024/1024)}')echo "Available /dev/shm space: ${SHM_AVAILABLE_GB}GB"
if [ $SHM_AVAILABLE_GB -lt $REQUIRED_SGA_GB ]; then echo "ERROR: Insufficient /dev/shm space" echo "Required: ${REQUIRED_SGA_GB}GB, Available: ${SHM_AVAILABLE_GB}GB" exit 1fi
# Check SHMMAXSHMMAX_GB=$(echo "$(cat /proc/sys/kernel/shmmax) / 1024 / 1024 / 1024" | bc)echo "SHMMAX: ${SHMMAX_GB}GB"
if [ $SHMMAX_GB -lt $REQUIRED_SGA_GB ]; then echo "ERROR: SHMMAX too small" echo "Required: ${REQUIRED_SGA_GB}GB, Current: ${SHMMAX_GB}GB" exit 1fi
# Check system memoryTOTAL_MEM_GB=$(free -g | awk 'NR==2{print $2}')echo "Total system memory: ${TOTAL_MEM_GB}GB"
if [ $TOTAL_MEM_GB -lt $((REQUIRED_SGA_GB * 2)) ]; then echo "WARNING: System memory may be insufficient" echo "Recommended: $((REQUIRED_SGA_GB * 2))GB, Available: ${TOTAL_MEM_GB}GB"fi
echo "Memory check completed successfully"
Related Errors
Section titled “Related Errors”- ORA-00845 - MEMORY_TARGET not supported on this system
- ORA-04031 - Unable to allocate shared memory
- ORA-27102 - Out of memory (not documented yet)
- ORA-00600 - Internal error (when memory corruption occurs)
Emergency Response
Section titled “Emergency Response”Quick Resolution Checklist
Section titled “Quick Resolution Checklist”-
Check available space
Terminal window df -h /dev/shmfree -h -
Increase /dev/shm temporarily
Terminal window sudo mount -o remount,size=16G /dev/shm -
Check and adjust kernel parameters
Terminal window sudo sysctl -w kernel.shmmax=17179869184 # 16GBsudo sysctl -w kernel.shmall=4194304 -
Reduce Oracle memory if needed
ALTER SYSTEM SET sga_target = 8G SCOPE = SPFILE; -
Restart database
STARTUP;
Quick Reference Commands
Section titled “Quick Reference Commands”# Memory diagnosticsdf -h /dev/shmcat /proc/sys/kernel/shmmaxcat /proc/sys/kernel/shmallfree -h
# Increase shared memory limitssudo sysctl -w kernel.shmmax=17179869184sudo sysctl -w kernel.shmall=4194304sudo mount -o remount,size=16G /dev/shm
# Oracle memory adjustmentsqlplus / as sysdbaALTER SYSTEM SET sga_target = 8G SCOPE = SPFILE;STARTUP;
System Configuration Template
Section titled “System Configuration Template”# /etc/sysctl.conf additions for Oracle# Shared memory settingskernel.shmmax = 17179869184 # 16GBkernel.shmall = 4194304 # 16GB in pageskernel.shmmni = 4096 # Max shared memory segments
# Memory managementvm.overcommit_memory = 2vm.overcommit_ratio = 80vm.nr_hugepages = 8192 # For 16GB hugepages
# /etc/fstab addition for /dev/shmtmpfs /dev/shm tmpfs defaults,size=20G 0 0