ORACLE 11G ADRCI 使用小記

在oracle11g中,dump file的目錄已經有所改變,bdump和udump整合到trace中,cdump獨立出一個。

E:\ora11g\app\Administrator\diag\rdbms>tree
卷 DOCUMENT 的文件夾 PATH 列表
卷序列號爲 5A21-A80E
E:.
└─ora11g
    └─ora11g
        ├─alert
        ├─cdump
        ├─hm
        ├─incident
        ├─incpkg
        ├─ir
        ├─lck
        ├─metadata
        ├─stage
        ├─sweep
        └─trace
 
E:\ora11g\app\Administrator\diag\rdbms>

而oracle也提供了一個ADRCI(Automatic Diagnostic Repository Command Interpreter)的工具來提供這些路徑下各個trace、incident、problem的管理。下面我們來看看該命令的使用。

C:\Documents and Settings\Administrator>adrci
 
ADRCI: Release 11.2.0.1.0 - Production on Fri Jun 22 23:05:42 2012
 
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
 
ADR base = "e:\ora11g\app\administrator"
adrci> help
 
 HELP [topic]
   Available Topics:
        CREATE REPORT
        ECHO
        EXIT
        HELP
        HOST
        IPS
        PURGE
        RUN
        SET BASE
        SET BROWSER
        SET CONTROL
        SET ECHO
        SET EDITOR
        SET HOMES | HOME | HOMEPATH
        SET TERMOUT
        SHOW ALERT
        SHOW BASE
        SHOW CONTROL
        SHOW HM_RUN
        SHOW HOMES | HOME | HOMEPATH
        SHOW INCDIR
        SHOW INCIDENT
        SHOW PROBLEM
        SHOW REPORT
        SHOW TRACEFILE
        SPOOL
 
 There are other commands intended to be used directly by Oracle, type
 "HELP EXTENDED" to see the list
 
adrci>

在使用前,我們要先設定一下adrci的主目錄:

adrci> show home
ADR Homes:
diag\clients\user_administrator\host_2188829984_76
diag\clients\user_unknown\host_2188829984_76
diag\diagtool\user_administrator\host_2188829984_76
diag\rdbms\ora11g\ora11g
diag\tnslsnr\hejianmin\listener
adrci>
adrci>
adrci> set home diag\rdbms\ora11g\ora11g
adrci>
adrci> show home
ADR Homes:
diag\rdbms\ora11g\ora11g
adrci>

好了,設置完主目錄後,我們先來檢查一下我們的alertlog:

adrci> show alert -tail -f
2012-06-22 23:51:45.466000 +08:00
Thread 1 cannot allocate new log, sequence 48
Checkpoint not complete
  Current log# 2 seq# 47 mem# 0: E:\ORA11G\APP\ADMINISTRATOR\ORADATA\ORA11G\REDO02.LOG
2012-06-22 23:51:46.981000 +08:00
Thread 1 advanced to log sequence 48 (LGWR switch)
  Current log# 3 seq# 48 mem# 0: E:\ORA11G\APP\ADMINISTRATOR\ORADATA\ORA11G\REDO03.LOG
Thread 1 cannot allocate new log, sequence 49
Checkpoint not complete
  Current log# 3 seq# 48 mem# 0: E:\ORA11G\APP\ADMINISTRATOR\ORADATA\ORA11G\REDO03.LOG
2012-06-22 23:51:49.934000 +08:00
Thread 1 advanced to log sequence 49 (LGWR switch)
  Current log# 1 seq# 49 mem# 0: E:\ORA11G\APP\ADMINISTRATOR\ORADATA\ORA11G\REDO01.LOG
2012-06-22 23:52:05.653000 +08:00
Thread 1 advanced to log sequence 50 (LGWR switch)
  Current log# 2 seq# 50 mem# 0: E:\ORA11G\APP\ADMINISTRATOR\ORADATA\ORA11G\REDO02.LOG
Thread 1 advanced to log sequence 51 (LGWR switch)
  Current log# 3 seq# 51 mem# 0: E:\ORA11G\APP\ADMINISTRATOR\ORADATA\ORA11G\REDO03.LOG
2012-06-22 23:52:07.122000 +08:00
Thread 1 advanced to log sequence 52 (LGWR switch)
  Current log# 1 seq# 52 mem# 0: E:\ORA11G\APP\ADMINISTRATOR\ORADATA\ORA11G\REDO01.LOG

