oracle 11g pmon工作內容系列一

wisdomone1發表於2015-11-04

背景

   熟悉PMON的含義及工作內容。

結論

1,pmon可以用10246 event進行跟蹤PMON工作過程
2,pmon工作內容如下:
後經查詢官方手冊發現,PMON的工作內容如下:
    1,監控後臺程式執行狀況
    2,如果某些程式異常中斷,PMON去釋放會話資源以及佔用的鎖LOCK
    3,更新事務表的標誌以及清除事務XID的標記
    4,清除異常中斷會話在BUFFER CACHE佔用的快取
    5,PMON也負責定期把資料庫例項註冊到監聽器中


3,10246 EVENT產生的TRACE FILE分析摘錄
--PMON接到通知
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksl2.h LINE:2160 ID:kslges, process=6c, post_num=5


*** 2015-11-01 21:49:30.646
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksl2.h LINE:2160 ID:kslges, process=39, post_num=6
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12751 ID:ksupsc, process=b8, post_num=7


*** 2015-11-01 22:03:02.812
deleting session 0xdc97f1b0 sid=201 serial=188  --PMON發現上述測試會話被人為KILL


*** 2015-11-01 22:03:03.382
deletion of killed session 0xdc97f1b0 successful


--這裡就是ORACLE核心程式碼負責清理被KILL會話佔用的資源
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12737 ID:ksuabt, process=0, post_num=8
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=9
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=10
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=11
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=12
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=13
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=14
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=15
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=16
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=17
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=18
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=19
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=20
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=21
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=22
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=23
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=24
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=25
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=26
PMON ignoring post from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2


*** 2015-11-01 22:03:06.428
marked process 0xdd6589c0 pid=184 serial=2 ospid = 11635 dead  --PMON清理完被KILL後,標記為DEAD


*** 2015-11-01 22:03:06.446
deleting process 0xdd6589c0 pid=184 serial=2 priority=0 --然後刪除這個會話對應的作業系統程式資源
deletion of process dd6589c0 pid=184 seq=2 successful



測試



1,資料庫版本
SQL> select * from v$version where rownum=1;


BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production


2,跟蹤pmon


SQL> alter session set tracefile_identifier='pmon_test1';


Session altered.


SQL> alter system set events='10246 trace name context forever,level 1';


System altered.


3,使用者測試會話
SQL> select sid from v$mystat where rownum=1;


       SID
----------
       201


 SQL> select sid,serial# from v$session where sid=201;


       SID    SERIAL#
---------- ----------
       201        188
       
SQL> create table t_pmon(a int,b int);


Table created.


SQL> insert into t_pmon select level,level from dual connect by level<=1000000;
insert into t_pmon select level,level from dual connect by level<=1000000
            *
ERROR at line 1:
ORA-00028: your session has been killed
ORA-00028: your session has been killed


--另啟會話殺掉正在插入記錄的上述測試會話
SQL> alter system kill session '201,188';


System altered.


3,關閉pmon跟蹤
SQL> alter system set events='10246 trace name context off';


System altered.




4,檢視pmon的TRACE FILE


--PMON接到通知
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksl2.h LINE:2160 ID:kslges, process=6c, post_num=5


*** 2015-11-01 21:49:30.646
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksl2.h LINE:2160 ID:kslges, process=39, post_num=6
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12751 ID:ksupsc, process=b8, post_num=7


*** 2015-11-01 22:03:02.812
deleting session 0xdc97f1b0 sid=201 serial=188  --PMON發現上述測試會話被人為KILL


*** 2015-11-01 22:03:03.382
deletion of killed session 0xdc97f1b0 successful


--這裡就是ORACLE核心程式碼負責清理被KILL會話佔用的資源
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12737 ID:ksuabt, process=0, post_num=8
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=9
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=10
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=11
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=12
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=13
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=14
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=15
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=16
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=17
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=18
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=19
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=20
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=21
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=22
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=23
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=24
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=25
PMON posted from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2, post_num=26
PMON ignoring post from location=FILE:/ade/b/1640894963/oracle/rdbms/src/hdir/ksu.h LINE:12763 ID:ksuxfd, process=2


*** 2015-11-01 22:03:06.428
marked process 0xdd6589c0 pid=184 serial=2 ospid = 11635 dead  --PMON清理完被KILL後,標記為DEAD


*** 2015-11-01 22:03:06.446
deleting process 0xdd6589c0 pid=184 serial=2 priority=0 --然後刪除這個會話對應的作業系統程式資源
deletion of process dd6589c0 pid=184 seq=2 successful




繼續測試,如果我們讓PMON阻塞,再手工KILL測試會話會如何呢


SQL> select pid,spid from v$process where pname='PMON';


       PID SPID
---------- ------------------------------------------------
         2 10556


SQL> oradebug setospid 10556
Oracle pid: 2, Unix process pid: 10556, image: oracle@seconary (PMON)
SQL> oradebug suspend
Statement processed.


沒看到任何有價值的內容




換個思路,如果阻塞PMON,事務提交會不會正常進行呢
SQL> oradebug setospid 10556
Oracle pid: 2, Unix process pid: 10556, image: oracle@seconary (PMON)
SQL> oradebug suspend
Statement processed.




可見事務提交不受影響
SQL> update t_pmon set a=111 where a=1;


1 row updated.


SQL> commit;


Commit complete.




後經查詢官方手冊發現,PMON的工作內容如下:
1,監控後臺程式執行狀況
2,如果某些程式異常中斷,PMON去釋放會話資源以及佔用的鎖LOCK
3,更新事務表的標誌以及清除事務XID的標記
4,清除異常中斷會話在BUFFER CACHE佔用的快取
5,PMON也負責定期把資料庫例項註冊到監聽器中




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-1822772/,如需轉載,請註明出處,否則將追究法律責任。

相關文章