首页 » ORACLE 9i-23ai » Identifying Shared Memory Segments for multiple database(Disable AMM) 标识某实例的共享内存段ID

Identifying Shared Memory Segments for multiple database(Disable AMM) 标识某实例的共享内存段ID

有时oracle 实例异常终止,会导致oracle process killed,但是实例之前所分配的shared memory segments没有release, 而此时登录提示no login,而且本机还有其它实例在用无法kill 所有,昨天就遇到了这样的情况,有三个实例,三个共享内存段,如果内核参数配置不合理比如shmmax少,有可能一个实例会有多个共享内存段。这种情况下如何指定残留的对应共享段?然后使用ipcrm 清理,下面例几种方法。

on linux

查看共享内存段

[oracle@db231 ~]$ ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x00000000 1966081    root      644        80         2                       
0x00000000 1998850    root      644        16384      2                       
0x00000000 2031619    root      644        280        2                       
0x00000000 1716125701 oracle    640        16777216   30                      
0x00000000 1716158470 oracle    640        2130706432 30                      
0x649e87b4 1716191239 oracle    640        2097152    30                      
0x00000000 41091080   oracle    640        2928640    156                     
0x00000000 41123849   oracle    640        419430400  78                      
0x00000000 41156618   oracle    640        1912602624 78                      
0x00000000 41189387   oracle    640        13848576   78                      
0x10482b78 41222156   oracle    640        12288      78

切换到对应的实例
export ORACLE_SID
export ORACLE_HOME

方法一使用lsof 配合SHM ID

[oracle@db231 ~]$ lsof | egrep "1716125701|COMMAND"
COMMAND     PID      USER   FD      TYPE             DEVICE   SIZE/OFF       NODE NAME
oracle      303    oracle  DEL       REG                0,4            1716125701 /SYSV00000000
oracle      305    oracle  DEL       REG                0,4            1716125701 /SYSV00000000
oracle      307    oracle  DEL       REG                0,4            1716125701 /SYSV00000000
oracle      309    oracle  DEL       REG                0,4            1716125701 /SYSV00000000
oracle      311    oracle  DEL       REG                0,4            1716125701 /SYSV00000000
oracle      325    oracle  DEL       REG                0,4            1716125701 /SYSV00000000
...

方法二 使用sysresv

[oracle@db231 ~]$ $ORACLE_HOME/bin/sysresv

IPC Resources for ORACLE_SID "anbob" :
Shared Memory:
ID              KEY
1716125701      0x00000000
1716158470      0x00000000
1716191239      0x649e87b4
Semaphores:
ID              KEY
3276801         0xb21bf730
3309570         0xb21bf731
3342339         0xb21bf732
3375108         0xb21bf733
3407877         0xb21bf734
3440646         0xb21bf735
3473415         0xb21bf736
3506184         0xb21bf737
3538953         0xb21bf738
Oracle Instance alive for sid "anbob"

方法三 使用oradebug ipc

sys@ANBOB>oradebug setmypid
Statement processed.

sys@ANBOB>oradebug ipc
Information written to trace file.

sys@ANBOB>oradebug tracefile_name
sys@ANBOB>ho grep -A 1 Shmid  /u01/app/oracle/diag/rdbms/anbob/anbob/trace/anbob_ora_3942.trc
   Area  Subarea    Shmid      Stable Addr      Actual Addr
      0        0 1716125701 0x00000060000000 0x00000060000000
--
   Area  Subarea    Shmid      Stable Addr      Actual Addr
      1        4 1716158470 0x00000061000000 0x00000061000000
--
   Area  Subarea    Shmid      Stable Addr      Actual Addr
      2        2 1716125701 0x00000060b46000 0x00000060b46000
--
   Area  Subarea    Shmid      Stable Addr      Actual Addr
      3        3 1716125701 0x00000060ffe000 0x00000060ffe000
--
   Area  Subarea    Shmid      Stable Addr      Actual Addr
      4        1 1716125701 0x00000060221000 0x00000060221000
--
   Area  Subarea    Shmid      Stable Addr      Actual Addr
      5        5 1716191239 0x000000e0000000 0x000000e0000000

Note: 在ORACLE 7老版本中可能输出是下面这个样子

    SVRMGR> oradebug ipc
    -------------- Shared memory --------------
    Seg Id     Address   Size
    353        80000000  55721984
    Total: # of segments = 1, size = 55721984
    -------------- Semaphores ----------------
    Total number of semaphores = 50
    Number of semaphores per set = 25
    Number of semaphore sets = 2
    Semaphore identifiers:
     458758 458759

有了shm id,使用ipcrm 就可以清理了。

–update 2017-7-14–
for 12c
在12c版本中引入了X$KSMSSINFO 视图,Kernel Service, Semory Sga OS (level) INFO。 从该视图可以查看当前实例使用的共享内存段,并且shmid列对应的IPCS中的SHMID。

SQL> select * from x$ksmssinfo;

ADDR                   INDX    INST_ID     CON_ID AREA NAME                        SEG_START ADDR   START ADDR       SEGMENT SIZE       SIZE REMAINING ALLOC SIZE   PAGESIZE      SHMID SEGMENT DISTRIBUTED  AREA FLAGS SEGMENT DEFERRED         NUMAPG
---------------- ---------- ---------- ---------- -------------------------------- ---------------- ---------------- ------------ ---------- -------------------- ---------- ---------- -------------------- ---------- -------------------- ----------
00007F49A77E5BC0          0          1          0 Variable Size                    0000000061000000 0000000061000000   1543503872 1543503872                    0       4096      65536 YES                        1042 NO                          129
00007F49A77E5BC0          1          1          0 Redo Buffers                     00000000BD000000 00000000BD000000      7983104    7983104                    0       4096      98306 YES                        4627 NO                          129
00007F49A77E5BC0          2          1          0 Fixed Size                       0000000060000000 0000000060000000      8794112    8794112                    0       4096      32769 YES                        4631 NO                          129
00007F49A77E5BC0          3          1          0 skgm overhead                    00000000BE000000 00000000BE000000        12288      12288                    0       4096     131075 YES                   268435987 NO                          129
打赏

对不起,这篇文章暂时关闭评论。