1. 程式人生 > >ORACLE:Health Monitor

ORACLE:Health Monitor

轉載之:http://space.itpub.net/9466564/viewspace-609039

1. Health Monitor簡介
    Health Monitor是11g裡新增加的特性,用於資料庫的各層和各個組建的診斷檢查。例如可以檢查:檔案損壞、物理邏輯塊損壞、redo和undo故障、資料字典損壞等。HM可以根據檢查的結果產生一個報表,並提供解決問題的建議。
   1.1 執行方式:
    1). Reactive
         Fault diagnosability infrastructure能自動響應嚴重的錯誤(critical error)。
     2). Manually
         可以通過DBMS_HM系統包或 Enterprise Manager來手工執行HM。

    1.2 執行模式


      1). DB-ONLINE
      2). DB-OFFLINE
      所有HM都能在online模式下執行,只有Redo Integrity Check 和 DB Structure Integrity Check能在offline模式下執行。
    
2. HM的型別
    見附件詳細說明
    也可以通過檢視來查詢:
   SQL> SELECT name FROM v$hm_check WHERE internal_check='N';
     NAME
     ----------------------------------------------------------------
     DB Structure Integrity Check
     
Data
 Block Integrity Check
     Redo Integrity Check
     Transaction Integrity Check
     Undo Segment Integrity Check
     Dictionary Integrity Check

3. 手工執行HM
   3.1 通過DBMS_HM系統包
     例如:     BEGIN         DBMS_HM.RUN_CHECK('Dictionary Integrity Check', 'my_run');     END;

     該程式允許有輸入引數,可以通過如下方式查詢:
    SQL>
SELECT c.name check_name, p.name parameter_name, p.type,p.default_value, p.description               FROM v$hm_check_param p, v$hm_check c               WHERE p.check_id = c.id and c.internal_check = 'N'               ORDER BY c.name;

      帶引數例項:
     BEGIN         DBMS_HM.RUN_CHECK (         check_name => 'Transaction Integrity Check',         run_name => 'my_run',         input_params => 'TXN_ID=7.33.2');     END;
    
    3.2 通過OEM允許
          Advisor Central -》Checkers -》 Run

4. 檢視HM報表
   4.1 通過DBMS_HM系統包
     例項:
   SQL>
