Oracle 11g 中使用adrci看alert日誌

來源:互聯網
上載者:User

Oracle 11g 中使用adrci看alert日誌

1  認識adrci

這個命令可以查看報錯資訊和日誌,伴隨著11g trace目錄換位置之後一起提供給我們的。這個工具不僅能像vi一樣對日誌進行編輯。還能像tail -f 一樣查看記錄檔。

而且可以跨平台,在windows上也可以使用。

--------------------------------------分割線 --------------------------------------

在CentOS 6.4下安裝Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虛擬機器中安裝步驟

Debian 下 安裝 Oracle 11g XE R2

--------------------------------------分割線 --------------------------------------

下面示範幾種adrci的常用用法。

1.1  查看命令位置

$ which adrci

/u01/app/oracle/product/11.2.0/dbhome_1/bin/adrci

1.2  為命令設定別名

rlwrap工具可以上下翻動自己剛才執行的命令

$ grep adrci .bash_profile

alias adrci='rlwrap adrci'

1.3  查看help

$ adrci -help

Syntax:

adrci [-help] [script=script_filename]

[exec = "one_command [;one_command;...]"]

Options      Description                    (Default)

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

script      script file name              (None)

help        help on the command options    (None)

exec        exec a set of commands        (None)

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

從help可以看出他的文法可以是類似下面這樣的:

1.3.1  直接執行命令

$ adrci exec="show alert"

1.3.2  指定指令碼命令

$ cat /tmp/abc.txt

show alert

$ adrci script = /tmp/abc.txt

$ adrci

ADRCI: Release 11.2.0.3.0 - Production on Fri Jun 6 11:45:39 2014

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

ADR base = "/u01/app/oracle"

adrci>

2  使用adrci

2.1  查看help

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.2  查看home

從help中可以看出,show 後面可以接home homes homepath 這三個參數,也就是說這三個參數其實顯示了同一個內容。

註:這裡的home並不是$ORACLE_HOME

adrci> show home

ADR Homes:

diag/rdbms/orcl/orcl

diag/asm/+asm/+ASM

diag/tnslsnr/oracle11g/listener

adrci> show homes

ADR Homes:

diag/rdbms/orcl/orcl

diag/asm/+asm/+ASM

diag/tnslsnr/oracle11g/listener

adrci> show homepath

ADR Homes:

diag/rdbms/orcl/orcl

diag/asm/+asm/+ASM

diag/tnslsnr/oracle11g/listener

2.3  列出home下面的日誌(show alert)

像這種show alert 的方式可以理解為使用vi開啟記錄檔。

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 be double 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, new data

will append at the end as new alert messages are generated.

[-term]: Direct results to terminal. If this option is not specified,

the results will be open in an editor.

By default, it will open in emacs, but "set editor" can be used

to set other editors.

[-file <alert_file_name>]: Allow users to specify an alert file which

may not be in ADR. <alert_file_name> must be specified with full path.

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

2.3.1  查看所有目錄中的日誌

adrci> show alert

Choose the alert log from the following homes to view:

1: diag/rdbms/orcl/orcl

2: diag/asm/+asm/+ASM

3: diag/tnslsnr/oracle11g/listener

Q: to quit

Please select option:

2.3.2  查看自訂目錄下的日誌

這個時候有4個選項可以供我們選擇,分別是資料庫,asm,監聽器的記錄檔。同樣也可以設定單獨的home,比如

adrci> set home diag/rdbms/orcl/orcl

adrci> show alert    //類似vi編輯意義昂

2.3.3  動態查看定義目錄下的日誌

一定要先設定目錄,不然不能查看,會得到以下錯誤,所以應該先設定home

adrci> show alert -tail -f

DIA-48449: Tail alert can only apply to single ADR home

adrci> sethome diag/rdbms/orcl/orcl

adrci> show alert -tail -f

用ctrl - c 方式可以退出動態查看

這個命令有點熟悉,類似於Linux中的“tail -f 檔案名稱”,這裡的“show alert -tail -”f 同樣適用於Windows

2.3.4  查看alert日誌中包含ORA-的字串

這個文法可以查看協助(前面有列出),其中-p參數可以跟基於XXX的資訊,比如下面是基於包含ORA- 的資訊

adrci> show alert -p "MESSAGE_TEXT like '%ORA-%'"

更多詳情見請繼續閱讀下一頁的精彩內容:

  • 1
  • 2
  • 下一頁

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.