您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關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; "
感謝各位的閱讀!關于“adrci命令怎么用”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。