【11g】Running Health Checks with Health Monitor

版权声明:所有文章禁止转载但是均可在生产中使用提高效率 https://blog.csdn.net/viviliving/article/details/90209079

Running Health Checks with Health Monitor

本节描述健康监视器,并包括如何使用它的说明。包括以下主题:

About Health Monitor

从11g版本开始,Oracle数据库包含一个名为Health Monitor的框架,用于对数据库运行诊断检查。

About Health Monitor Checks

健康监视器检查(也称为检查程序、健康检查或检查)检查数据库的各个层和组件。健康检查检测文件损坏、物理和逻辑块损坏、撤消和重做损坏、数据字典损坏等等。健康检查产生关于其调查结果的报告,并在许多情况下提出解决问题的建议。健康检查可以通过两种方式进行:

  • reactive—故障诊断基础设施可以在出现严重错误时自动运行健康检查.

  • Manual—您可以使用DBMS_HM PL/SQL包或Enterprise Manager接口手动运行健康检查。如果需要,您可以定期运行检查器,或者Oracle支持可能要求您在处理服务请求时运行检查器。t.

健康监测”检查存储结果、建议和其他信息 Automatic Diagnostic Repository (ADR).

Health checks can run in two modes:

  • DB-online mode means the check can be run while the database is open (that is, in OPEN mode or MOUNT mode).

  • DB-offline mode means the check can be run when the instance is available but the database itself is closed (that is, in NOMOUNT mode).

所有的健康检查都可以在DB-online模式下运行。只有重做完整性检查和DB结构完整性检查才能在DB-脱机模式下使用。

See Also:

"Automatic Diagnostic Repository (ADR)"

健康检查的种类

Health monitor runs the following checks:

  • DB Structure Integrity Check—此检查检查数据库文件的完整性,如果这些文件不可访问、损坏或不一致,则报告失败。如果数据库处于挂载或打开模式,此检查将检查控制文件中列出的日志文件和数据文件。如果数据库处于NOMOUNT模式,则只检查控制文件.

  • Data Block Integrity Check—此检查检测磁盘映像块的损坏,如校验和失败、头尾不匹配和块内的逻辑不一致。大多数损坏可以使用块媒体恢复修复。损坏的块信息也在V$DATABASE_BLOCK_CORRUPTION视图中捕获。此检查不检测块间或段间损坏。

  • Redo Integrity Check—此检查将扫描重做日志的内容,以确定可访问性和损坏性,如果可用,还将扫描存档日志。重做完整性检查报告失败,如归档日志或重做损坏。

  • Undo Segment Integrity Check—此检查发现逻辑撤消损坏。定位撤消损坏后,此检查使用PMON和SMON尝试恢复损坏的事务。如果恢复失败,那么Health Monitor将在V$ corrupt t_xid_list中存储关于损坏的信息。大多数撤销损坏都可以通过强制提交来解决。

  • Transaction Integrity Check—此检查与撤消段完整性检查相同,只是它只检查一个特定的事务。

  • Dictionary Integrity Check—该检查检查核心dictionary对象(如tab$和col$)的完整性。它执行以下操作:

    • Verifies the contents of dictionary entries for each dictionary object.

    • Performs a cross-row level check, which verifies that logical constraints on rows in the dictionary are enforced.

    • Performs an object relationship check, which verifies that parent-child relationships between dictionary objects are enforced.

    The Dictionary Integrity Check operates on the following dictionary objects:

    tab$clu$fet$uet$seg$undo$ts$file$obj$ind$icol$col$user$con$cdef$ccol$bootstrap$objauth$ugroup$tsq$syn$view$typed_view$superobj$seq$lob$coltype$subcoltype$ntab$refcon$opqtype$dependency$access$viewcon$icoldep$dual$sysauth$objpriv$defrole$, and ecol$.

Running Health Checks Manually

Health Monitor提供了两种手动运行健康检查的方法:

  • By using the DBMS_HM PL/SQL package

  • By using the Enterprise Manager interface, found on the Checkers subpage of the Advisor Central page

使用DBMS_HM PL/SQL包运行健康检查

The DBMS_HM procedure for running a health check is called RUN_CHECK. To call RUN_CHECK, supply the name of the check and a name for the run, as follows:

BEGIN
  DBMS_HM.RUN_CHECK('Dictionary Integrity Check', 'my_run');
END;
/

To obtain a list of health check names, run the following query:

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

大多数健康检查接受输入参数。您可以使用V$HM_CHECK_PARAM视图查看参数名称和描述。有些参数是强制性的,有些参数是可选的。如果省略了可选参数,则使用默认值。以下查询显示所有健康检查的参数信息:

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;

输入参数在input_params参数中作为名称/值对传递,以分号(;)分隔。下面的例子演示了如何将事务ID作为参数传递给事务完整性检查:

BEGIN
  DBMS_HM.RUN_CHECK (
   check_name   => 'Transaction Integrity Check',
   run_name     => 'my_run',
   input_params => 'TXN_ID=7.33.2');
END;
/

See Also:

使用Enterprise Manager运行健康检查

Enterprise Manager provides an interface for running Health Monitor checkers.

To run a Health Monitor Checker using Enterprise Manager:

  1. On the Database Home page, in the Related Links section, click Advisor Central.

  2. Click Checkers to view the Checkers subpage.

  3. In the Checkers section, click the checker you want to run.

  4. Enter values for input parameters or, for optional parameters, leave them blank to accept the defaults.

  5. Click Run, confirm your parameters, and click Run again.

Viewing Checker Reports

运行检查程序后,可以查看它的执行报告。报告包含调查结果、建议和其他信息。您可以使用Enterprise Manager、ADRCI实用程序或DBMS_HM PL/SQL包查看报表。下表显示了每种查看方法可用的报告格式。

