ADRCI命令

jichengjie發表於2017-08-02

一、adrci說明 


    在oracle11g中,dump file的目錄已經有所改變,bdump和udump整合到trace中,cdump獨立出一個。 
oracle新增了一個ADRCI(Automatic Diagnostic Repository Command Interpreter)的工具, 
統一管理ASM例項和多個資料庫例項的alert檔案、後臺trace檔案、使用者trace檔案,dump檔案等等。 
而且這個工具可以快速查詢錯誤相關的所有trace檔案,並將這些檔案打包到一個zip檔案,以便將問題 
相關的資訊提供給Oracle的技術支援。 

二、檢視檔案 
1)進入、退出adrci 
--顯示幫助 
[root@oratest ~]# su - oracle 
[oracle@oratest ~]$ which adrci 
~/bin/adrci 

[oracle@oratest trace]$ adrci 
ADRCI: Release 11.2.0.3.0 - Production on Wed Dec 23 10:30:26 2015 
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. 
ADR base = "/u01"  
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           ---若非我們想要的目錄,可以指定  set home diag/rdbms/tinadb/tinadb 
ADR Homes: 
diag/rdbms/tinadb/tinadb 

--退出ADRCI: 
adrci>>exit或者quit  回車 
    
--備註 
1.在adrci中命令大小寫不敏感 但使用搜尋串的時候是敏感的,比如:show tracefile %mmon% 

2.在adrci中不能使用退格(backspace)怎麼辦 
跟sqlplus一樣,有下面幾種選擇: 
用del鍵; 
使用Ctrl+backspace; 
使用Ctrl+u刪除整行(bash下); 
在os命令列下stty erase ^h  (可以直接寫到oracle的.profile/.bash_profile下面) 

2)檢視alert日誌 
1.show alert -tail (預設是10條條目) 
2.show alert -tail -f(類似tail -f alertlog一樣) 
3.show alert 
4.show alert -p "MESSAGE_TEXT like '%ORA-%'" 
更多可見 help show alert 
注意,show alert的起始點是在control中設定的保留時間之後的日誌,或者說是purge之後的日誌,之前的日誌無法顯示。 

舉例: 
adrci> show alert -tail -f 
2015-12-23 08:35:13.712000 +08:00 
  Current log# 2 seq# 191 mem# 0: /u01/oradata/tinadb/redo02.log 
Archived Log entry 296 added for thread 1 sequence 190 ID 0x637eb2fb dest 1: 
2015-12-23 08:50:18.242000 +08:00 
Thread 1 advanced to log sequence 192 (LGWR switch) 
  Current log# 3 seq# 192 mem# 0: /u01/oradata/tinadb/redo03.log 
Archived Log entry 297 added for thread 1 sequence 191 ID 0x637eb2fb dest 1: 
2015-12-23 09:05:17.755000 +08:00 
Thread 1 advanced to log sequence 193 (LGWR switch) 
  Current log# 1 seq# 193 mem# 0: /u01/oradata/tinadb/redo01.log 
Archived Log entry 298 added for thread 1 sequence 192 ID 0x637eb2fb dest 1: 
2015-12-23 09:20:20.346000 +08:00 
Thread 1 advanced to log sequence 194 (LGWR switch) 
  Current log# 2 seq# 194 mem# 0: /u01/oradata/tinadb/redo02.log 
Archived Log entry 299 added for thread 1 sequence 193 ID 0x637eb2fb dest 1: 

3)檢視control 
adrci> show control 
ADR Home = /u01/diag/rdbms/tinadb/tinadb: 
************************************************************************* 
ADRID                SHORTP_POLICY        LONGP_POLICY         LAST_MOD_TIME                            LAST_AUTOPRG_TIME                        LAST_MANUPRG_TIME                        ADRDIR_VERSION       ADRSCHM_VERSION      ADRSCHMV_SUMMARY     ADRALERT_VERSION     CREATE_TIME                              
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ---------------------------------------- 
2092229604           720                  8760                 2015-12-09 17:41:58.349021 +08:00        2015-12-23 10:05:32.222256 +08:00                                                 1                    2                    80                   1                    2015-12-09 17:41:58.349021 +08:00       
1 rows fetched 
關於control的設定,除了預設的SHORTP_POLICY為720小時,LONGP_POLICY為8760小時外,我們可以修改這2個時間: 

