• 使用ADRCI (ADR Command Interpreter) 工具查看Oracle alert警告日志


    Oracle11g版本中,alert文件的位置发生了变化,与此同时Oracle提供了一个命令行工具ADRCI,它可以很便利的查看数据库中出现的异常。 通过这个小文儿给大家展示一下使用ADRCI (ADR Command Interface) 在11g中查看Oracle的警告日志的方法。

    1.进入到adrci命令行模式
    ora11g@RHEL53 /home/oracle$ which adrci
    /oracle/u01/app/oracle/product/1101/db/bin/adrci
    ora11g@RHEL53 /home/oracle$ 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)
    ------------------------------------------------------

    ora11g@RHEL53 /home/oracle$ adrci

    ADRCI: Release 11.1.0.6.0 - Beta on Fri Feb 27 15:23:52 2009

    Copyright (c) 1982, 2007, Oracle.  All rights reserved.

    ADR base = "/oracle/u01/app/oracle"
    adrci>

    2.使用 help show alert 命令查看帮助文档
    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> 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

    adrci>

    3.使用 show alert 列出各个目录下的日志目录,输入编号4,系统会自动调用vi编辑器查看数据库的alert日志
    adrci> show alert

    Choose the alert log from the following homes to view:

    1: diag/tnslsnr/RHEL53/listener
    2: diag/clients/user_unknown/host_411310321_11
    3: diag/clients/user_oracle/host_2175824367_11
    4: diag/rdbms/ora11g/ora11g
    Q: to quit

    Please select option:4

    4.另外一种查看方式是,指定具体的 homepath 然后使用“show alert -tail 15”查看对应日志文件的后15行
    adrci> show homepath
    ADR Homes:
    diag/tnslsnr/RHEL53/listener
    diag/clients/user_unknown/host_411310321_11
    diag/clients/user_oracle/host_2175824367_11
    diag/rdbms/ora11g/ora11g
    adrci> set homepath diag/rdbms/ora11g/ora11g
    adrci> show alert -tail 15
    2009-02-27 14:25:05.036000 +08:00
    Starting background process SMCO
    SMCO started with pid=21, OS id=3855
    Starting background process FBDA
    FBDA started with pid=22, OS id=3857
    replication_dependency_tracking turned off (no async multimaster replication found)
    2009-02-27 14:25:07.246000 +08:00
    Starting background process QMNC
    QMNC started with pid=23, OS id=3859
    2009-02-27 14:25:17.325000 +08:00
    db_recovery_file_dest_size of 4096 MB is 0.00% used. This is a
    user-specified limit on the amount of space that will be used by this
    database for recovery-related files, and does not reflect the amount of
    space available in the underlying filesystem or ASM diskgroup.
    2009-02-27 14:25:33.727000 +08:00
    Completed: ALTER DATABASE OPEN
    2009-02-27 14:29:59.158000 +08:00
    Starting background process CJQ0
    CJQ0 started with pid=25, OS id=3892
    adrci>

    5.小结
     使用ADRCI命令可以很好的对各个目录中的日志文件进行集中查看,可以有效的提高工作效率,赞一个,在高度紧张的问题处理环境中这个工具可以有效的提高问题诊断的效率。
    ============

     

    #ADRCI

    11G new feature

    Automatic Diagnostic Repository Command-Interpreter

    ADRCI工具是Oracle11g才推出的新工具,主要用来管理alert文件、trace文件、dump文件、健康监事报告等。

    11g中alert,trace文件的位置发生了变化, 从原来的ORACLE_BASE/admin/INSTANCE_NAME目录变成了ORACLE_BASE/diag/rdbms/DBNAME/INSTANCE_NAME目录。

    Oracle之所以修改了这个跨越多个版本都没有修改过的参数设置,就是因为Oracle在11g中推出了ADRCI。这个工具可以统一管理ASM实例和多个数据库实例的alert文件、后台trace文件、用户trace文件,dump文件等等。

    而且这个工具可以快速查询错误相关的所有trace文件,并将这些文件打包到一个zip文件,以便将问题相关的信息提供给Oracle的技术支持。

    下面是adrci 的一些快速学习的事项

    0. 注意事项, 知识快速整理.

    1. 定位problem,incident

    2. 定位tracefile (user trace file, alert log file)

    3. 生成package

    0. 注意事项, 知识快速整理.

    show alert -tail -f 相关操作的时候需要先 
    set home 因为adrci是多目录操作不然会报错 DIA-48449:Tail alert can only apply to single ADR home 这是为了保证在多实例下不至于造成混乱。 
     
    adrci
    也支持spool 
     
    adrci
    是基于一个叫做fault diagnosability infrastructure(错误诊断框架),这样一个底层框架的,核心的思想就是,通过problemincident来定位错误。 
     
    problem
    incident 是一种相辅相成的关系, problem指的是大的问题,叫criticial error,一个大问题会由很多小的incidents所导致。所以他们是1:n的关系. 
     
    problem 的数据都预先定义在v$diag_critical_error了(应该是,猜的) 
     
    adrci
    > show incident                                                                                                                                                               
     
    ADR
    Home=/u01/app/oracle/diag/rdbms/opt/opt: 
    ************************************************************************* 
    INCIDENT_ID          PROBLEM_KEY                                                 CREATE_TIME                               
    -----------------------------------------------------------------------------------------------------------------------  
    121                  ORA 4031                                                    2010-08-1714:49:59.384000+08:00        
    209                  ORA 4031                                                    2010-08-1714:50:25.980000+08:00        
    2 rows fetched 
     
    adrci
    >                                                                                                                                                                             
    adrci
    >                                                                                                                                                                             
    adrci
    > show problem                                                                                                                                                                
     
    ADR
    Home=/u01/app/oracle/diag/rdbms/opt/opt: 
    ************************************************************************* 
    PROBLEM_ID           PROBLEM_KEY                                                 LAST_INCIDENT        LASTINC_TIME                              
    -------------------------------------------------------------------------------------------------------------------------------------------  
    1                    ORA 4031                                                    209                  2010-08-1714:50:25.980000+08:00        
    1 rows fetched 
     
    ---很容易看到一个04031对应了:  2091212个事件

    1. 如何identified 这以上的problem和incident的tracefile所在位置呢。

    1.先说problem, problem都是记录在alert里的,一般是放在$ORACLE_BASE/diag/rdbms/$DBNAME/$ORACLE_SID/trace/alert_SID.log,  
    可以手动去找,不过adrci提供了更高效的方式,直接吧04031那段记录在TMP文件里。获取的命令是: 
     
    show alert
    -p "message_text like '%ORA-04031%'"#详细 
    show problem
    -p "problem_id=1"# 看某一个problem 
     
    2. incident 相关: 
     
    # INCIDENT_FILE 显示了tracefile的位置。 
    show incident
    -MODE DETAIL -p "incident_id=121"

    2. 定位tracefile (user trace file, alert log file)

    # This example shows all trace files for incidents 1 and 4, under the path /home/steve/temp: 
    show tracefile
    %mmon%-rt 
    # This example shows all trace files for incidents 1 and 4, under the path /home/steve/temp: 
    show tracefile
    -i 14-path /home/steve/temp

    4. 生成 package

    set homepath diag/rdbms/opt/opt 
    方法一 
    ips pack problem
    1 
    方法二 
    # Created package 8 without any contents, correlation level typical 
    ips create
    package 
    Added problem 1 to package8 
    ips add incident
    121package8 
    ips add incident
    209package8 
    ips add file
    /u01/app/oracle/diag/rdbms/opt/opt/trace/opt_dbrm_5035.trc  package8 
    ips generate
    package8 
     
    adrci
    > ips get metadata from file /home/oracle/script/IPSPKG_20110220163312_COM_1.zip                                                                                              
    IPS metadata
    from file /home/oracle/script/IPSPKG_20110220163312_COM_1.zip: 
    ---------------------------------------------------------- 
    <?xml version="1.0" encoding="US-ASCII"?> 
    <PACKAGE> 
       
    <PACKAGE_ID>8</PACKAGE_ID> 
        <PACKAGE_NAME>IPSPKG_20110220163312</
    PACKAGE_NAME> 
       
    <MODE>Complete</MODE> 
        <SEQUENCE>1</
    SEQUENCE> 
       
    <LAST_COMPLETE>1</LAST_COMPLETE> 
        <DATE>2011-02-20 16:37:55.035301 +08:00</
    DATE> 
       
    <ADR_BASE>/u01/app/oracle</ADR_BASE> 
        <ADR_HOME>/
    u01/app/oracle/diag/rdbms/opt/opt</ADR_HOME> 
        <PROD_NAME>rdbms</
    PROD_NAME> 
       
    <PROD_ID>opt</PROD_ID> 
        <INST_ID>opt</
    INST_ID> 
       
    <OCM_GUID/> 
       
    <FINALIZED>1</FINALIZED> 
    </
    PACKAGE> 
     
    ---------------------------------------------------------- 
     
    ips unpack file
    /home/oracle/IPSPKG_20090215012523_COM_1.zip into/home/oracle

    http://space.itpub.net/519536/viewspace-558046

    http://code.google.com/p/mymetalink/wiki/ADRCI

  • 相关阅读:
    GSM Arena 魅族mx四核评测个人翻译
    Oracle Exists用法|转|
    NC公有协同的实现原理|同13的QQ||更新总部往来协同|
    NC客商bd_custbank不可修改账号、名称但可修改默认银行并更新分子公司trigger
    试玩了plsql中test窗口declare声明变量|lpad函数||plsql sql command test window区别|
    使用windows live writer测试
    用友写insert on bd_custbank 触发器和自动更新单位名称2in1
    oracle触发器select into和cursor用法的区别
    |转|oracle中prior的用法,connect by prior,树形目录
    客商增加自动增加银行账户|搞定!||更新使用游标course写法|
  • 原文地址:https://www.cnblogs.com/sopost/p/2851244.html
Copyright © 2020-2023  润新知