Report Viewing Method Report Formats Available
Enterprise Manager HTML
DBMS_HM PL/SQL package HTML, XML, and text
ADRCI utility XML

检查器运行的结果(结果、建议和其他信息)存储在ADR中,但不会立即生成报告。当你请求报告DBMS_HM PL / SQL包或与企业经理,如果报告还不存在,这是第一次从ADR的检查程序运行数据生成,存储为XML格式的报表文件HM ADR回家当前实例的子目录,然后显示出来. 如果报告文件已经存在,则只显示它。在使用ADRCI实用程序时,必须首先运行一个命令来生成报告文件(如果报告文件不存在),然后运行另一个命令来显示报告文件的内容。

The preferred method to view checker reports is with Enterprise Manager. The following sections provide instructions for all methods:

See Also:

"Automatic Diagnostic Repository (ADR)"

使用Enterprise Manager查看报表

您还可以使用Enterprise Manager查看特定检查器运行时的健康监测报告和结果

To view run findings using Enterprise Manager

  1. Access the Database Home page.

    For Oracle Enterprise Manager Database Control, see Oracle Database 2 Day DBA for instructions. For Oracle Enterprise Manager Grid Control, go to the desired database target.

  2. In the Related Links section, click Advisor Central.

  3. Click Checkers to view the Checkers subpage.

  4. Click the run name for the checker run that you want to view.

    The Run Detail page appears, showing the findings for that checker run.

  5. Click Runs to display the Runs subpage.

    Enterprise Manager displays more information about the checker run.

  6. Click View Report to view the report for the checker run.

    The report is displayed in a new browser window.

Viewing Reports Using DBMS_HM

您可以使用DBMS_HM包函数GET_RUN_REPORT查看健康监视器检查器报告。此函数允许您请求HTML、XML或文本格式。默认格式为文本,如下面的SQL*Plus示例所示:

SET LONG 100000
SET LONGCHUNKSIZE 1000
SET PAGESIZE 1000
SET LINESIZE 512
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:
               '/u01/app/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:
               '/u01/app/oracle/dbs/t_db1.f' is media corrupt
 Message       : Object BMRTEST2 owned by SYS might be unavailable

See Also:

Oracle Database PL/SQL Packages and Types Reference for details on the DBMS_HM package.

使用ADRCI实用程序查看报告

您可以使用ADRCI实用程序创建和查看健康监视器检查器报告。

To create and view a checker report using ADRCI:

  1. Ensure that operating system environment variables (such as ORACLE_HOME) are set properly, and then enter the following command at the operating system command prompt:

    ADRCI
    

    The utility starts and displays the following prompt:

    adrci>>
    

    Optionally, you can change the current ADR home. Use the SHOW HOMES command to list all ADR homes, and the SET HOMEPATH command to change the current ADR home. See Oracle Database Utilities for more information.

  2. Enter the following command:

    show hm_run
    

    This command lists all the checker runs (stored in V$HM_RUN) registered in the ADR repository.

  3. Locate the checker run for which you want to create a report and note the checker run name. The REPORT_FILE field contains a filename if a report already exists for this checker run. Otherwise, generate the report with the following command:

    create report hm_run run_name
    
  4. To view the report, enter the following command:

    show report hm_run run_name
    

See Also:

"Automatic Diagnostic Repository (ADR)"

Health Monitor Views

Instead of requesting a checker report, you can view the results of a specific checker run by directly querying the ADR data from which reports are created. This data is available through the views V$HM_RUNV$HM_FINDING, and V$HM_RECOMMENDATION.

The following example queries the V$HM_RUN view to determine a history of checker runs:

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

The next example queries the V$HM_FINDING view to obtain finding details for the reactive data block check with RUN_ID 1061:

SELECT type, description FROM v$hm_finding WHERE run_id = 1061;

TYPE          DESCRIPTION
------------- -----------------------------------------
FAILURE       Block 64349 in datafile 1: '/u01/app/orac
              le/dbs/t_db1.f' is media corrupt
 
FAILURE       Block 64351 in datafile 1: '/u01/app/orac
              le/dbs/t_db1.f' is media corrupt

See Also:

Health Check Parameters Reference

The following tables describe the parameters for those health checks that require them. Parameters with a default value of (none) are mandatory.

Table 9-6 Parameters for Data Block Integrity Check

Parameter Name Type Default Value Description

BLC_DF_NUM

Number

(none)

Block data file number

BLC_BL_NUM

Number

(none)

Data block number

Table 9-7 Parameters for Redo Integrity Check

Parameter Name Type Default Value Description

SCN_TEXT

Text

0

SCN of the latest good redo (if known)

Table 9-8 Parameters for Undo Segment Integrity Check

Parameter Name Type Default Value Description

USN_NUMBER

Text

(none)

Undo segment number

Table 9-9 Parameters for Transaction Integrity Check

Parameter Name Type Default Value Description

TXN_ID

Text

(none)

Transaction ID

Table 9-10 Parameters for Dictionary Integrity Check

Parameter Name Type Default Value Description

CHECK_MASK

Text

ALL

Possible values are:

  • COLUMN_CHECKS—Run column checks only. Verify column-level constraints in the core tables.

  • ROW_CHECKS—Run row checks only. Verify row-level constraints in the core tables.

  • REFERENTIAL_CHECKS—Run referential checks only. Verify referential constraints in the core tables.

  • ALL—Run all checks.

TABLE_NAME

Text

ALL_CORE_TABLES

Name of a single core table to check. If omitted, all core tables are checked.

猜你喜欢

转载自blog.csdn.net/viviliving/article/details/90209079