類似的,我們可以

  1. show alert -tail (默認是10條條目)
  2. show alert -tail -20(顯示最後20個條目)
  3. show alert -tail -f(類似tail -f alertlog一樣)
  4. show alert(windows中會彈出txt文本窗口顯示,如已經裝了MKS Toolkit,希望用vi顯示,則需要先set editor vi,再show alert。)
  5. show alert -p "MESSAGE_TEXT like '%ORA-%'"(顯示alert中關於ORA-報錯的內容。其他更多的show alert的選項,可見 help show alert)

注意,show alert的起始點是在control中設置的保留時間之後的日誌,或者說是purge之後的日誌,之前的日誌無法顯示。

adrci> show control
 
ADR Home = e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g:
*************************************************************************
ADRID                SHORTP_POLICY        LONGP_POLICY         LAST_MOD_TIME                            LAST_AUTOPRG_TIME                        LAST_MANUPRG_TIME                        ADRDIR_VERSION       ADRSCHM_VERSION      ADRSCHMV_SUMMARY     ADRALERT_VERSION     CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
799124850            720                  8760                 2011-05-08 17:12:01.015000 +08:00        2011-07-08 23:00:22.380000 +08:00        2012-06-22 23:36:14.731000 +08:00        1                    2                    76                   1                    2011-05-08 17:12:01.015000 +08:00
1 rows fetched
 
adrci>

也就是max(LAST_AUTOPRG_TIME,LAST_MANUPRG_TIME)之後的日誌。

關於control的設置,除了默認的SHORTP_POLICY爲720小時,LONGP_POLICY爲8760小時外,我們可以修改這2個時間:

adrci> set control (SHORTP_POLICY = 360)
adrci> set control (LONGP_POLICY = 2160)
adrci>
adrci> show control
 
ADR Home = e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g:
*************************************************************************
ADRID                SHORTP_POLICY        LONGP_POLICY         LAST_MOD_TIME                            LAST_AUTOPRG_TIME                        LAST_MANUPRG_TIME                        ADRDIR_VERSION       ADRSCHM_VERSION      ADRSCHMV_SUMMARY     ADRALERT_VERSION     CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
799124850            360                  2160                 2012-06-23 00:11:47.106000 +08:00        2011-07-08 23:00:22.380000 +08:00        2012-06-22 23:36:14.731000 +08:00        1                    2                    76                   1                    2011-05-08 17:12:01.015000 +08:00
1 rows fetched
 
adrci>

這樣就改成了tracefiles保留360小時,即15天,incident file保留2160小時,即90天。

上述就是oracle自己保留日誌的期限,但是我們也可以通過purge這個命令來手工的清空。關於purge這個命令,我會在介紹incident和problem之後,再介紹。

下面我們來看看關於incident和proble的顯示。我們人爲的製造一個incident

adrci> show incident
 
ADR Home = e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g:
*************************************************************************
0 rows fetched
 
adrci>
adrci>
adrci>
adrci> show incident
 
ADR Home = e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g:
*************************************************************************
0 rows fetched
 
adrci>
 
sys@ORA11G(192.168.1.106)> select OBJECT_NAME,OBJECT_ID,DATA_OBJECT_ID from dba_objects where owner='TEST' and object_name='TB_TEST';
 
OBJECT_NAME                     OBJECT_ID DATA_OBJECT_ID
------------------------------ ---------- --------------
TB_TEST                             74270          74270
 
Elapsed: 00:00:00.00
sys@ORA11G(192.168.1.106)>
sys@ORA11G(192.168.1.106)>
sys@ORA11G(192.168.1.106)> update sys.tab$ set OBJ# = 999999 where OBJ# = 74270;
 
1 row updated.
 
Elapsed: 00:00:00.00
sys@ORA11G(192.168.1.106)> commit;
 
Commit complete.
 
Elapsed: 00:00:00.03
sys@ORA11G(192.168.1.106)> alter system checkpoint;
 
System altered.
 
Elapsed: 00:00:00.26
sys@ORA11G(192.168.1.106)>
sys@ORA11G(192.168.1.106)>
sys@ORA11G(192.168.1.106)> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@ORA11G(192.168.1.106)> startup
ORACLE instance started.
 
