天天學習oracle(一)

anycall2010發表於2009-03-16

1.檢視ORACLE可執行檔案大小:

[oracle@dg1 bin]$ ls -l oracle
-rwsr-s--x 1 oracle oinstall 93362156 Aug 23  2008 oracle

2.判斷ORACLE資料庫是32位還是64位

[oracle@dg1 bin]$ file oracle
oracle: setuid setgid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

3.資料庫啟動順序:

PMON started with pid=2, OS id=12663
PSP0 started with pid=3, OS id=12665
MMAN started with pid=4, OS id=12667
DBW0 started with pid=5, OS id=12669
LGWR started with pid=6, OS id=12671
CKPT started with pid=7, OS id=12673
SMON started with pid=8, OS id=12675
RECO started with pid=9, OS id=12677
CJQ0 started with pid=10, OS id=12679
MMON started with pid=11, OS id=12681

4.SPID和作業系統程式對應關係:

SQL> select addr,pid,spid,username,program from v$process;

ADDR            PID SPID         USERNAME
-------- ---------- ------------ ---------------
PROGRAM
------------------------------------------------
3E61627C          1
PSEUDO

3E616830          2 1366         oracle
oracle@dg1 (PMON)

3E616DE4          3 1368         oracle
oracle@dg1 (PSP0)

3E617398          4 1370         oracle
oracle@dg1 (MMAN)

3E61794C          5 1372         oracle
oracle@dg1 (DBW0)

3E617F00          6 1374         oracle
oracle@dg1 (LGWR)

[oracle@dg1 bdump]$ ps -ef |grep ora
root       300 31531  0 02:45 pts/1    00:00:00 su - oracle
oracle     301   300  0 02:45 pts/1    00:00:00 -bash
oracle    1366     1  0 03:18 ?        00:00:00 ora_pmon_dg1
oracle    1368     1  0 03:18 ?        00:00:00 ora_psp0_dg1
oracle    1370     1  0 03:18 ?        00:00:00 ora_mman_dg1
oracle    1372     1  0 03:18 ?        00:00:00 ora_dbw0_dg1
oracle    1374     1  0 03:18 ?        00:00:00 ora_lgwr_dg1
。。。。。。

該用法可以看出作業系統中的PID和v$process檢視中的SPID是關聯的。因此如果作業系統某程式異常高的情況下,我們可以找到OS上程式在資料庫內部的化身。

V$PROCESS程式包含當前資料庫活動資訊,這些程式在作業系統都存在與之相對應的OS程式。

SQL> desc v$process;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ADDR                                               RAW(4)
 PID                                                NUMBER
 SPID                                               VARCHAR2(12)
 USERNAME                                           VARCHAR2(15)
 SERIAL#                                            NUMBER
 TERMINAL                                           VARCHAR2(30)
 PROGRAM                                            VARCHAR2(48)
 TRACEID                                            VARCHAR2(255)
 BACKGROUND                                         VARCHAR2(1)
 LATCHWAIT                                          VARCHAR2(8)
 LATCHSPIN                                          VARCHAR2(8)
 PGA_USED_MEM                                       NUMBER
 PGA_ALLOC_MEM                                      NUMBER
 PGA_FREEABLE_MEM                                   NUMBER
 PGA_MAX_MEM                                        NUMBER

其中LACHWAIT程式表示當前正在等待的LARCH資訊。LACHSPIN記錄程式正在通過SPIN進行LATCH的競爭。LATCH通常叫做”閂“,是資料庫內部的序列鎖機制。主要用來控制記憶體上的併發,在多處理器中,ORACLE程式通過SPIN來進行LATCH爭奪。

ADDR代表程式地址,程式的狀態等資訊在記憶體中的記錄。      

在V$SESSION檢視中記錄的PADDR就是V$PROCESS.ADDR的進一步延伸,兩者是關聯的。

SQL> select PADDR,STATE,PROCESS,SID from v$session;

PADDR    STATE               PROCESS             SID
-------- ------------------- ------------ ----------
3E61DFF4 WAITING             1426                145
3E61DA40 WAITING             1424                147
3E61B254 WAITING             2437                150
3E61C924 WAITING             1414                152
3E61BDBC WAITING             1410                155
3E61B808 WAITING             1408                156
3E61C370 WAITED SHORT TIME   2301                158
3E61A138 WAITING             1386                160
3E619B84 WAITING             1384                161
3E6195D0 WAITING             1382                162
3E61901C WAITING             1380                163

PADDR    STATE               PROCESS             SID
-------- ------------------- ------------ ----------
3E618A68 WAITING             1378                164
3E6184B4 WAITING             1376                165
3E617F00 WAITING             1374                166
3E61794C WAITING             1372                167
3E617398 WAITING             1370                168
3E616DE4 WAITING             1368                169
3E616830 WAITING             1366                170

18 rows selected.

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

相關文章