Oracle 11g ADRCI工具使用

realkid4發表於2012-05-22

 

Oracle中,各個元件(監聽器、資料庫例項、各種配置工具)在安裝和執行時都會有相應的日誌Log和跟蹤檔案Trace生成。Oracle 11g之前,這些資訊都是零散的分佈在Oracle元件目錄中的。在11gOracle推出了ADRAutomatic Diagnostic Repository)的概念,將這些資訊統一的列入到其中管理。

 

1ADRCI初探

 

11g中,提供了ADR_HOME目錄,其中集中儲存各型別的日誌和跟蹤資訊。

 

 

[oracle@bspdev app]$ ls -l

total 24

drwxrwxr-x.  3 oracle oinstall 4096 Mar 25  2011 11.2.0

drwxr-x---.  3 oracle oinstall 4096 Apr  1  2011 admin

drwxr-x---.  5 oracle oinstall 4096 Apr  1  2011 cfgtoollogs

drwxr-xr-x.  2 oracle oinstall 4096 Mar 31  2011 checkpoints

drwxrwxr-x.  6 oracle asmadmin 4096 Apr  1  2011 diag

drwxrwxr-x. 76 oracle oinstall 4096 Feb 23 09:34 oracle

 

[oracle@bspdev diag]$ ls

asm  asmtool  rdbms  tnslsnr

[oracle@bspdev diag]$ cd rdbms

[oracle@bspdev rdbms]$ ls

ora11g

[oracle@bspdev rdbms]$ cd ora11g

[oracle@bspdev ora11g]$ ls

i_1.mif  ora11g

[oracle@bspdev ora11g]$ cd ora11g

[oracle@bspdev ora11g]$ ls

alert  cdump  hm  incident  incpkg  ir  lck  metadata  stage  sweep  trace

 

 

$ORACLE_BASE目錄下,存在diag資料夾,裡面儲存如asmasmtoolrdbmsTNS listener等重要元件的日誌資訊。針對每一個元件,又按照告警檔案、跟蹤檔案和dump等分類進行組織

 

Diag目錄實際上就形成了一個輸出日誌資訊資料庫,所有的診斷資訊和日誌資訊都在該目錄中進行分類儲存。此外,Oracle推出了ADRCI工具,可以統一的使用介面命令檢查日誌和管理診斷資訊。

 

 

ora11g:/home/ora11g>adrci

 

ADRCI: Release 11.2.0.1.0 - Production on Mon May 21 13:56:53 2012

 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

 

ADR base = "/nbsdu01/app/oracle"

adrci>

 

 

透過命令列adrci,我們可以在統一的命令列中進行診斷資訊管理。

 

 

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

 

 

2、檢視日誌資訊

 

在使用adrci的過程中,要注意當前homepath的問題。每個Oracle元件,都存在一個診斷資訊目錄。

 

 

ADR base = "/nbstu01/app/oracle"

adrci> show homepath

ADR Homes:

diag/rdbms/nbstest/NBSTEST

diag/tnslsnr/P550_05_LC/listener

 

 

要注意,如果要進入具體的那個元件檢視日誌資訊和診斷資訊,首先需要設定homepath到一個元件目錄裡面。上面的兩個ADR home中,是Oracle資料庫和監聽器兩個元件。如果我們要檢視資料庫日誌,需要如下的配置。

 

 

adrci> set homepath diag/rdbms/nbstest/NBSTEST

 

adrci> show alert -TAIL 10

2012-05-21 15:37:59.861000 +08:00

Thread 1 cannot allocate new log, sequence 2319

Private strand flush not complete

  Current log# 2 seq# 2318 mem# 0: /nbstdata01/oradata/NBSTEST/redo02a.log

  Current log# 2 seq# 2318 mem# 1: /nbstdata02/oradata/NBSTEST/redo02b.log

2012-05-21 15:38:02.931000 +08:00

Thread 1 advanced to log sequence 2319 (LGWR switch)

  Current log# 1 seq# 2319 mem# 0: /nbstdata01/oradata/NBSTEST/redo01a.log

  Current log# 1 seq# 2319 mem# 1: /nbstdata02/oradata/NBSTEST/redo01b.log

