[0104]ipcs查看共享内存段.txt
--//数据库启动异常,有时候会留下一些共享内存段没有清理,需要使用ipcrm清理.
--//由于服务器上跑2个实例,必须选择正确的共享内存段,否则会导致别的数据库crash.
--//在我工作中,这是遇到的第2次,做一些复习与整理:
--//在linux下有一个命令sysresv可以查看某实例使用的共享内存段.
$ ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 287440897 oracle 600 12288 2dest
0x00000000 287473666 oracle 600 196608 2dest
0x00000000 287506435 oracle 600 12288 2dest
0x00000000 287211524 oracle 600 393216 2dest
0x00000000 287244293 oracle 600 393216 2dest
0x00000000 287277062 oracle 600 393216 2dest
0x00000000 287309831 oracle 600 196608 2dest
0x00000000 287342600 oracle 600 393216 2dest
0x00000000 287375369 oracle 600 196608 2dest
0x00000000 287408138 oracle 600 393216 2dest
0x00000000 301334539 oracle 640 12582912 25
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x00000000 301367308 oracle 640 633339904 25
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0xe8a8ec10 301400077 oracle 640 2097152 25
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x790209cd 294617102 oracle 666 808 0
0x79020002 294649871 oracle 666 808 0
------ Semaphore Arrays --------
key semid owner perms nsems
0x6aa88594 275578880 oracle 640 184
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x790209cd 269713409 oracle 666 1
0x79020002 269746178 oracle 666 1
------ Message Queues --------
key msqid owner perms used-bytes messages
$ export ORACLE_SID=book
$ sysresv
IPC Resources for ORACLE_SID "book" :
Shared Memory:
ID KEY
301334539 0x00000000
301367308 0x00000000
301400077 0xe8a8ec10
Semaphores:
ID KEY
275578880 0x6aa88594
Oracle Instance alive for sid "book"
--//下划线内容可以对上.
--//注意执行前最好指定确认ORACLE_SID环境变量.
man ipcrm
-m shmid removes the shared memory segment identified by shmid after the last detach is performed.
--//ipcrm 参数-m 对应 shmid.
--//另外ipcs有一个参数-t参看time.
$ ipcs -t
------ Shared Memory Attach/Detach/Change Times --------
shmid owner attached detached changed
287440897 oracle Dec 12 17:37:06 Dec 12 17:37:07 Dec 5 17:32:14
287473666 oracle Dec 12 17:37:06 Dec 12 17:37:07 Dec 5 17:32:14
287506435 oracle Dec 12 17:37:06 Dec 12 17:37:07 Dec 5 17:32:14
287211524 oracle Dec 12 17:37:06 Dec 12 17:37:07 Dec 5 15:42:08
287244293 oracle Dec 12 17:37:06 Dec 12 17:37:07 Dec 5 15:42:08
287277062 oracle Dec 12 17:37:06 Dec 12 17:37:07 Dec 5 15:42:08
287309831 oracle Dec 12 17:37:06 Dec 12 17:37:07 Dec 5 15:42:08
287342600 oracle Dec 12 17:37:06 Dec 12 17:37:07 Dec 5 15:42:09
287375369 oracle Dec 12 17:37:06 Dec 12 17:37:07 Dec 5 15:42:17
287408138 oracle Dec 12 17:37:06 Dec 12 17:37:07 Dec 5 15:42:17
301334539 oracle Jan 4 10:13:32 Jan 4 10:14:02 Jan 4 09:53:20
301367308 oracle Jan 4 10:13:32 Jan 4 10:14:02 Jan 4 09:53:20
301400077 oracle Jan 4 10:13:32 Jan 4 10:14:02 Jan 4 09:53:20
294617102 oracle Dec 24 09:22:37 Dec 24 09:22:37 Dec 24 09:22:37
294649871 oracle Dec 24 10:03:22 Dec 24 10:08:55 Dec 24 09:23:01
------ Semaphore Operation/Change Times --------
semid owner last-oplast-changed
275578880 oracle Fri Jan 4 10:14:43 Fri Jan 4 10:14:43
269713409 oracle Mon Dec 24 09:22:37 Mon Dec 24 09:22:37
269746178 oracle Mon Dec 24 10:08:55 Mon Dec 24 09:23:01
------ Message Queues Send/Recv/Change Times --------
msqid owner send recv change
--//我仔细看了一下.如果有用户连上attached会变化,退出后detached时间也会变化.说明有用户使用.
--//最后一列changed视乎都不变,不知道是否对应oracle实例的启动时间.
SYS@book> select startup_time from v$instance ;
STARTUP_TIME
-------------------
-01-04 09:53:21
--//视乎可以对上.
--//另外使用oradebug ipc命令也可以查看.
SYS@book> oradebug setmypid
Statement processed.
SYS@book> oradebug ipc
IPC information written to the trace file
SYS@book> oradebug tracefile_name
/u01/app/oracle/diag/rdbms/book/book/trace/book_ora_7252.trc
*** -01-04 10:25:15.026
Processing Oradebug command 'ipc'
Dump of unix-generic skgm context
areaflags000000f7
realmflags0000001f
mapsize 00000800
protectsize00001000
lcmsize 00001000
seglen 00200000
largestsize 0000000480000000
smallestsize 0000000000400000
stacklimit 0x7fffc0268300
stackdir-1
mode 640
magic acc01ade
Handle: 0x7f0b488e40b0 `/u01/app/oracle/product/11.2.0.4/dbhome_1book'
--//注意这是句柄,还记得环境变量ORACLE_HOME后面带斜线的设置导致无法连上数据库的问题吗?11.2.0.4已经没有这个问题了.
$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0.4/dbhome_1
--//参看链接:/267265/viewspace-2055052/=>[0310]神奇的斜线.txt
Dump of unix-generic realm handle `/u01/app/oracle/product/11.2.0.4/dbhome_1book', flags = 00000000
Area #0 `Fixed Size' containing Subareas 0-0
Total size 0000000000226c00 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
0 0 301334539 0x00000060000000 0x00000060000000
Subarea size Segment size
0000000000227000 0000000000c00000
Area #1 `Variable Size' containing Subareas 4-4
Total size 0000000025c00000 Minimum Subarea size 00400000
Area Subarea Shmid Stable Addr Actual Addr
1 4 301367308 0x00000060c00000 0x00000060c00000
Subarea size Segment size
0000000025c00000 0000000025c00000
Area #2 `Redo Buffers' containing Subareas 1-1
Total size 0000000000724000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
2 1 301334539 0x00000060227000 0x00000060227000
Subarea size Segment size
0000000000724000 0000000000c00000
Area #3 `Base Allocator Control' containing Subareas 3-3
Total size 0000000000002000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
3 3 301334539 0x00000060bfe000 0x00000060bfe000
Subarea size Segment size
0000000000002000 0000000000c00000
Area #4 `Slab Allocator Control' containing Subareas 2-2
Total size 00000000002b3000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
4 2 301334539 0x0000006094b000 0x0000006094b000
Subarea size Segment size
00000000002b3000 0000000000c00000
Area #5 `skgm overhead' containing Subareas 5-5
Total size 0000000000002000 Minimum Subarea size 00000000
Area Subarea Shmid Stable Addr Actual Addr
5 5 301400077 0x00000086800000 0x00000086800000
Subarea size Segment size
0000000000002000 0000000000200000
Dump of Linux-specific skgm context
-------------- system semaphore information -------------
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 287440897 oracle 600 12288 2dest
0x00000000 287473666 oracle 600 196608 2dest
0x00000000 287506435 oracle 600 12288 2dest
0x00000000 287211524 oracle 600 393216 2dest
0x00000000 287244293 oracle 600 393216 2dest
0x00000000 287277062 oracle 600 393216 2dest
0x00000000 287309831 oracle 600 196608 2dest
0x00000000 287342600 oracle 600 393216 2dest
0x00000000 287375369 oracle 600 196608 2dest
0x00000000 287408138 oracle 600 393216 2dest
0x00000000 301334539 oracle 640 12582912 26
0x00000000 301367308 oracle 640 633339904 26
0xe8a8ec10 301400077 oracle 640 2097152 26
0x790209cd 294617102 oracle 666 808 0
0x79020002 294649871 oracle 666 808 0
------ Semaphore Arrays --------
key semid owner perms nsems
0x6aa88594 275578880 oracle 640 184
0x790209cd 269713409 oracle 666 1
0x79020002 269746178 oracle 666 1
------ Message Queues --------
key msqid owner perms used-bytes messages
--//仅仅前面部分的显示该实例使用共享内存段.