一、警报条件监视和通知
警报系统在空间管理方面,默认的配置是在考虑自动扩展和内容本质的情况下,当表空间达到全满的85%时,将引发警告性报警。当表空间达到全满的97%时,将发出严重报警。
警报有两种形式,有状态警报基于持久保存且可以修复的条件。如表空间的使用、挂起的会话数量,或执行完SQL语句需要的平均时间。无状态警报基于事件,事件发生后又消失了。如查询因快照过旧而失败,或两个形成死锁的事务。
要配置警报系统,用户需要设置阈值,阈值存储在AWR中。此后MMON后台进程将实时监视数据库和实例,并将当前状态和阈值对比,如果超出阈值,就引发警报,而引发警报的机制就是将条目放在警报队列中。队列是一个可供其他进程读取的消息表。下一步对警报消息的处理方式的默认行为是Enterprise Manager读取消息使消息出列,并显示在数据库主页中。也可以配置在发现警报时发送电子邮件或SMS消息。
可以通过查询视图dba_outstanding_alerts查看警报信息:
col creation_time for a20
col host_id for a20
col object_name for a20
col object_type for a20
col reason for a100
col suggested_action for a50
col message_group for a20
select to_char(creation_time, 'yyyy-mm-dd hh24:mi:ss') creation_time, host_id, instance_name, object_name, object_type, reason, metric_value, suggested_action, message_type, message_group, message_level from dba_outstanding_alerts;
有状态警报的默认通知机制仅仅是在Enterprise Manager的数据库主页上显示警报,并将它们写入dba_outstanding_alerts视图,在消除之前,警报一直可见。在警报清除时,系统将警报从dba_outstanding_alerts视图中删除,并转入dba_alert_history视图。而无状态警报(如重做生成率等与活动相关的警报)可能在活动减少时自动清除,其被直接写入历史视图,不会记录到dba_outstanding_alerts中。
通过视图dba_alert_history查看历史警报信息:
col creation_time for a20
col host_id for a20
col object_name for a20
col object_type for a20
col reason for a100
col suggested_action for a50
col message_group for a20
select to_char(creation_time, 'yyyy-mm-dd hh24:mi:ss') creation_time, host_id, instance_name, object_name, object_type, reason, metric_value, suggested_action, message_type, message_group, message_level, resolution from dba_alert_history order by creation_time desc;
二、阈值的设置
可设置警告阈值的指标记录在v$metricname视图中,这样的指标有200多个,不一一列出:
col group_name for a35
col metric_name for a50
col metric_unit for a45
select * from v$metricname;
要查看AWR当前设置的阈值,可查询视图dba_thresholds:
col metrics_name for a50
col object_name for a20
col warning_value for a20
col critical_value for a20
select metrics_name, object_name, status, warning_value, critical_value from dba_thresholds;
通过程序包dbms_server_alert中的过程set_threshold可以设置阈值。
以下举例说明阈值的使用:
1)创建表空间:
create tablespace tbs1 datafile 'd:\oradata\mes\tbs1.dbf' size 10m;
2)查看当前关于表空间管理方面的指标和阈值,此时存在默认的针对所有用户表空间的85%和97%的阈值设置:
select * from v$metricname t where t.metric_name like 'Tablespace%';
select metrics_name, object_name, status, warning_value, critical_value from dba_thresholds where metrics_name like 'Tablespace%';
3)设置表空间TBS1的阈值,空间使用比例大于88%时发出警告,大于98%时发出严重警告:
begin
dbms_server_alert.set_threshold(metrics_id => dbms_server_alert.tablespace_pct_full,
warning_operator => dbms_server_alert.operator_gt,
warning_value => 88,
critical_operator => dbms_server_alert.operator_gt,
critical_value => 98,
observation_period => 1,
consecutive_occurrences => 1,
instance_name => null,
object_type => dbms_server_alert.object_type_tablespace,
object_name => 'TBS1');
end;
/
4)查看新的阈值设置,可以看到增加了单独针对表空间TBS1的阈值设置:
select metrics_name, object_name, status, warning_value, critical_value from dba_thresholds where metrics_name like 'Tablespace%';
5)在TBS1上创建表,并模拟空间数据量的增长:
create table cmes.t1 tablespace tbs1 as select * from all_objects;
6)查看警报记录:
select creation_time, host_id, instance_name, object_name, object_type, reason, metric_value, suggested_action, message_type, message_group, message_level from dba_outstanding_alerts;
三、其它通知方法
如果需要除默认通知外的其他通知,就必须在Enterprise Manager中进行设置。Enterprise Manager通知系统要求三个级别的配置:
- 配置通知方法。其他通知方法包括:操作系统命令或脚本、PL/SQL过程或SNMP陷阱。
- 创建规则来捕获事件。
- 使用户订阅规则。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28974745/viewspace-2146337/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28974745/viewspace-2146337/