Identifying Oracle Instance Shared Memory Segments using the SYSRESV Utility
Oracle has since version 8i provided the SYSRESV Utility which does map instances to shared memory segments. This utility can be used to both identify which shared memory segments belong to which instances and eliminate any DBA guess work or difficult correlation via alternative mechanism.
Example
On a typical Linux server with four database instances, the standard “ipcs” command shows:
$ ipcs -m ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x00000000 3768322 root 644 80 2 0x00000000 3801093 root 644 16384 2 0x00000000 3833862 root 644 280 2 0xd30a2acc 4063239 oracle 640 2634055680 47 0xc267ec14 3899400 oracle 640 1258323968 16 0xba16ccb8 3964938 oracle 640 1258323968 35 0xe3ac6984 4030475 oracle 640 1224769536 15
However there’s no information provided to show which memory segment corresponds to which instance.
For example if the PROD4 instance has crashed but has not automatically removed the shared memory segment it can easily be identified using the SYSRESV utility and process of elimination:
$ sysresv -l PROD1 PROD2 PROD3 IPC Resources for ORACLE_SID "PROD1" : Shared Memory: ID KEY 4063239 0xd30a2acc Semaphores: ID KEY 983041 0xf7bd1ea4 Oracle Instance alive for sid "PROD1" IPC Resources for ORACLE_SID "PROD2" : Shared Memory: ID KEY 3899400 0xc267ec14 Semaphores: ID KEY 262146 0xf7bc1ea4 294915 0xf7bc1ea5 327684 0xf7bc1ea6 360453 0xf7bc1ea7 393222 0xf7bc1ea8 Oracle Instance alive for sid "PROD2" IPC Resources for ORACLE_SID "PROD3" : Shared Memory: ID KEY 4030475 0xe3ac6984 Semaphores: ID KEY 851975 0xf7be1ea4 Oracle Instance alive for sid "PROD3"
From the output above we can see the shared memory segment KEY and ID values for the three running instances PROD1, PROD2, and PROD3. Through process of elimination and comparing to the output of the ealier ipcs command we can conclude that shared memory segment KEY=0xba16ccb8 ID=3964938 must belong to the failed PROD4 instance. It can then be removed with the appropriate UNIX command. For example:
$ ipcrm -m 3964938
References
My Oracle Support: SYSRESV Utility (Doc ID 123322.1)