1. 程式人生 > 其它 >關於oracle裡的process總結(45天)

關於oracle裡的process總結(45天)

感覺需要對process做一個簡單的總結。準備瞭如下的測試場景。 session在服務端請求 先用sqlplus / as sysdba在服務端登入。 SQL> show user USER is "SYS" 得到當前的session為5860. SQL> select sid from v$mystat where rownum<2; SID ---------- 5860 得到對應的Process。這個其實就是客戶端對應的process,因為是從服務端登入,所以在服務端應該會有兩個process來對應,一個相當於客戶端,一個相當於服務端。paddr是process對應的記憶體地址,在查詢v$process的很有用。

SQL> select sid,username,process,paddr from v$session where sid=5860; SID USERNAME PROCESS PADDR ---------- ------------------------------ ------------------------ ---------------- 5860 SYS 28490 000000035977B488
先來驗證一下客戶端的process 28490是不是存在。可以看到,28490是通過sqlplus的方式登入的。而且是另外一個連線的父程序。這個程序就是我們需要查詢的在服務端存在的對映程序。 SQL> host ps -ef|grep 28490 oratestdb 6741 28490 0 14:48 pts/1 00:00:00 /bin/bash -c ps -ef|grep 28490 oratestdb 6743 6741 0 14:48 pts/1 00:00:00 grep 28490 oratestdb 28490 4017 0 14:45 pts/1 00:00:00 sqlplus as sysdba oratestdb 28491 28490 0 14:45 ? 00:00:00 oraclePETtest1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
我們來查詢v$process,看process是不是存在28491,spid就是對應的攝影程序,pid是資料庫內部的程序標示。 檢視程序明細,可以看到使用的bequence協議。 SQL> select pid,spid from v$process where addr='000000035977B488'; PID SPID ---------- ------------------------ 31 28491 SQL> host ps -ef|grep 28491 oratestdb 14578 28490 0 14:50 pts/1 00:00:00 /bin/bash -c ps -ef|grep 28491 oratestdb 14580 14578 0 14:50 pts/1 00:00:00 grep 28491 oratestdb 28491 28490 0 14:45 ? 00:00:00 oraclePETtest1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))) 再來看另外一個場景。 session在客戶端請求 通過sqlplus從客戶端登陸。 ############# select sid from v$mystat where rownum<2; SID ---------- 6049 select sid,username,process,paddr from v$session where sid=6049 SQL> / 可以看到對應的Process是824. 這個就是客戶端所在的機器對應的process。 SID USERNAME PROCESS PADDR ---------- ------------------------------ ------------------------ ---------------- 6049 JIANRONG 824 000000035977C508 SQL> host ps -ef|grep 824 oraccbs1 824 30352 0 17:05 pts/1 00:00:00 sqlplus root 3824 3051 0 2013 ? 00:00:00 [aio/29] oraccbs1 11079 824 0 17:06 pts/1 00:00:00 /bin/bash -c ps -ef|grep 824 oraccbs1 11082 11079 0 17:06 pts/1 00:00:00 grep 824 檢視服務端對應的程序,是17175 SQL> select pid,spid ,username from v$process where addr='000000035977C508'; PID SPID USERNAME ---------- ------------------------ --------------- 32 17175 oratestdb 登入服務端,檢視程序情況,與客戶端的場景不同的是,17175的父程序是1,為root根程序。 oratestdb@ccbdbpt4:/opt/app/oracle/dbtestspt1/oratestdb> ps -ef|grep 17175 oratestdb 17175 1 0 17:05 ? 00:00:00 oraclePETtest1 (LOCAL=NO) oratestdb 27196 24714 0 17:07 pts/1 00:00:00 grep 17175 對於客戶端場景和服務端場景來說,如果一定要刨根問底的看某個session(比如 session 824)的父程序情況。可以看到最終的process 父程序還是1.

oratest1@:/opt/app/oracle/dbtestpt1/oratest1> ps -ef|grep 30352
oratest1   824 30352  0 17:05 pts/1    00:00:00 sqlplus                          
oratest1 20500 20060  0 17:23 pts/1    00:00:00 grep 30352
oratest1 30352 30347  0 16:34 pts/1    00:00:00 -bash
oratest1@:/opt/app/oracle/dbtestpt1/oratest1> ps -ef|grep 30347
oratest1 21993 20060  0 17:23 pts/1    00:00:00 grep 30347
oratest1 30347 29705  0 16:34 ?        00:00:00 sshd: oratest1@pts/1
oratest1 30352 30347  0 16:34 pts/1    00:00:00 -bash
oratest1@:/opt/app/oracle/dbtestpt1/oratest1> ps -ef|grep 29705
oratest1 23945 20060  0 17:23 pts/1    00:00:00 grep 29705
root 29705 25298  0 16:34 ?        00:00:00 sshd: oratest1 [priv]
oratest1 30347 29705  0 16:34 ?        00:00:00 sshd: oratest1@pts/1
oratest1@:/opt/app/oracle/dbtestpt1/oratest1> ps -ef|grep 25298
root     25298     1  0  2013 ?        00:00:03 /usr/sbin/sshd
oratest1 26659 20060  0 17:24 pts/1    00:00:00 grep 25298
root     29705 25298  0 16:34 ?        00:00:00 sshd: oratest1 [priv]