Show Table of Contents
Chapter 7. Setting Shared Memory
Shared memory allows processes to access common structures and data by placing them in shared memory segments. It is the fastest form of inter-process communication available since no kernel involvement occurs when data is passed between the processes. In fact, data does not need to be copied between the processes.
Oracle uses shared memory segments for the Shared Global Area (SGA) which is an area of memory that is shared by Oracle processes. The size of the SGA has a significant impact to Oracle's performance since it holds database buffer cache and much more.
To see all shared memory settings, execute:
$ ipcs -lm
7.1. Setting SHMMAX Parameter
This parameter defines the maximum size in bytes of a single shared memory segment that a Linux process can allocate in its virtual address space. For example, if you use the Red Hat Enterprise Linux 3
smpkernel on a 32 bit platform (x86), then the virtual address space for a user process is 3 GB. If you use the Red Hat Enterprise Linux 3
hugememkernel on a 32 bit platform (x86), then the virtual address space for a user process is almost 4GB. Hence, setting
SHMMAXto 4GB - 1 byte (4294967295 bytes) on a smp kernel on a 32 bit architecture will not increase the maximum size of a shared memory segment to 4 GB -1. Even setting
SHMMAXto 4 GB - 1 byte using the
hugememkernel on a 32 bit architecture will not enable a process to get such a large shared memory segment. In fact, the upper limit for a shared memory segment for an Oracle 10g R1 SGA using the
hugememkernel is roughly 3.42 GB (~3.67 billion bytes) since virtual address space is also needed for other things like shared libraries. This means if you have three 2 GB shared memory segments on a 32 bit system, no process can attach to more than one shared memory segment at a time. Also note if you set
SHMMAXto 4294967296 bytes (4*1024*1024*1024=4GB) on a 32 bit system, then
SHMMAXwill essentially bet set to 0 bytes since it wraps around the 4GB value. This means that
SHMMAXshould not exceed 4294967295 on a 32 bit system. On x86-64 platforms,
SHMMAXcan be much larger than 4GB since the virtual address space is not limited by 32 bits.
Since the SGA is comprised of shared memory,
SHMMAXcan potentially limit the size of the SGA.
SHMMAXshould be slightly larger than the SGA size. If
SHMMAXis too small, you can get error messages similar to this one:
ORA-27123: unable to attach to shared memory segment
It is highly recommended that the shared memory fits into the Big Pages or Huge Pages pool, see Chapter 14, Large Memory Optimization, Big Pages, and Huge Pages.
To increase the default maximum SGA size on x86 Red Hat Enterprise Linux 2.1 systems without VLM, refer to Chapter 15, Growing the Oracle SGA to 2.7 GB in x86 Red Hat Enterprise Linux 2.1 Without VLM.
To increase the default maximum SGA size on x86 Red Hat Enterprise Linux 3, 4 and 5 systems without VLM, refer to Chapter 16, Growing the Oracle SGA to 2.7/3.42 GB in x86 Red Hat Enterprise Linux 3, 4 and 5 Without VLM..
To determine the maximum size of a shared memory segment, run:
# cat /proc/sys/kernel/shmmax 2147483648
The default shared memory limit for SHMMAX can be changed in the
procfile system without reboot:
# echo 2147483648 > /proc/sys/kernel/shmmax
Alternatively, you can use
sysctl(8)to change it:
# sysctl -w kernel.shmmax=2147483648
To make a change permanent, add the following line to the file
/etc/sysctl.conf(your setting may vary). This file is used during the boot process.
# echo "kernel.shmmax=2147483648" >> /etc/sysctl.conf