执行健康检查做健康监控

MicrosoftInternetExplorer402DocumentNotSpecified7.8Normal0

执行健康检查做健康监控

关于健康监控包含如下的主题:

关于健康监控

手动执行监控检查

查看检查报告

健康监控视图

健康检查参数说明

关于健康监控

Oracle 11G 开始,引入了一个健康监控的架构,执行数据库健康诊断。

关于健康检查

健康监控检查各种数据库的组件。健康检查发现文件损坏,物理和逻辑坏块,undoredo的损坏,数据字典损坏(file corruptions, physical and logical block corruptions, undo and redo corruptions, data dictionary corruptions) 等。健康检查根据检查的内容会生成检查报告。健康检查可以有如下两种执行方法:

Reactive -- 当数据库遇到危险的错误,故障诊断结构会自动调用健康检查。

Manual -- 可以手动的执行健康检查,通过DBMS_HM包或者 OEM 

健康监控检查报告建议等信息保存在ADRAutomatic Diagnostic Repository)中。

SQL> set linesize 100

SQL> select * from v$diag_info where NAME='Health Monitor';

   INST_ID NAME                 VALUE

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

         1 Health Monitor       /u01/app/oracle/diag/rdbms/orcl/orcl/hm

SQL> 

SQL> ! ls /u01/app/oracle/diag/rdbms/orcl/orcl/hm

HMREPORT_HM_RUN_1.hm  HMREPORT_HM_RUN_4161.hm  HMREPORT_HM_RUN_4461.hm  HMREPORT_xhl.hm

监控检查可以运行在两种模式:

DB-online :检查需要运行在数据库打开状态。(这里是 OPEN or MOUNT)。

DB-offline :检查需要运行在数据库 NOMOUNT 状态。

REDO完整性检查和DB结构完整性检查需要可以运行在 DB-offline 模式。其他的都是 DB-online 模式。

健康检查类型

健康检查可以执行如下:

数据库结构完整性检查:检查数据文件不一致、损坏、无法访问等。Mount open 状况检查 全库的,nomount 状态只能检查控制文件。

数据块完整性检查:检查磁盘数据块(disk image block)损坏,包括校验和失败,块头未不 匹配(分裂块),块逻辑不一致。多数可以通过块媒介恢复(RMAN)。检查到的损坏块会捕获到V$DATABASE_BLOCK_CORRUPTION视图中。This check does not detect inter-block or inter-segment corruption.

重做完整性检查:扫描重做的内容检查,可以检查重做日志、归档日志。

回滚段完整性检查:检查逻辑回滚错误,定位undo错误,使用PMON或者SMON 复错误的事务。如果恢复失败信息会记录在 V$CORRUPT_XID_LIST. 视图中。大多可 以通过强制提交解决。

事务处理完整性检查:与回滚段完整性检查一样,这个以事务为单位。

字典完整性检查:检查字典的完整性。

控制文件完整性检查:检查控制文件块的完整性

手动执行健康检查

两种方式执行健康监控检查:

使用 DBMS_HM 

使用 OEM 

使用 DBMS_HM 包执行健康检查

如下所示:

BEGIN

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

END;

/

PROCEDURE RUN_CHECK

 Argument Name                  Type                    In/Out Default?

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

 CHECK_NAME                     VARCHAR2                IN

 RUN_NAME                       VARCHAR2                IN     DEFAULT

 TIMEOUT                        NUMBER                  IN     DEFAULT

 INPUT_PARAMS                   VARCHAR2                IN     DEFAULT

获得健康检查名称执行如下查询:

SQL> col name format a50

SQL> SELECT name FROM v$hm_check WHERE internal_check='N';

NAME

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

DB Structure Integrity Check

CF Block Integrity Check

Data Block Integrity Check

Redo Integrity Check

Transaction Integrity Check

Undo Segment Integrity Check

Dictionary Integrity Check

ASM Allocation Check

8 rows selected.

注:我的数据库版本为 11.2.0.2.2 可以看到这里多了几个,随着版本的更新健康检查会逐步完善的。

一些检查需要输入检查参数,可以通过 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;

如下为需要参数的检查的示例:

BEGIN

  DBMS_HM.RUN_CHECK (

   check_name   => 'Transaction Integrity Check',

   run_name     => 'my_run',

   input_params => 'TXN_ID=7.33.2');

END;

/

使用OEM执行健康检查

进入OEM ,进入可用性页面

选择指导中心

查看检查报告

查看检查报告方式和查看内容格式如下:

Report Viewing Method

Report Formats Available

Enterprise Manager

HTML

DBMS_HM PL/SQL package

HTML, XML, and text

ADRCI utility

XML

OEM查看不在介绍。

使用 DBMS_HM 包查看

SET LONG 100000

SET LONGCHUNKSIZE 1000

SET PAGESIZE 1000

SET LINESIZE 512

SELECT DBMS_HM.GET_RUN_REPORT('HM_RUN_1061') FROM DUAL;

FUNCTION GET_RUN_REPORT RETURNS CLOB

 Argument Name                  Type                    In/Out Default?

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

 RUN_NAME                       VARCHAR2                IN

 REPORT_TYPE                    VARCHAR2                IN     DEFAULT

 REPORT_LEVEL                   VARCHAR2                IN     DEFAULT

ADRCI工具查看

adrci>>

show hm_run

create report hm_run run_name

show report hm_run run_name

具体见 ADRCI 工具说明。

健康监控视图

可以通过查看视图来替代生产报告。可以通过如下的视图获得这些可用的信息 V$HM_RUNV$HM_FINDINGV$HM_RECOMMENDATION

V$HM_RUN 查询所有的检查

V$HM_FINDING 查询检查发现的问题

V$HM_RECOMMENDATION 查询报告的建议

健康检查参数说明

Table 9-6 Parameters for Data Block Integrity Check

Parameter Name

Type

Default Value

Description

BLC_DF_NUM

Number

(none)

Block datafile 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.

关于 健康 检查的MOS文章:

Additional Information On The Health Monitor Feature And How To Disable The Reactive Jobs [ID 1312723.1]

alter system set "_diag_hm_rc_enabled"=false;               ==>关闭health monitor

How To Purge or Delete Health Monitor Checks After DBMS_HM.RUN_CHECK ? [ID 951022.1]

Solution

 The Health Checks Reports can be purged using the following options :

1 - Using the Purge command in the ADRCI Utility :
1. Ensure that the ORACLE_HOME and PATH environment variables are set properly.
The PATH environment variable must include ORACLE_HOME/bin.
2. Enter the following command at the operating system command prompt:
ADRCI
The utility starts and displays the following prompt:
adrci>
3. View the Health Monitor Runs so far:

adrci> show hm_run
4. The following command will purge diagnostic data in the current ADR home which are of type HM (Health Monitor):

adrci> purge -age 1 -type HM


5. Enter one of the following commands to exit ADRCI:

adrci> EXIT
or
 adrci> QUIT


The -age option purges only data older than number of minutes specified .
If multiple homes are current, then error <> can be raised ,
For further explanation of the error, please reference:
Note 951023.1- DIA-48448 When Executing PURGE command in ADRCI Utility


OR

2 - Using undocumented procedure of DBMS_HM package:

SQL> exec DBMS_HM.DROP_SCHEMA();


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25475140/viewspace-748865/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25475140/viewspace-748865/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值