Semaphores act as flags for shared memory.
Semaphores are either set on or off. When an Oracle process accesses
the SGA (in shared memory) it will check for a semaphore for that
portion of memory. If it finds a semaphore set on for that portion of
memory that process will sleep and check again later. If there is no
semaphore set on for that portion of memory it will set one on and
proceed with its operation. When it is done it will switch that
semaphore back to off.
從oracle8.1.5起,oracle在unix/linux平臺提供了一個叫做sysresv的小工具來查看oracle佔用的共享內存段和信號量等系統資源的一些關鍵信息。
[oracle@localhost ~]$ sysresv
sysresv: error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directory
出現該錯誤是由於沒有設置LD_LIBRARY_PATH環境變量,導致無法找到需要的庫文件
sysresv: error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directory
出現該錯誤是由於沒有設置LD_LIBRARY_PATH環境變量,導致無法找到需要的庫文件
[oracle@localhost ~]$ LD_LIBRARY_PATH=$ORACLE_HOME/lib
[oracle@localhost ~]$ export LD_LIBRARY_PATH
[oracle@localhost ~]$ sysresv
[oracle@localhost ~]$ export LD_LIBRARY_PATH
[oracle@localhost ~]$ sysresv
IPC Resources for ORACLE_SID "ning" :
Shared Memory:
ID KEY
458763 0x78b6869c
Semaphores:
ID KEY
98304 0x5ed8a0f0
Oracle Instance alive for sid "ning"
Shared Memory:
ID KEY
458763 0x78b6869c
Semaphores:
ID KEY
98304 0x5ed8a0f0
Oracle Instance alive for sid "ning"
根據上述信息,可以通過ipcs查看sid爲ning的instance具體的共享內存段和信號量信息:
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x78b6869c 458763 oracle 660 243269632 23
key shmid owner perms bytes nattch status
0x78b6869c 458763 oracle 660 243269632 23
------ Semaphore Arrays --------
key semid owner perms nsems
0x5ed8a0f0 98304 oracle 660 154
key semid owner perms nsems
0x5ed8a0f0 98304 oracle 660 154
------ Message Queues --------
key msqid owner perms used-bytes messages
sysresv命令比較簡單,只有幾個不同的option,默認只顯示$ORACLE_SID指定的instance的信息:
key msqid owner perms used-bytes messages
sysresv命令比較簡單,只有幾個不同的option,默認只顯示$ORACLE_SID指定的instance的信息:
usage : sysresv [-if] [-d <on/off>] [-l sid1 <sid2> ...]
-i : Prompt before removing ipc resources for each sid
-f : Remove ipc resources silently, oevrrides -i option
-d <on/off> : List ipc resources for each sid if on
-l sid1 <sid2> .. : apply sysresv to each sid
Default : sysresv -d on -l $ORACLE_SID
Note : ipc resources will be attempted to be deleted for a
sid only if there is no currently running instance
with that sid.
-i : Prompt before removing ipc resources for each sid
-f : Remove ipc resources silently, oevrrides -i option
-d <on/off> : List ipc resources for each sid if on
-l sid1 <sid2> .. : apply sysresv to each sid
Default : sysresv -d on -l $ORACLE_SID
Note : ipc resources will be attempted to be deleted for a
sid only if there is no currently running instance
with that sid.