adrci> set control (SHORTP_POLICY = 360) 
adrci> set control (LONGP_POLICY = 2160) 
adrci> show control 
ADR Home = /u01/diag/rdbms/tinadb/tinadb: 
************************************************************************* 
ADRID                SHORTP_POLICY        LONGP_POLICY         LAST_MOD_TIME                            LAST_AUTOPRG_TIME                        LAST_MANUPRG_TIME                        ADRDIR_VERSION       ADRSCHM_VERSION      ADRSCHMV_SUMMARY     ADRALERT_VERSION     CREATE_TIME                              
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ---------------------------------------- 
2092229604           360                  2160                 2015-12-09 17:41:58.349021 +08:00        2015-12-23 10:05:32.222256 +08:00                                                 1                    2                    80                   1                    2015-12-09 17:41:58.349021 +08:00       

這樣就改成了tracefiles保留360小時,即15天,incident file保留2160小時,即90天。 
上述就是oracle自己保留日誌的期限,我們也可以透過purge這個命令來手工的清空。 


4)快速定位tracefile 
(1)列出所有跟蹤檔案:            show tracefile 
(2)模糊查詢跟蹤檔案,比如某個程式的,注意這裡區分大小寫        show tracefile %mmon% 
(3)可以指定某個路徑              show tracefile %mmon% -path /home/steve/temp 
(4)按時間排序                    show tracefile -rt 

舉例: 
adrci> show tracefile %mmon% 
     diag/rdbms/tinadb/tinadb/trace/tinadb_mmon_7202.trc 
     diag/rdbms/tinadb/tinadb/trace/tinadb_mmon_21083.trc 
     diag/rdbms/tinadb/tinadb/trace/tinadb_mmon_8320.trc 
     diag/rdbms/tinadb/tinadb/trace/tinadb_mmon_4137.trc 

三、定位incident和problem 
常用: 
show incident 
show incident -mode detail -p "incident_id=1" 
show problem 
show problem -p "problem_id=2" 
更多資訊見help show incident或help show problem。 

舉例: 
adrci> show incident 
ADR Home = /u01/diag/rdbms/tinadb/tinadb: 
************************************************************************* 
INCIDENT_ID          PROBLEM_KEY                                                 CREATE_TIME                              
-------------------- ----------------------------------------------------------- ---------------------------------------- 
53353                ORA 600 [krbnpdf_wrngdbid_3]                                2015-12-17 10:09:33.291000 +08:00       
53354                ORA 600 [krbnbeg_norestart]                                 2015-12-17 10:24:52.395000 +08:00       
53355                ORA 600 [krbnpdf_nonid]                                     2015-12-17 10:28:17.766000 +08:00       
53417                ORA 600 [krbnbeg_norestart]                                 2015-12-17 10:32:58.256000 +08:00       
53418                ORA 600 [krbnpdf_nonid]                                     2015-12-17 10:34:22.881000 +08:00       
5 rows fetched 

adrci> show problem 
ADR Home = /u01/diag/rdbms/tinadb/tinadb: 
************************************************************************* 
PROBLEM_ID           PROBLEM_KEY                                                 LAST_INCIDENT        LASTINC_TIME                             
-------------------- ----------------------------------------------------------- -------------------- ---------------------------------------- 
1                    ORA 600 [krbnpdf_wrngdbid_3]                                53353                2015-12-17 10:09:33.291000 +08:00       
2                    ORA 600 [krbnbeg_norestart]                                 53417                2015-12-17 10:32:58.256000 +08:00       
3                    ORA 600 [krbnpdf_nonid]                                     53418                2015-12-17 10:34:22.881000 +08:00       
3 rows fetched 

我們看到有5個incident和3個problem 
problem指的是大的問題,叫criticial error, 一個大問題會由很多小的incidents所導致。所以他們是1:n的關係. 

檢視細節: 
adrci> show incident -mode detail -p "incident_id=53353" 
ADR Home = /u01/diag/rdbms/tinadb/tinadb: 
************************************************************************* 

********************************************************** 
INCIDENT INFO RECORD 1 
********************************************************** 
   INCIDENT_ID                   53353 
   STATUS                        ready 
   CREATE_TIME                   2015-12-17 10:09:33.291000 +08:00 
   PROBLEM_ID                    1 
   CLOSE_TIME                    <NULL> 
   FLOOD_CONTROLLED              none 
   ERROR_FACILITY                ORA 
   ERROR_NUMBER                  600 
   ERROR_ARG1                    krbnpdf_wrngdbid_3 
   ERROR_ARG2                    /u01/oradata/tinadb/system01.dbf 
   ERROR_ARG3                    1669126943 
   ERROR_ARG4                    1668473151 
   ERROR_ARG5                    1669126943 
   ERROR_ARG6                    <NULL> 


