Skip to content

semaphore for Oracle Database

April 13, 2010

A semaphore can be thought of as a counter that is used to control access to a shared resource. Semaphores provide low level synchronization between processes (or threads within a process) so that only one process (or thread) has access to the shared segment, thereby ensureing the integrity of that shared resource. When an application requests semaphores, it does so using “sets”.
To determine all semaphore limits, use the following: # ipcs -ls
—— Semaphore Limits ——–
max number of arrays = 128
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 32
semaphore max value = 32767You can also use the following command: # cat /proc/sys/kernel/sem
250 32000 32 128
SEMMSL
The SEMMSL kernel parameter is used to control the maximum number of semaphores per semaphore set.
Oracle recommends setting SEMMSL to the largest PROCESS instance parameter setting in the init.ora file for all databases hosted on the Linux system plus 10. Also, Oracle recommends setting the SEMMSL to a value of no less than 100.
SEMMNI
The SEMMNI kernel parameter is used to control the maximum number of semaphore sets on the entire Linux system.
Oracle recommends setting the SEMMNI to a value of no less than 100.
SEMMNS
The SEMMNS kernel parameter is used to control the maximum number of semaphores (not semaphore sets) on the entire Linux system.
Oracle recommends setting the SEMMNS to the sum of the PROCESSES instance parameter setting for each database on the system, adding the largest PROCESSES twice, and then finally adding 10 for each Oracle database on the system. To summarize: SEMMNS = sum of PROCESSES setting for each database on the system
+ ( 2 * [largest PROCESSES setting])
+ (10 * [number of databases on system]
To determine the maximum number of semaphores that can be allocated on a Linux system, use the following calculation. It will be the lesser of: SEMMNS -or- (SEMMSL * SEMMNI)
SEMOPM
The SEMOPM kernel parameter is used to control the number of semaphore operations that can be performed per semop system call.
The semop system call (function) provides the ability to do operations for multiple semaphores with one semop system call. A semaphore set can have the maximum number of SEMMSL semaphores per semaphore set and is therefore recommended to set SEMOPM equal to SEMMSL.
Oracle recommends setting the SEMOPM to a value of no less than 100.
Setting Semaphore Kernel Parameters
Finally, we see how to set all semaphore parameters using several methods. In the following, the only parameter I care about changing (raising) is SEMOPM. All other default settings should be sufficient for our example installation.
This is method I use most often. This method sets all semaphore kernel parameters on startup by inserting the following kernel parameter in the /etc/sysctl.conf startup file: # echo “kernel.sem=250 32000 100 128” >> /etc/sysctl.conf
If you wanted to dynamically alter the value of all semaphore kernel parameters without rebooting the machine, you can make this change directly to the /proc file system. This command can be made permanent by putting it into the /etc/rc.local startup file: # echo “250 32000 100 128” > /proc/sys/kernel/sem
You can also use the sysctl command to change the value of all semaphore settings: # sysctl -w kernel.sem=”250 32000 100 128″

Advertisements

From → Oracle DBA

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: