內核參數SEMMSL SEMMNS SEMOPM SEMMNI參數的設置
這四個參數自己一直沒搞清楚
今天問了下同事,大概整了一下,后面會再補充。
以下是linux文檔上的說明:
/proc/sys/kernel/sem (since Linux 2.4)
This file contains 4 numbers defining limits for System V IPC semaphores. These fields are, in order:
SEMMSL The maximum semaphores per semaphore set.
SEMMNS A system-wide limit on the number of semaphores in all semaphore sets.
SEMOPM The maximum number of operations that may be specified in a semop(2) call.
SEMMNI A system-wide limit on the maximum number of semaphore identifiers.
semaphore set:信號量集。
semaphore :信號量。
自己根據這個說明,畫了一個圖。

SEMMSL,SEMOPM:設置process+10
SEMMNI:設置為100。這個參數決定了操作系統啟動時初始化信號集的個數。
SEMMNS:SEMMSL*SEMMNI
SEMOPM主要的限制體現在:
1.lgwr寫完之后通知應用進程的過程中,也就是主要影響log file sync(如設置250,一次semops最多可以通知250個應用進程,當應用commit厲害時,semops會大大增加,會到影響系統性能)。
2.發生大規模enqueue lock時,通知等待在此鎖資源上的進程(如果有500個進程等待同一個鎖,則需要進行2次semops調用,來通知等待的進程,鎖可以使用了)。
補充:SEMOPM是一個系統調用,類似的還有semtimedop調用。
可以跟蹤一下oracle的lgwr進程,可以看到秒隔3秒調用一次semtimedop,是一個超時調用,當semtimedop()調用致使lgwr進程進入睡眠,因為logbuffer在空閑的情況下有一個3秒刷一次的機制:
[oracle@fd_perf4 ~]$ ps -ef|grep lgwr
oracle 15341 1934 0 19:49 pts/0 00:00:00 grep lgwr
oracle 15445 1 0 2010 ? 00:14:06 ora_lgwr_fd_perf4
[oracle@fd_perf4 ~]$ strace -p 15445
Process 15445 attached – interrupt to quit
times(NULL) = 2742619382
semtimedop(98304, 0x7fbfffde70, 1, {1, 420000000}) = -1 EAGAIN (Resource temporarily unavailable)
times(NULL) = 2742619524
times(NULL) = 2742619524
times(NULL) = 2742619524
semtimedop(98304, 0x7fbfffde70, 1, {3, 0}) = -1 EAGAIN (Resource temporarily unavailable)
times(NULL) = 2742619824
times(NULL) = 2742619824
getrusage(RUSAGE_SELF, {ru_utime={237, 721860}, ru_stime={608, 380512}, …}) = 0
getrusage(RUSAGE_SELF, {ru_utime={237, 721860}, ru_stime={608, 380512}, …}) = 0
times(NULL) = 2742619824
semtimedop(98304, 0x7fbfffde70, 1, {3, 0}) = -1 EAGAIN (Resource temporarily unavailable)
times(NULL) = 2742620124
times(NULL) = 2742620124
times(NULL) = 2742620124
