我们可能都知道在$ORACLE_HOME/bin,存在很多小工具,今天主要介绍一下工具sysresv,通过该工具我们查看实例对应的内存共享段,以及删除内存共享段
当我们的系统运行有多个实例时:
引用
[root@hzmc ~]# ps -ef|grep smon|grep -v grep
ora10g 13422 1 0 Mar16 ? 00:00:00 ora_smon_mcactive
ora10g 25249 1 0 Mar16 ? 00:00:00 ora_smon_mcstar
ora10g 31000 1 0 Mar14 ? 00:01:21 ora_smon_drb
如果要清除某个实例的信号量,仅仅通过ipcs命令查看是远远不够的,它只会列出Oracle使用的内存共享段
引用
[root@hzmc ~]# ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 32768 gdm 600 393216 2 dest
0x366d0098 491521 ora10g 640 314576896 23
0x8f92b47c 2686978 ora10g 640 532684800 20
0x4566f728 2490371 ora10g 640 532684800 148
------ Semaphore Arrays --------
key semid owner perms nsems
0x64466970 1802240 ora10g 640 154
0x3ea594ac 10584065 ora10g 640 154
0xaf45a9f8 9797634 ora10g 640 154
------ Message Queues --------
key msqid owner perms used-bytes messages
如果使用sysresv工具,可以清楚地知道实例所对应的共享段:
引用
[root@hzmc ~]# su - ora10g
[ora10g@hzmc ~]$ cd $ORACLE_HOME/bin
[ora10g@hzmc bin]$ sysresv -l mcactive mcstar drb
IPC Resources for ORACLE_SID "mcactive" :
Shared Memory:
ID KEY
2490371 0x4566f728
Semaphores:
ID KEY
9797634 0xaf45a9f8
Oracle Instance alive for sid "mcactive"
IPC Resources for ORACLE_SID "mcstar" :
Shared Memory:
ID KEY
2686978 0x8f92b47c
Semaphores:
ID KEY
10584065 0x3ea594ac
Oracle Instance alive for sid "mcstar"
IPC Resources for ORACLE_SID "drb" :
Shared Memory:
ID KEY
491521 0x366d0098
Semaphores:
ID KEY
1802240 0x64466970
Oracle Instance alive for sid "drb"
如果更进一步,我们可以通过strings提取sysresv的用法:
引用
[ora10g@hzmc bin]$ strings sysresv
/lib/ld-linux.so.2
。。。
Note : ipc resources will be attempted to be deleted for a
sid only if there is no currently running instance
with that sid.
usage : sysresv [-if] [-d ] [-l sid1 ...]
-i : Prompt before removing ipc resources for each sid
-f : Remove ipc resources silently, oevrrides -i option
-d : List ipc resources for each sid if on
-l sid1 .. : apply sysresv to each sid
Default : sysresv -d on -l $ORACLE_SID
kpudex spare savdef free
Fatal Error :
This program was not built to run on the processor
in your system.
由以上说明,可以看出加-f参数可以移除共享段(仅适用于实例不存在,操作系统共享段不释放条件)
引用
[ora10g@hzmc bin]$ export ORACLE_SID=mcactive
[ora10g@hzmc bin]$ sysresv -f mcactive
IPC Resources for ORACLE_SID "mcactive" :
Shared Memory:
ID KEY
2490371 0x4566f728
Semaphores:
ID KEY
9797634 0xaf45a9f8
Oracle Instance alive for sid "mcactive"
SYSRESV-005: Warning
Instance maybe alive - aborting remove for sid "mcactive"
当然除了使用sysresv之外,操作系统也提供了命令:ipcrm,可以从操作系统级别移除共享段。至于其用法,各种平台略有差异,具体用法查看联机文档,不做过多阐述。