SHMMAX and SHMALL parameters
QUESTION 1
===========
What is the maximum value of SHMMAX for a 32-bit (x86) Linux system?
Oracle Global Customer Support officially recommends a " maximum" for SHMMAX of just less than 4Gb, or 4294967295.
The maximum size of a shared memory segment is limited by the size of the available user address space. On 32-bit systems, this is a theoretical 4GB. The maximum possible value for SHMMAX is just less than 4Gb, or 4294967295. Setting SHMMAX to 4GB exactly will give you 0 bytes as max, as this value is interpreted as a 32-bit number and it wraps around.
QUESTION 2
===========
What is the maximum value of SHMMAX for a 64-bit (x86-64) Linux system?
Oracle Global Customer Support officially recommends a " maximum" for SHMMAX of "1/2 of physical RAM".
System Parameters
SHMMAX - kernel parameter controlling maximum size of one shared memory segment
SHMMNI - kernel parameter controlling maximum number of shared memory segments in the system
SHMSEG - kernel parameter controlling maximum number of shared memory segments a process can attach
SEMMNS - kernel parameter controlling maximum number of semaphores in the system
SEMMNI - kernel parameter controlling maximum number of semaphore sets. Semaphores in Unix are allocated in sets of 1 to SEMMSL.
SEMMSL - kernel parameter controlling maximum number of semaphores in a semaphore set.
SHMLBA - kernel parameter controlling alignment of shared memory segments; all segments must be attached at multiples of this value.
Typically, non-tunable.
SHMMAX is the maximum size of a single shared memory segment set in "bytes"
[root@ip-10.1.1.1.1 ~]# cat /proc/sys/kernel/shmmax
18446744073692774399
[root@ip-10.1.1.1.1 ~]#
SHMALL is the total size of Shared Memory Segments System wide set in "pages".
[root@ip-10.1.1.1.1 ~]# cat /proc/sys/kernel/shmall
18446744073692774399
[root@ip-10.1.1.1.1 ~]#
The key thing to note here is the value of SHMMAX is set in “bytes” but the value of SHMMALL is set in “pages”.
As SHMALL is the total size of Shard Memory Segments System wide, it should always be less than the Physical Memory on the System and should be greater than sum of SGA’s of all the oracle databases on the server. Once this value (sum of SGA’s) hit the limit, i.e. the value of shmall, then any attempt to start a new database (or even an existing database with a resized SGA) will result in an “out of memory” error (below). This is because there won’t be any more shared memory segments that Linux can allocate for SGA.
ORA-27102: out of memory
Linux-x86_64 Error: 28: No space left on device.
Setting the value for SHMALL to optimal is straight forward. All you want to know is how much “Physical Memory” (excluding Cache/Swap) you have on the system and how much of it should be set aside for Linux Kernel and to be dedicated to Oracle Databases
example
[root@ip-10.1.1.1.1 ~]# free -g
total used free shared buff/cache available
Mem: 7 0 5 0 1 7
Swap: 0 0 0
[root@ip-10.1.1.1.1 ~]#
Let say the Physical Memory of a system is 7GB, out of which you want to set aside 2GB for Linux Kernel for OS Operations and dedicate the rest of 5GB to Oracle Databases. Then here’s how you will get the value for SHMALL.
[root@ip-10.1.1.1.1 ~]# getconf PAGE_SIZE
4096
[root@ip-10.1.1.1.1 ~]#
or
[root@ip-10.1.1.1.1 ~]# cat /proc/sys/kernel/shmmni
4096
[root@ip-10.1.1.1.1 ~]#
Convert 5GB into bytes and divide by page size
5gb = 5*1024*1024*1024 = 5,368,709,120 bytes /4096
= 1310720
[root@ip-10.1.1.1.1 ~]# ipcs -lm
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 18014398509465599
max total shared memory (kbytes) = 18446744073709551612
min seg size (bytes) = 1
What’s the optimal value for SHMMAX?
Oracle makes use of one of the 3 memory management models to create the SGA during database startup and it does this in following sequence. First Oracle attempts to use the one-segment model and if this fails, it proceeds with the next one which’s the contiguous multi-segment model and if that fails too, it goes with the last option which is the non-contiguous multi-segment model.
So let’s say if you know the max size of SGA of any database on the server stays below 2GB, you can set shmmax to 2 GB. But say if you have SGA sizes for different databases spread between 512MB to 5GB, then set shmmax to 5Gigs and so on.
Half the size of physical memory in bytes
SHMMNI: parameter recommended as 4096.
SHMALL: parameter recommended as %40 size of physical memory in pages.