Shared memory allows an application to allocate a chunk of memory which can be viewed by other processes. Oracle uses shared memory to create the System Global Area (SGA) which all Oracle processes must be able to access.
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.
转载于:https://blog.51cto.com/zhaizhenxing/134481