2012-05-21 15:49:34.382000 +08:00

Thread 1 cannot allocate new log, sequence 2320

Private strand flush not complete

  Current log# 1 seq# 2319 mem# 0: /nbstdata01/oradata/NBSTEST/redo01a.log

  Current log# 1 seq# 2319 mem# 1: /nbstdata02/oradata/NBSTEST/redo01b.log

2012-05-21 15:49:37.420000 +08:00

Thread 1 advanced to log sequence 2320 (LGWR switch)

  Current log# 3 seq# 2320 mem# 0: /nbstdata01/oradata/NBSTEST/redo03a.log

  Current log# 3 seq# 2320 mem# 1: /nbstdata02/oradata/NBSTEST/redo03b.log

2012-05-21 16:03:48.579000 +08:00

Thread 1 cannot allocate new log, sequence 2321

Private strand flush not complete

  Current log# 3 seq# 2320 mem# 0: /nbstdata01/oradata/NBSTEST/redo03a.log

  Current log# 3 seq# 2320 mem# 1: /nbstdata02/oradata/NBSTEST/redo03b.log

2012-05-21 16:03:51.656000 +08:00

Thread 1 advanced to log sequence 2321 (LGWR switch)

  Current log# 2 seq# 2321 mem# 0: /nbstdata01/oradata/NBSTEST/redo02a.log

  Current log# 2 seq# 2321 mem# 1: /nbstdata02/oradata/NBSTEST/redo02b.log

 

 

上面命令show alert顯示的內容是資料庫元件日誌alert資訊。注意,此處我們也可以使用tail –n 命令,但是後面的數字表示的是日誌的條目數,而不是記錄行數!

 

3、檢視incidentproblem資訊

 

在很多時候,資料庫元件生成的錯誤事件資訊,都是以診斷資訊的形式產生出來。利用ADRCI,可以方便的對這些資訊進行檢視。

 

 

adrci> show incident

 

ADR Home = /nbstu01/app/oracle/diag/rdbms/nbstest/NBSTEST:

*************************************************************************

INCIDENT_ID          PROBLEM_KEY                                                 CREATE_TIME                             

-------------------- ----------------------------------------------------------- ----------------------------------------

41385                ORA 445                                                     2011-07-03 00:47:52.612000 +08:00      

73745                ORA 3137 [12333]                                            2011-09-08 09:23:38.004000 +08:00      

74145                ORA 3137 [12333]                                            2011-09-08 10:45:20.543000 +08:00      

74225                ORA 3137 [12333]                                            2011-09-08 10:52:21.273000 +08:00      

74217                ORA 3137 [12333]                                            2011-09-08 10:58:45.016000 +08:00      

73753                ORA 3137 [12333]                                            2011-09-08 11:09:32.727000 +08:00      

74073                ORA 3137 [12333]                                            2011-09-08 12:52:20.201000 +08:00      

74089                ORA 3137 [12333]                                            2011-09-08 12:55:07.228000 +08:00      

74074                ORA 3137 [12333]                                            2011-09-08 12:59:46.138000 +08:00      

74075                ORA 3137 [12333]                                            2011-09-08 13:00:38.048000 +08:00      

74457                ORA 3137 [12333]                                            2011-09-08 13:02:44.184000 +08:00       

73841                ORA 3137 [12333]                                            2011-09-08 14:39:46.547000 +08:00      

153367               ORA 445                                                     2012-03-02 19:01:31.854000 +08:00      

153368               ORA 445                                                     2012-03-02 23:14:56.008000 +08:00      

14 rows fetched

 

adrci>

 

adrci> show problem

 

ADR Home = /nbstu01/app/oracle/diag/rdbms/nbstest/NBSTEST:

*************************************************************************

PROBLEM_ID           PROBLEM_KEY                                                 LAST_INCIDENT        LASTINC_TIME                            

-------------------- ----------------------------------------------------------- -------------------- ----------------------------------------