Total System Global Area  778387456 bytes
Fixed Size                  1374808 bytes
Variable Size             310379944 bytes
Database Buffers          461373440 bytes
Redo Buffers                5259264 bytes
Database mounted.
Database opened.
sys@ORA11G(192.168.1.106)>conn test/test
test@ORA11G(192.168.1.106)> desc tb_test
ERROR:
ORA-03113: end-of-file on communication channel
Process ID: 640
Session ID: 137 Serial number: 2
 
 
test@ORA11G(192.168.1.106)>
test@ORA11G(192.168.1.106)>

我們來看看show incident和show problem:

adrci> show incident
 
ADR Home = e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g:
*************************************************************************
INCIDENT_ID          PROBLEM_KEY                                                 CREATE_TIME
-------------------- ----------------------------------------------------------- ----------------------------------------
32620                ORA 7445 [kqldcdp()+78]                                     2012-06-24 22:13:56.109000 +08:00
1 rows fetched
 
adrci> show problem
 
ADR Home = e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g:
*************************************************************************
PROBLEM_ID           PROBLEM_KEY                                                 LAST_INCIDENT        LASTINC_TIME
-------------------- ----------------------------------------------------------- -------------------- ----------------------------------------
2                    ORA 7445 [kqldcdp()+78]                                     32620                2012-06-24 22:13:56.109000 +08:00
1 rows fetched
 
adrci>

我們看到分別有一個incident和problem。

我們再次desc一次這個表:

sys@ORA11G(192.168.1.106)> conn test/test
Connected.
test@ORA11G(192.168.1.106)>
test@ORA11G(192.168.1.106)>
test@ORA11G(192.168.1.106)> desc tb_test
ERROR:
ORA-03113: end-of-file on communication channel
Process ID: 7244
Session ID: 16 Serial number: 24
 
 
test@ORA11G(192.168.1.106)>
 
adrci> show incident
 
ADR Home = e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g:
*************************************************************************
INCIDENT_ID          PROBLEM_KEY                                                 CREATE_TIME
-------------------- ----------------------------------------------------------- ----------------------------------------
32620                ORA 7445 [kqldcdp()+78]                                     2012-06-24 22:13:56.109000 +08:00
32580                ORA 7445 [kqldcdp()+78]                                     2012-06-24 22:17:23.890000 +08:00
2 rows fetched
 
adrci> show problem
 
ADR Home = e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g:
*************************************************************************
PROBLEM_ID           PROBLEM_KEY                                                 LAST_INCIDENT        LASTINC_TIME
-------------------- ----------------------------------------------------------- -------------------- ----------------------------------------
2                    ORA 7445 [kqldcdp()+78]                                     32580                2012-06-24 22:17:23.890000 +08:00
1 rows fetched
 
adrci>

我們看到有2個incident和一個problem。我們可以理解成problem是重複的incident。
注意在這裏incident和problem還可以用如下的用法:

  1. show incident -mode detail -p "incident_id=123"
  2. show problem -p "problem_id=2"

更多信息見help show incident或help show problem。

OK,我們現在可以將相關的incident的文件打包給oracle,上傳到SR上。我們這裏用到一個IPS(incident package service)服務。
我們先創建一個邏輯的package:
比如我們針對上面的2個incident和1個problem,我們可以有各種選擇:

1.什麼參數都不帶,表示以默認的level typical, 裏面無任何內容。
adrci> ips create package
Created package 1 without any contents, correlation level typical
2.加incident參數,指明某個incident。默認level還是typical。
adrci>
adrci> ips create package incident 32620
Created package 2 based on incident id 32620, correlation level typical
adrci>
3.加incident參數,指定某個incident,設置level爲all。
adrci> ips create package incident 32580 correlate all
Created package 3 based on incident id 32580, correlation level all
adrci>
4.加problem參數,指定某個problem。默認level還是typical。
adrci> ips create package problem 2
Created package 4 based on problem id 2, correlation level typical
5.加problem參數,指定某個problem,設置level爲basic。
adrci>
adrci> ips create package problem 2 correlate basic
Created package 5 based on problem id 2, correlation level basic
adrci>
adrci>
6.加time參數,設置開始時間to結束時間,後面的+8:00表示東八區。
adrci> ips create package time '2012-06-23 00:00:00 +08:00' to '2012-06-24 23.00.00 +08:00'
Created package 6 based on time range 2012-06-23 00:00:00.000000 +08:00 to 2012-06-24 23:00:00.000000 +08:00, correlation level typical
adrci>