四、ips打包 
   將相關的incident的檔案打包給oracle,上傳到SR上。我們這裡用到一個IPS(incident package service)服務。 
我們先建立一個邏輯的package,有以下幾種方式: 

1.什麼引數都不帶,表示以預設的level typical, 裡面無任何內容。 
adrci> ips create package 
Created package 1 without any contents, correlation level typical 

2.加incident引數,指明某個incident。預設level還是typical。 
adrci> ips create package incident 53353 
Created package 2 based on incident id 53353, correlation level typical 

3.加incident引數,指定某個incident,設定level為all。 
adrci> ips create package incident 53354 correlate all 
Created package 3 based on incident id 53354, correlation level al 

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> ips create package problem 1 correlate basic 
Created package 5 based on problem id 1, correlation level basic 

6.加time引數,設定開始時間to結束時間,後面的+8:00表示東八區。 
adrci> ips create package time '2015-12-22 00:00:00' to '2015-12-23 00:00:00' 
Created package 6 based on time range 2015-12-22 00:00:00.000000 +08:00 to 2015-12-23 00:00:00.000000 +08:00, correlation level typical 


還可以追加檔案到PACKAGE 3: 
adrci> ips add new incidents package 3 
Added new incidents to package 3 
adrci> ips add problem 12 package 3 
Added problem 12 to package 3 


五、將包放到實際的物理位置 
adrci> ips generate package 3 
Generated package 3 in file /u01/diag/rdbms/tinadb/tinadb/trace/ORA600krb_20151223104459_COM_1.zip, mode complete 

自定義路徑,加in引數即可: 
adrci>  ips GENERATE PACKAGE 3 in /tmp 
Generated package 3 in file /tmp/ORA600krb_20151223104459_COM_2.zip, mode complete 

注意:ips的呼叫和perl有關。需要預先在os安裝 yum install -y perl 否則這裡會報錯 

有了這個zip包,我們可以直接傳送給oracle技術支援了。 


六、解壓 
最後簡單介紹一下UNPACK命令,這個命令可以將得到的zip檔案解壓到指定目錄: 

adrci> ips get metadata from file /tmp/ORA600krb_20151223104459_COM_2.zip 
IPS metadata from file /tmp/ORA600krb_20151223104459_COM_2.zip: 
---------------------------------------------------------- 
<?xml version="1.0" encoding="US-ASCII"?> 
<PACKAGE> 
    <PACKAGE_ID>3</PACKAGE_ID> 
    <PACKAGE_NAME>ORA600krb_20151223104459</PACKAGE_NAME> 
    <MODE>Complete</MODE> 
    <SEQUENCE>2</SEQUENCE> 
    <LAST_COMPLETE>2</LAST_COMPLETE> 
    <DATE>2015-12-23 11:33:51.703402 +08:00</DATE> 
    <ADR_BASE>/u01</ADR_BASE> 
    <ADR_HOME>/u01/diag/rdbms/tinadb/tinadb</ADR_HOME> 
    <PROD_NAME>rdbms</PROD_NAME> 
    <PROD_ID>tinadb</PROD_ID> 
    <INST_ID>tinadb</INST_ID> 
    <OCM_GUID/> 
    <OCM_ANNOTATION/> 
    <FINALIZED>1</FINALIZED> 
</PACKAGE> 

---------------------------------------------------------- 
adrci> ips unpack file /tmp/ORA600krb_20151223104459_COM_2.zip into /tmp 
Unpacking file /tmp/ORA600krb_20151223104459_COM_2.zip into target /tmp 

七、清除purge 
(1)清除incident,我們可以用purge命令: 
adrci> purge -age 2 

(2)清除problem,我們可以用delete命令: 
adrci> delete from problem where problem_id=1 

(3)清除trace 
adrci> purge -age 1440 -type trace --可以刪除24h以前的trace 

八、命令列執行adrci命令 
[oracle@oratest ~]$ adrci exec="show homes;echo '20070712';echo '';show base; " 

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

相關文章