1                    ORA 445                                                     153368               2012-03-02 23:14:56.008000 +08:00      

2                    ORA 3137 [12333]                                            73841                2011-09-08 14:39:46.547000 +08:00      

2 rows fetched

 

 

4、生成診斷package

 

對於一些incident,我們是無法進行診斷處理的,需要協同Oracle Support進行檢查除錯。這個時候,我們可以利用ADRCI工具將錯誤incident打包成package傳送給Oracle客戶服務人員。

 

打包package的步驟分為logical packagephysical package兩個大步驟。具體如下:

 

--對事件74073建立邏輯包

adrci> ips create package incident 74073

Created package 1 based on incident id 74073, correlation level typical

 

--同時將153368事件也加入到package 1中;

adrci> ips add incident 153368 package 1

Added incident 153368 to package 1

 

 

最後,將Logical Package輸出為Physical Package

 

 

adrci> host

$ pwd

/home/oracle

 

$ exit

adrci> ips generate package 1 in /home/oracle

Generated package 1 in file /home/oracle/ORA313712_20120521160458_COM_1.zip, mode complete

 

oracle:/home/oracle>ls -l | grep ORA

-rw-r--r--    1 oracle   dba         3072148 May 21 16:08 ORA313712_20120521160458_COM_1.zip

 

 

我們就可以直接將給zip包傳送出去,作為診斷材料。

 

5purge命令

 

診斷跟蹤資訊是一個單項積累的過程。當診斷資訊和日誌資訊過多的時候,就可能會給系統一些負面影響。比較方便的做法是週期性的進行檢查,將不需要的診斷資訊刪除。

 

在沒有adrci的時候,我們不得不分別到所有的目錄裡面進行清理。但是藉助adrcipurge命令和control配置,可以方便的進行整理。

 

 

Purge命令自身帶有三個操作模式,進入一個特定ADR目錄後,可以刪除特定incident、特定時間範圍和診斷檔案型別。語法結構如下:

 

 

purge [[-i {id | start_id end_id}] | [-age mins [-type      {ALERT|INCIDENT|TRACE|CDUMP|HM}]]]

 

 [[-i {id1 | start_id end_id}]

 Purges either a specific incident ID (id) or a range of incident IDs (start_id and end_id)

 

[-age mins]

 Purges only data older than mins minutes.

 

[-type    {ALERT|INCIDENT|TRACE|CDUMP|HM}]

 Specifies the type of diagnostic data to purge (alert log messages, incident data, trace files (including dumps), core files, or Health Monitor run data and reports).

 

 

如刪除20分鐘前的所有資訊。

 

 

adrci> purge -age 20         

adrci>

 

adrci> purge -age 20         

adrci> show tracefile

     diag/rdbms/ora11g/ora11g/trace/tautltest.txt

     diag/rdbms/ora11g/ora11g/trace/alert_ora11g.log

     diag/rdbms/ora11g/ora11g/trace/squtltest.txt

     diag/rdbms/ora11g/ora11g/trace/tasqdirset.txt

 

 

除了手工進行刪除外,Oracle ADR還提供了刪除策略,透過control進行配置。

 

 

adrci> show homepath

ADR Homes:

diag/asm/user_oracle/host_1437849207_76

diag/rdbms/ora11g/ora11g

diag/asmtool/user_root/host_1437849207_76

diag/asmtool/user_oracle/host_1437849207_76

diag/tnslsnr/bspdev/listener

diag/tnslsnr/bspdev/listener_ora11g

adrci> set homepath diag/rdbms/ora11g/ora11g

adrci> show home

ADR Homes:

diag/rdbms/ora11g/ora11g

adrci> show control

 

ADR Home = /u01/app/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-04-01 10:13:25.436450 -04:00        2012-05-15 20:08:26.781034 -04:00                                                 1                    2                    76                   1                    2011-04-01 10:13:25.436450 -04:00      

1 rows fetched

 

 

6、結論

 

Oracle 11g中,一些小工具的推出幫助我們方便解決一些繁瑣的工作。使用ADRCI,可以讓我們的診斷過程更加方便。

 

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

相關文章