我們看到,已經有6個邏輯上的package被建立,在incpkg也有了6個對於的目錄。

E:\ora11g\app\Administrator\diag\rdbms>tree
卷 DOCUMENT 的文件夾 PATH 列表
卷序列號爲 5A21-A80E
E:.
└─ora11g
    └─ora11g
        ├─alert
        ├─cdump
        ├─hm
        ├─incident
        │  ├─incdir_32580
        │  └─incdir_32620
        ├─incpkg
        │  ├─pkg_1
        │  │  └─seq_1
        │  ├─pkg_2
        │  │  └─seq_1
        │  ├─pkg_3
        │  │  └─seq_1
        │  ├─pkg_4
        │  │  └─seq_1
        │  ├─pkg_5
        │  │  └─seq_1
        │  └─pkg_6
        │      └─seq_1
        ├─ir
        ├─lck
        ├─metadata
        ├─stage
        ├─sweep
        └─trace
            ├─cdmp_20120624221402
            └─cdmp_20120624221725
 
E:\ora11g\app\Administrator\diag\rdbms>

我們上傳給oracle的話,還需要建立真正物理上的package。

adrci> ips GENERATE PACKAGE 2
Generated package 2 in file E:\ORA7445kq_20120624223659_COM_1.zip, mode complete
adrci>

如果我們要自定義路徑,加in參數即可:

adrci> ips GENERATE PACKAGE 3 in E:\ora11g\app\Administrator\diag\rdbms\ora11g\ora11g\jimmy_ips
Generated package 3 in file E:\ora11g\app\Administrator\diag\rdbms\ora11g\ora11g\jimmy_ips\ORA7445kq_20120624223726_COM_2.zip, mode complete
adrci>

注意ips的調用和perl有關。如果你的機器上裝有多個版本的oracle,請注意環境變量的中的perl的路徑。不然會有類似的報錯:

adrci> ips GENERATE PACKAGE 5 in E:\ora11g\app\Administrator\diag\rdbms\ora11g\ora11g\jimmy_ips
Perl 5.006 required--this is only version 5.00503, stopped at E:\ora10g\oracle\product\10.2.0\db_1\perl\5.8.3\lib/vars.pm line 3.
BEGIN failed--compilation aborted at E:\ora10g\oracle\product\10.2.0\db_1\perl\5.8.3\lib/vars.pm line 3.
BEGIN failed--compilation aborted at E:\ora10g\oracle\product\10.2.0\db_1\perl\site\5.8.3\lib/Win32/TieRegistry.pm line 14.
Generated package 5 in file E:\ora11g\app\Administrator\diag\rdbms\ora11g\ora11g\jimmy_ips\ORA7445kq_20120624223801_COM_2.zip, mode complete
DIA-49441: Warnings while finalizing package, details in file e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g\incpkg\pkg_5\seq_2\finalize.log
 
adrci>

這樣就可以把zip發給oracle診斷了。

好了,最好,我們來打掃戰場。

(1)清除incident,我們可以用purge命令:

adrci> purge -age 2
adrci> show incident
 
ADR Home = e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g:
*************************************************************************
0 rows fetched
 
adrci>

(2)清除problem,我們可以用delete命令:

adrci> show problem
 
ADR Home = e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g:
*************************************************************************
PROBLEM_ID PROBLEM_KEY LAST_INCIDENT LASTINC_TIME
——————– ———————————————————– ——————– ————————–
1 ORA 7445 [kqrprl()+92] 22970 2012-04-20 13:42:14.953000
1 rows fetched
 
adrci>
adrci>
adrci>
adrci> delete from problem where problem_id=1
 
1 Row Deleted
adrci>
adrci>
adrci> show problem
 
ADR Home = e:\ora11g\app\administrator\diag\rdbms\ora11g\ora11g:
*************************************************************************
0 rows fetched
 
adrci>
adrci>

本來還想多寫點,到後來猛然發現原來這貨是爲了給oracle開SR的時候,打包各類日誌提供方便。這貨的主要目的還是爲他人做嫁衣裳了。

DBA的關鍵素質還是的自己能看trace,分析trace,不能把所有的希望寄託在metalink上。

發佈了6 篇原創文章 · 獲贊 4 · 訪問量 18萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章