從Oracle Database11g R1 開始,将忽略傳統的…_DUMP_DEST 初始化參數。ADR 根目錄又稱為ADR 基目錄,其位置由DIAGNOSTIC_DEST 初始化參數設定。如果省略此參數或将其保留為空,資料庫将在啟動時按如下方式設定DIAGNOSTIC_DEST:
如果已設定了環境變量ORACLE_BASE,則将DIAGNOSTIC_DEST 設定為$ORACLE_BASE。
如果未設定環境變量ORACLE_BASE,則将DIAGNOSTIC_DEST 設定為$ORACLE_HOME/log。
同樣資料庫警告日志檔案也一樣
在oracle 11g中,你不能在目錄$ORACLE_BASE/diag/rdbms/$INSTANCE_NAME/$ORACLE_SID/alert中直接讀取alert日志。
而是讀取其中的log.xml檔案,該檔案不是文本檔案。
除了所有标準的資料庫操作資訊外,alert日志裡也包含關于事件的資訊。
你也可以從目錄 $ORACLE_BASE/diag/rdbms/$INSTANCE_NAME/$ORACLE_SID/trace中讀取以前版本的alert日志。
problems和incidents (問題和事件)
圍繞着oracle 11g錯誤診斷結構有兩種新的概念:problems和incidents。
problems:
任何嚴重錯誤稱之為problems,比如ORA-600錯誤,ORA-04031錯誤。所有涉及資料庫problems的源資料都存儲在ADR中。每一個問題配置設定一個關鍵字,以便于辨別和描述問題。問題關鍵字包括oracle錯誤号和錯誤變量值。
是一次問題的産生。一個問題可能會産生多次。每一次就是一個事件。每個事件有它自己的事件ID.
當某一個事件産生時。在資料庫裡做三件事情:
為該事件建立一個告警日志行并配置設定合适安全告警。
在alert日志裡建立相關條目。
收集和存儲診斷資料放置在ADR結構中合适子目錄中。
ADR 基目錄中可以包含多個ADR 主目錄,其中每個ADR 主目錄都是一個根目錄,用于存放特定Oracle 産品或元件的特定執行個體的全部診斷資料。前一張幻燈片的圖形中顯示了資料庫的ADR主目錄位置。
另外,還生成了兩個預警檔案。一個是文本形式的預警檔案(與早期版本Oracle DB 使用的預警檔案非常相似),位于各個ADR 主目錄的TRACE 目錄下。還有一個符合XML 标準的預警消息檔案,存儲在ADR 主目錄内的ALERT 子目錄下。可使用EnterpriseManager 和ADRCI 實用程式檢視文本格式的預警日志(已删除了XML 标記)。
INCIDENT 目錄包含多個子目錄,每個子目錄均以特定意外事件命名,并且僅包含與該意外事件相關的轉儲。
HM 目錄包含由健康狀況螢幕生成的檢查器運作報告。
還有一個METADATA 目錄,其中包含資料檔案庫自身的重要檔案。可以将此目錄比作資料庫字典。可使用ADRCI 查詢此字典。
ADR 指令解釋器(ADRCI) 是一個實用程式,可用于執行支援工作台允許的所有任務(但是僅限于在指令行環境中)。使用ADRCI 實用程式,您還可以檢視ADR 中跟蹤檔案的名稱以及删除了XML 标記、具有和不具有内容篩選功能的預警日志。
此外,還可以使用V$DIAG_INFO列出一些重要的ADR 位置。
<code>SQL> col name </code><code>format</code> <code>a20</code>
<code>SQL> col value </code><code>format</code> <code>a70</code>
<code>SQL> </code><code>set</code> <code>lin 700</code>
<code>SQL> </code><code>select</code> <code>name,value from </code><code>v</code><code>$diag_info;</code>
<code>NAME VALUE</code>
<code>-------------------- ----------------------------------------------------------------------</code>
<code>Diag Enabled TRUE</code>
<code>ADR Base </code><code>/oracle/app/oracle</code>
<code>ADR Home </code><code>/oracle/app/oracle/diag/rdbms/udevasm/udevasm</code>
<code>Diag Trace </code><code>/oracle/app/oracle/diag/rdbms/udevasm/udevasm/trace</code>
<code>Diag Alert </code><code>/oracle/app/oracle/diag/rdbms/udevasm/udevasm/alert</code>
<code>Diag Incident </code><code>/oracle/app/oracle/diag/rdbms/udevasm/udevasm/incident</code>
<code>Diag Cdump </code><code>/oracle/app/oracle/diag/rdbms/udevasm/udevasm/cdump</code>
<code>Health Monitor </code><code>/oracle/app/oracle/diag/rdbms/udevasm/udevasm/hm</code>
<code>Default Trace File </code><code>/oracle/app/oracle/diag/rdbms/udevasm/udevasm/trace/udevasm_ora_10122</code><code>.</code>
<code> </code><code>trc</code>
<code>Active Problem Count 0</code>
<code>Active Incident Coun 0</code>
V$DIAG_INFO 視圖列出了所有重要的ADR 位置:
(1) ADR Base:ADR 基目錄的路徑
(2) ADR Home:目前資料庫執行個體的ADR 主目錄的路徑
(3) Diag Trace:文本預警日志和背景/前台程序跟蹤檔案的位置
(4) Diag Alert:XML 版本的預警日志的位置
(5) …
(6) Default Trace File:會話的跟蹤檔案的路徑。SQL 跟蹤檔案将寫入到這裡。
ADRCI 是一個指令行工具,包含在Oracle Database 版本11g 中引入的故障可診斷性基礎結構中。使用ADRCI,可以:
(1) 檢視自動診斷資料檔案庫(ADR) 中的診斷資料。
(2) 将意外事件和問題資訊打包成zip 檔案,以傳輸到Oracle 技術支援。此操作是使用稱為意外事件打包服務(IPS) 的服務完成的。
ADRCI 具有豐富的指令集,可在互動模式下使用,也可以在腳本中使用。此外,ADRCI 還可以使用與SQL*Plus 執行SQL 腳本和PL/SQL 指令相同的方式執行ADRCI 指令腳本。
打包和以其它方式管理診斷資料的最簡單方法是使用Oracle Enterprise Manager 的支援工作台。ADRCI 提供了一個可代替支援工作台大部分功能的指令行,并添加了一些功能,如列出和查詢跟蹤檔案。
可以使用ADRCI 檢視預警日志檔案的内容。可以選擇更改目前的ADR 主目錄。使用SHOW HOMES 指令列出所有ADR 主目錄,然後使用SET HOMEPATH 指令更改目前的ADR 主目錄。
請確定已正确設定了作業系統環境變量(如ORACLE_HOME),然後在作業系統指令提示符下輸入以下指令:adrci。
然後,使用SHOW ALERT 指令。要限制輸出,可以使用–TAIL 選項檢視最近的記錄。這将顯示預警日志的最後部分(大約20 到30 條消息),然後等待更多消息進入預警日志中。這些剛剛進入到預警日志的消息也會顯示出來。使用此指令,可以對預警日志進行實時監視。按CTRL-C 可停止等待并傳回到ADRCI 提示符處。如果需要,還可以指定要列印的行數。
注:ADRCI 允許您将輸出假脫機到檔案中,與在SQL*Plus 中使用的方法非常相似。
二.ADRCI 使用示例
[oracle@dave dave]$ adrci
ADRCI: Release 11.2.0.3.0 - Production onThu Oct 11 18:34:29 2012
Copyright (c) 1982, 2011, Oracle and/or itsaffiliates. All rights reserved.
ADR base = "/u01/app/oracle"
adrci> show homepath
ADR Homes:
diag/rdbms/dave/dave
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 beused directly by Oracle, type "HELP EXTENDED" to see the list
2.2 檢視alert log
adrci> help show alert
Usage: SHOW ALERT [-p <predicate_string>] [-term]
[ [-tail [num] [-f]] |[-file <alert_file_name>] ]
Purpose: Show alert messages.
Options:
[-p <predicate_string>]: The predicate string must bedouble-quoted.
The fields in the predicate are the fields:
ORIGINATING_TIMESTAMP timestamp
NORMALIZED_TIMESTAMP timestamp
ORGANIZATION_ID text(65)
COMPONENT_ID text(65)
HOST_ID text(65)
HOST_ADDRESS text(17)
MESSAGE_TYPE number
MESSAGE_LEVEL number
MESSAGE_ID text(65)
MESSAGE_GROUP text(65)
CLIENT_ID text(65)
MODULE_ID text(65)
PROCESS_ID text(33)
THREAD_ID text(65)
USER_ID text(65)
INSTANCE_ID text(65)
DETAILED_LOCATION text(161)
UPSTREAM_COMP_ID text(101)
DOWNSTREAM_COMP_ID text(101)
EXECUTION_CONTEXT_ID text(101)
EXECUTION_CONTEXT_SEQUENCE number
ERROR_INSTANCE_ID number
ERROR_INSTANCE_SEQUENCE number
MESSAGE_TEXT text(2049)
MESSAGE_ARGUMENTS text(129)
SUPPLEMENTAL_ATTRIBUTES text(129)
SUPPLEMENTAL_DETAILS text(129)
PROBLEM_KEY text(65)
[-tail [num] [-f]]: Output last part of the alert messages and
output latest messages as the alert log grows. If num is not specified,
the last 10 messages are displayed. If "-f" is specified, newdata
will append at the end as new alert messages are generated.
[-term]: Direct results to terminal. If this option is notspecified, the results will be open inan editor. By default, it will open in emacs, but "set editor" can beused to set other editors.
--如果直接showalert ,會啟用editor模式。
[-file <alert_file_name>]: Allow users to specify an alert filewhich
may not be in ADR. <alert_file_name> must be specified with fullpath.
Note that this option cannot be used with the -tail option
Examples:
show alert
show alert -p "message_text like '%incident%'"
show alert -tail 20
小技巧:
當有多個homepath的時候,我們在使用show alert 時會讓我們選擇。 這樣不友善檢視,我們可以直接先指定我們的homepath,這樣就避免出現這種問題了。 如下:
ADR Homes:
diag/tnslsnr/dave/listener
adrci> show alert
Choose the alert log from the following homes to view:
1: diag/rdbms/dave/dave
2: diag/tnslsnr/dave/listener
Q: to quit
Please select option: 1
adrci> set homepath diag/rdbms/dave/dave
adrci> show alert -tail 20
adrci> showalert -tail
2012-10-11 17:40:04.975000 +08:00
Dumping diagnostic data indirectory=[cdmp_20121011174004], requested by (instance=1, osid=16650 (CJQ0)),summary=[incident=13378].
2012-10-11 17:40:08.193000 +08:00
Restarting dead background process CJQ0
CJQ0 started with pid=22, OS id=23205
Sweep [inc][13458]: completed
2012-10-11 17:40:09.273000 +08:00
Sweep [inc][13378]: completed
Sweep [inc2][13378]: completed
2012-10-11 17:40:10.805000 +08:00
Dumping diagnostic data indirectory=[cdmp_20121011174010], requested by (instance=1, osid=18804),summary=[incident=13458].
2012-10-11 17:41:08.886000 +08:00
Sweep [inc2][13458]: completed
2012-10-11 18:14:32.747000 +08:00
Time drift detected. Please check VKTMtrace file for more details.
adrci> showalert -tail 15
2012-10-11 15:57:01.996000 +08:00
2012-10-11 17:00:05.236000 +08:00
2012-10-11 17:39:24.364000 +08:00
Thread 1 advanced to log sequence 36 (LGWRswitch)
Current log# 3 seq# 36 mem# 0: /u01/app/oracle/oradata/anqing/redo03.log
2012-10-11 17:39:59.093000 +08:00
Exception [type: SIGSEGV, Address notmapped to object] [ADDR:0x0] [PC:0x0, {empty}] [flags: 0x0, count: 1]
2012-10-11 17:40:00.347000 +08:00
Errors in file /u01/app/oracle/diag/rdbms/dave/dave/trace/dave_cjq0_16650.trc (incident=13378):
ORA-07445: exception encountered: core dump[PC:0x0] [SIGSEGV] [ADDR:0x0] [PC:0x0] [Address not mapped to object] []
Errors in file/u01/app/oracle/diag/rdbms/dave/dave/trace/dave_ora_18804.trc (incident=13458):
ORA-07445: °é”è: è¨ [PC:0x0] [SIGSEGV] [ADDR:0x0] [PC:0x0] [Address not mapped toobject] []
Incident details in:/u01/app/oracle/diag/rdbms/dave/dave/incident/incdir_13458/dave_ora_18804_i13458.trc
Incident details in:/u01/app/oracle/diag/rdbms/dave/dave/incident/incdir_13378/dave_cjq0_16650_i13378.trc
Use ADRCI or Support Workbench to packagethe incident.
See Note 411.1 at My Oracle Support forerror and packaging details.
adrci>
adrci> showalert -tail -f
--該指令會顯示最近10條記錄,并時時更新新的log。 可以按CTRL-C來結束等待,傳回ADRCI。
如果直接使用show alert,預設使用editor模式,如vi,是以退出使用vi的指令。可以指定-term參數,直接顯示,而不是打開。 但這樣,如果日志過長,不友善檢視。
ADR Home =/u01/app/oracle/diag/rdbms/dave/dave:
*************************************************************************
Output the results to file:/tmp/alert_26566_1402_dave_1.ado
2012-09-07 13:12:22.622000 +08:00
Starting ORACLE instance (normal)
2012-09-07 13:12:24.456000 +08:00
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Shared memory segment for instancemonitoring created
Picked latch-free SCN scheme 3
Using LOG_ARCHIVE_DEST_1 parameter defaultvalue as USE_DB_RECOVERY_FILE_DEST
Autotune of undo retention is turned on.
IMODE=BR
ILAT =27
LICENSE_MAX_USERS = 0
注意:
show alert的起始點是在control中設定的保留時間之後的日志,或者說是purge之後的日志,之前的日志無法顯示。後文有說明。
adrci> showalert -P "message_text LIKE '%ORA-600%'"
adrci> showalert -P "message_text LIKE '%ORA-27037%'"
Output the results to file:/tmp/alert_26566_1402_dave_7.ado
2012-09-07 13:21:06.387000 +08:00
Errors in file/u01/app/oracle/diag/rdbms/dave/dave/trace/dave_ora_12435.trc:
ORA-00313: open failed for members of loggroup 1 of thread 1
ORA-00312: online log 1 thread 1:'/u01/app/oracle/oradata/dave/redo01.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file ordirectory
Additional information: 3
…
通過ADRCI,我們可以檢視ADR下的所有tracefiles,并可以對這些trace 檔案進行過濾,隻檢視我們關注的資訊。
如: 擷取trace 檔案包含‘mmon’字元串的檔案:
adrci> show tracefile
diag/rdbms/dave/dave/trace/dave_mmon_16622.trc
diag/rdbms/dave/dave/trace/dave_vktm_16598.trc
diag/rdbms/dave/dave/trace/alert_dave.log
diag/rdbms/dave/dave/incident/incdir_8529/dave_mmnl_6039_i8529.trc
diag/rdbms/dave/dave/incident/incdir_13378/dave_cjq0_16650_i13378.trc
diag/rdbms/dave/dave/incident/incdir_13458/dave_ora_18804_i13458.trc
adrci> showtracefile %mmon%
adrci> show incident
INCIDENT_ID PROBLEM_KEY CREATE_TIME
------------------------------------------------------------------------------- ----------------------------------------
8529 ORA 7445 [PC:0x0] 2012-09-12 04:22:16.811000 +08:00
13378 ORA 7445 [PC:0x0] 2012-10-11 17:40:00.347000 +08:00
13458 ORA 7445 [PC:0x0] 2012-10-11 17:40:00.356000 +08:00
3 rows fetched
在2.2.4 節裡,我們通過show alert 檢視了所有的alert log資訊。
show alert的起始點是在control中設定的保留時間之後的日志,或者說是purge之後的日志,之前的日志無法顯示。
ADRCI的purge 指令會清空alert log的内容,注意這裡的内容僅僅是XML的alert log。對于trace目錄下的text 格式的alert log 不會進行清空。 我們在使用purge 時,可以指定alert log中entries保留的時間。 機關是分鐘。
adrci> help purge
Usage: PURGE [[-i <id1> | <id1> <id2>] |
[-age <mins> [-typeALERT|INCIDENT|TRACE|CDUMP|HM|UTSCDMP]]]:
Purpose: Purge the diagnostic data in the current ADR home. If no
option is specified, the default purging policy will be used.
[-i id1 | id1 id2]: Users can input a single incident ID, or a
range of incidents to purge.
[-age <mins>]: Users can specify the purging policy either to all
the diagnostic data or the specified type. The data older than<mins>
ago will be purged
[-type ALERT|INCIDENT|TRACE|CDUMP|HM|UTSCDMP]: Users can specify whattype of data to be purged.
purge
purge -i 123 456
purge-age 60 -type incident
如清除超過60分鐘前的alert log,指令如下:
adrci> purge -age 60 -type ALERT
adrci> show alert -term
這裡已經沒有日志了。 我們手工的制造一條日志。 在檢視:
SQL> alter system switch logfile;
System altered.
2012-10-11 19:39:31.042000 +08:00
Thread 1 advanced to log sequence 37 (LGWRswitch)
Current log# 1 seq# 37 mem# 0: /u01/app/oracle/oradata/anqing/redo01.log
--這裡顯示了我們日志切換的記錄。
adrci> show control
ADRID SHORTP_POLICY LONGP_POLICY
-------------------- ----------------------------------------
3642307927 720 8760
1 rows fetched
--之前格式有點亂,我調整了一下。
官網對這2個參數的解釋:
Attribute Name
Description
SHORTP_POLICY
Number of hours after which to purge ADR contents that have a short life. Default is 720 (30 days).
A setting of 0 (zero) means that all contents that have a short life can be purged. The maximum setting is 35791394. If a value greater than 35791394 is specified, then this attribute is set to 0 (zero).
The ADR contents that have a short life include the following:
Trace files
Core dump files
Packaging information
LONGP_POLICY
Number of hours after which to purge ADR contents that have a long life. Default is 8760 (365 days).
A setting of 0 (zero) means that all contents that have a long life can be purged. The maximum setting is 35791394. If a value greater than 35791394 is specified, then this attribute is set to 0 (zero).
The ADR contents that have a long life include the following:
Incident information
Incident dumps
Alert logs
SHORTP_POLICY 預設是720小時,30天。其控制如下三種檔案的保留時間:
(1) Trace files
(2) Core dump files
(3) Packaging information
LONGP_POLICY預設值是8760小時,即365天,1年,其控制如下三種檔案的保留時間:
(1) Incident information
(2) Incident dumps
(3) Alert logs
修改ADR的保留政策:
adrci> set control (SHORTP_POLICY = 360)
adrci> set control (LONGP_POLICY = 2160)
ADRID SHORTP_POLICY LONGP_POLICY
3642307927 360 2160
關于ADRCI 的更多内容,參考官網手冊:
<a href="http://docs.oracle.com/cd/E11882_01/server.112/e10701/adrci.htm" target="_blank">http://docs.oracle.com/cd/E11882_01/server.112/e10701/adrci.htm</a>
本文轉自xiaocao1314051CTO部落格,原文連結:http://blog.51cto.com/xiaocao13140/1947973 ,如需轉載請自行聯系原作者