Removing oracle’s shared memory segments

If there has been a problem on the system (unexplained crash/sysadmin a bit pkill happy) shared memory segments can be left behind.

-bash-4.1$ ipcs -a
IPC status from  as of Mon Aug  4 12:21:42 BST 2014
T         ID      KEY        MODE        OWNER    GROUP  CREATOR   CGROUP CBYTES  QNUM QBYTES LSPID LRPID   STIME    RTIME    CTIME
Message Queues:
T         ID      KEY        MODE        OWNER    GROUP  CREATOR   CGROUP NATTCH      SEGSZ   CPID  LPID   ATIME    DTIME    CTIME
Shared Memory:
m  251658260   0xc0e79a34 --rw-r-----   oracle oinstall   oracle oinstall      1      12288 22170 26178 12:21:25 12:21:25 11:19:24
m  251658259   0x0        --rw-r-----   oracle oinstall   oracle oinstall      1  796917760 22170 26178 12:21:25 11:23:54 11:19:24
m  251658258   0x0        --rw-r-----   oracle oinstall   oracle oinstall      1    8388608 22170 26178 12:21:25 11:23:54 11:19:24
T         ID      KEY        MODE        OWNER    GROUP  CREATOR   CGROUP NSEMS   OTIME    CTIME
Semaphores:
s         11   0x798a1154 --ra-r-----   oracle oinstall   oracle oinstall   304 11:23:54 11:19:24

You can delete these segments using the ipcrm command – but if you have a lot of running databases you may not want to risk selecting the wrong key values.

So, oracle has a utility sysresv that you can use. Set your ORACLE_SID so it knows which database you are working on..

First run it without any parameters to check the segments

-bash-4.1$ sysresv

IPC Resources for ORACLE_SID "oms" :
Shared Memory:
ID              KEY
251658258       0x00000000
251658259       0x00000000
251658260       0xc0e79a34
Semaphores:
ID              KEY
11              0x798a1154
Oracle Instance not alive for sid "oms"

Then run it with the -i flag to interactively remove segments

-bash-4.1$ sysresv -i

IPC Resources for ORACLE_SID "oms" :
Shared Memory:
ID              KEY
251658258       0x00000000
251658259       0x00000000
251658260       0xc0e79a34
Semaphores:
ID              KEY
11              0x798a1154
Oracle Instance not alive for sid "oms"
Remove ipc resources for sid "oms" (y/n)?y
Done removing ipc resources for sid "oms"
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s