SET LONG 100000
SQL>SET LONGCHUNKSIZE 1000
SQL>SET PAGESIZE 1000
SQL>SET LINESIZE 512
SQL>SELECT DBMS_HM.GET_RUN_REPORT('HM_RUN_1061')  FROM    DUAL;
     DBMS_HM.GET_RUN_REPORT('HM_RUN_1061')
    -----------------------------------------------------------------------
     Run Name                     : HM_RUN_1061
     Run Id                       : 1061
     Check Name                   : Data Block Integrity Check
     Mode                         : REACTIVE
     Status                       : COMPLETED
     Start Time                   : 2007-05-12 22:11:02.032292 -07:00
     End Time                     : 2007-05-12 22:11:20.835135 -07:00
     Error Encountered            : 0
     Source Incident Id           : 7418
     Number of Incidents Created  : 0
    
    Input Paramters for the Run
     BLC_DF_NUM=1
     BLC_BL_NUM=64349
    
    Run Findings And Recommendations
     Finding
     Finding Name  : Media Block Corruption
     Finding ID    : 1065
     Type          : FAILURE
     Status        : OPEN
     Priority      : HIGH
     Message       : Block 64349 in datafile 1:
                   '/ade/sfogel_emdb/oracle/dbs/t_db1.f' is media corrupt
     Message       : Object BMRTEST1 owned by SYS might be unavailable
     Finding
     Finding Name  : Media Block Corruption
     Finding ID    : 1071
     Type          : FAILURE
     Status        : OPEN
     Priority      : HIGH
     Message       : Block 64351 in datafile 1:
                   '/ade/sfogel_emdb/oracle/dbs/t_db1.f' is media corrupt
     Message       : Object BMRTEST2 owned by SYS might be unavailable

    4.2 通過ADRCI檢視
    adrci> show hm_run
   
    ADR Home = /u01/app/oracle/diag/rdbms/orcl/orcl:
    *************************************************************************
   
    **********************************************************
    HM RUN RECORD 1
    **********************************************************
       RUN_ID                        1
       RUN_NAME                      liang
       CHECK_NAME                    Dictionary Integrity Check
       NAME_ID                       24
       MODE                          0
       START_TIME                    2009-07-13 17:31:46.436329 +08:00
       RESUME_TIME                   <NULL>
       END_TIME                      2009-07-13 17:31:58.773625 +08:00
       MODIFIED_TIME                 2009-07-13 17:31:58.773625 +08:00
       TIMEOUT                       0
       FLAGS                         0
       STATUS                        5
       SRC_INCIDENT_ID               0
       NUM_INCIDENTS                 0
       ERR_NUMBER                    0
       REPORT_FILE                   <NULL>
    1 rows fetched
   
   adrci> create report hm_run liang
    adrci> show report hm_run liang
    <?xml version="1.0" encoding="US-ASCII"?>
    <HM-REPORT REPORT_ID="liang">
        <TITLE>HM Report: liang</TITLE>
        <RUN_INFO>
            <CHECK_NAME>Dictionary Integrity Check</CHECK_NAME>
            <RUN_ID>1</RUN_ID>
            <RUN_NAME>liang</RUN_NAME>
            <RUN_MODE>MANUAL</RUN_MODE>
            <RUN_STATUS>COMPLETED</RUN_STATUS>
            <RUN_ERROR_NUM>0</RUN_ERROR_NUM>
            <SOURCE_INCIDENT_ID>0</SOURCE_INCIDENT_ID>
            <NUM_INCIDENTS_CREATED>0</NUM_INCIDENTS_CREATED>
            <RUN_START_TIME>2009-07-13 17:31:46.436329 +08:00</RUN_START_TIME>
            <RUN_END_TIME>2009-07-13 17:31:58.773625 +08:00</RUN_END_TIME>
        </RUN_INFO>
        <RUN_PARAMETERS>
            <RUN_PARAMETER>TABLE_NAME=ALL_CORE_TABLES</RUN_PARAMETER>
            <RUN_PARAMETER>CHECK_MASK=ALL</RUN_PARAMETER>
        </RUN_PARAMETERS>
        <RUN-FINDINGS/>
   4.3 通過OEM
          Advisor Central -》Checkers-》Runs  -》View Report

5. HM檢視
    除了可以建立一個checker報表外,還可以在ADR裡直接檢視已經產生的報表。可檢視的檢視有:
   
V$HM_RUN,V$HM_FINDING, andV$HM_RECOMMENDATION.
     例如:
    SQL>

SELECT run_id, name, check_name, run_mode, src_incident FROM v$hm_run;

RUN_ID NAME CHECK_NAME RUN_MODE SRC_INCIDENT
---------- ------------ ---------------------------------- -------- ------------
1 HM_RUN_1 DB Structure Integrity Check REACTIVE 0
101 HM_RUN_101 Transaction Integrity Check REACTIVE 6073
121 TXNCHK Transaction Integrity Check MANUAL 0
181 HMR_tab$ Dictionary Integrity Check MANUAL 0
.
.
.
981 Proct_ts$ Dictionary Integrity Check MANUAL 0
1041 HM_RUN_1041 DB Structure Integrity Check REACTIVE 0
1061 HM_RUN_1061 Data Block Integrity Check REACTIVE 7418
SQL> SELECT type, description FROM v$hm_finding WHERE run_id = 1061;
TYPE DESCRIPTION
------------- -----------------------------------------
FAILURE Block 64349 in datafile 1: '/ade/sfogel_e
mdb/oracle/dbs/t_db1.f' is media corrupt

FAILURE Block 64351 in datafile 1: '/ade/sfogel_e
mdb/oracle/dbs/t_db1.f' is media corrupt

Types of Health Checks

Types of Health Checks

Health Check Parameters Reference 01

Health Check Parameters Reference 01

Health Check Parameters Reference 02

Health Check Parameters Reference 02