Oracle Alerts  与…

来源:互联网 发布:红中麻将源码教程 编辑:程序博客网 时间:2024/04/29 01:20
Oracle Alerts  与 Metrics(警告与度量)说明
      
一.Alerts 和 Metrics说明官方链接:
Monitoring and Tuning the Database
http://docs.oracle.com/cd/E11882_01/server.112/e10897/montune.htm#CACCIHAB

Alerts help you monitor your database. Most alerts notify youofwhen particular metric thresholds are exceeded.For each alert, youcan set critical and warning threshold values. These thresholdvalues are meant to be boundary values that when exceeded, indicatethat the system is in an undesirable state. For example, when atablespace becomes 97 percent full, this can be consideredundesirable, and Oracle Database generates a critical alert.
--Alerts 可以帮助我们监控数据库,大部分alerts 信息都是超过metric thresholds。对于每一个alert,都可以设置critical和 warning threshold值。当系统达到这个alert时,就说明这个指标已经处于异常状态。比如当表空间使用了97%,那么就可以认为已经异常,数据库就会生成一条critical alert。

这些信息在OEM 上都可以很直观的查看。
企业管理器(OEM)介绍: Grid Control 和DatabaseControl
http://blog.csdn.net/tianlesoftware/article/details/5704374

Oracle OEM 重建 及 案例 说明
http://blog.csdn.net/tianlesoftware/article/details/4702978

Other alerts correspond to database events such as Snapshot Too Oldor Resumable Session suspended. These types of alerts indicate thatthe event has occurred.
另一种alerts与db events 相关,如snapshot too old或resumable sessionsuspended。 当发生这些事件时,就会生成对应的alert。

In addition to notification, you can set alerts to perform someaction such as running a script. For instance, scripts that shrinktablespace objects can be useful for a Tablespace Usage warningalert.

By default, Oracle Database issues several alerts, including thefollowing:
--默认情况下,oracle会发布如下的alerts:
(1)Archive Area Used (warning at 80 percent full)
(2)Broken Job Count and Failed Job Count (warning when goes above0)
(3)Current Open Cursors Count(warning when goes above 1200)
(4)Dump Area Used (warning at 95 percent full)
(5)Session Limit Usage (warning at 90 percent, critical at 97percent)
(6)Tablespace Space Used (warningat 85 percent full, critical at 97percent full)

You can modify these alerts and others by setting theirmetrics.
这些alerts 和其他的Metrics值都可以使用DBMS_SERVER_ALERT包的SET_THRESHOLD,GET_THRESHOLD方法来修改和查看,也可以直接使用OEM来进行修改。

与Alerts 相关的数据字典如下表:

     View                               Description
DBA_THRESHOLDS            Lists the threshold settings defined for the instance

DBA_OUTSTANDING_ALERTS    Describes the outstanding alerts in the database

DBA_ALERT_HISTORY         Lists a history of alerts that have been cleared
    
V$ALERT_TYPES             Provides information such as group and type for each alert
    
V$METRICNAME              Contains the names, identifiers, and other information about thesystem  metrics
    
V$METRIC                  Contains system-level metric values

V$METRIC_HISTORY          Contains a history of system-level metric values
 
小结一下:Alert 信息的产生分两种: OEM 产生 和 DB Server 产生。
 (1)OEM 是通过EMD(OEM daemon)直接访问SGA 获取。
 (2)DB Server 是通过MMON 进程获取。Server产生的alert信息在alert_que中排队,该队列的主要consumer是DBCONSOLE。

DB Server产生的alerts 有分两种:基于threshold values 和 event。
(1)基于threshold的alert信息可以在DBA_OUTSTANDING_ALERTS中。当被clear的时候,会进入DBA_ALERT_HISTORY,而alerthistory被purge也是基于AWR信息的purge策略。
(2)基于事件的alert比如下面这些:Snapshot Too Old, Resumable SessionSuspended。
这部分alert信息由DBCONSOLE控制,因为DBCONSOLE会把相关信息存放在自己的repository中。

这里要强调一点MMON 进程,在之前整理的Blog里有说明:
Oracle 进程 说明
http://blog.csdn.net/tianlesoftware/article/details/6711694

The manageability monitor process (MMON) performs many tasksrelated to the Automatic Workload Repository (AWR). For example,MMON writes when a metric violates its threshold value, takingsnapshots, and capturing statistics value for recently modified SQLobjects.
The manageability monitor lite process (MMNL) writes statisticsfrom the Active Session History (ASH) buffer in the SGA to disk.MMNL writes to disk when the ASH buffer is full.
From:http://docs.oracle.com/cd/E11882_01/server.112/e25789/process.htm#CNCPT89087

通过官网上的这段说明,可以很清楚的理解MMON具体的工作:MMON writes when a metric violates itsthreshold value, taking snapshots,and capturing statistics valuefor recently modified SQL objects.

MMON主要执行一些与AWR 相关的任务。如检查metric,产生快照,捕捉统计信息. 这里分BaseStatistics和Metrics:
    (1) basestatistics是指收集的裸信息。
    (2)Metrics是基于base statistics的第二层信息,可以跟踪数据库的活动变化情况。
   该统计信息每分钟由MMON进程进行更新。METRIC的值由MMON进程计算,保存在内存中一个小时。

Metrics每分钟更新记录可以通过相关的视图来确认,这些视图有:
V$SYSMETRIC,
V$SESSMETRIC,
V$SERVICEMETRIC,
V$METRICNAME
V$FILEMETRIC,
V$EVENTMETRIC,
V$WAITCLASSMETRIC
V$SYSMETRIC_HISTORY,
DBA_HIST_*

如:
SYS@anqing1(rac1)> alter session setnls_date_format='yyyy-mm-dd hh24:mi:ss';
Session altered.

SYS@anqing1(rac1)> select begin_time,end_time fromV$EVENTMETRIC where rownum=1;
BEGIN_TIME             END_TIME
------------------- -------------------
2011-12-28 01:27:08 2011-12-28 01:28:07
通过以上的查询,可以确认其时间间隔是每分钟一次。

系统每秒对v$session进行抽样,放在SGA中的ASH区,该ASH区采用的是循环使用的机制,V$ACTIVE_SESSION_HISTORY中包含的是活动会话的信息。不是所有的ASH数据被写入磁盘,因为数据量太大,所以进行了过滤。通常每60分钟(快照默认时间)MMON进程会写这些信息,当ASHBUFFER满的话MMNL进程会写。

默认情况下AWR快照一个小时收集一次,在Oracle 10g里,快照保存7天,11g保留8天。AWR产生snapshot的频率和保留策略修改参考:

Oracle AWR(AutomaticWorkload Repository) 说明
http://blog.csdn.net/tianlesoftware/article/details/4682300

Oracle Statistic 统计信息 小结
http://blog.csdn.net/tianlesoftware/article/details/4668723

二. 相关的视图之前整理过一篇根据dba_errors视图来查看报警的文章:
根据 dba_errors 制定 数据库报警邮件
http://blog.csdn.net/tianlesoftware/article/details/6433418

DBA_ERRORS:describes the current errors on all stored objects inthe database.
dba_errors 视图记录的是数据库对象上当前存在的错误,这些错误信息包含对象名称,类型,所有者,错误类型和错误原因,
比如存储过程有语法错误,没有编译通过,这时就会在dba_errors里留下记录。 这里我们看的是其他的几个相关视图。

2.1 V$SYSMETRIC_HISTORY   

V$SYSMETRIC_HISTORY displays all system metric values available inthe database. Both long duration(60-second with 1 hour history) andshort duration (15-second with one-intervalonly) metrics aredisplayed by this view.

Column        Datatype       Description
BEGIN_TIME    DATE           Begin time of the interval
END_TIME      DATE           End time of the interval
INTSIZE_CSEC  NUMBER         Interval size (in hundredths of a second)
GROUP_ID      NUMBER         Metric group ID
METRIC_ID     NUMBER         Metric ID
METRIC_NAME   VARCHAR2(64)   Metric name
VALUE         NUMBER         Metric value
METRIC_UNIT   VARCHAR2(64)   Metric unit description
 
http://docs.oracle.com/cd/E11882_01/server.112/e25513/dynviews_3091.htm

2.2 DBA_OUTSTANDING_ALERTS

DBA_OUTSTANDING_ALERTS describes alerts which the server considersto be outstanding.
http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_4167.htm
 
在Alerts 体系中,基于threshold 的alert信息可以通过dba_outstanding_alerts视图查看,
当这个警告被clear 后,信息会被转移,那么该警告信息可以通过dba_alert_history视图查看,
该视图里的历史数据也有有限的,其存放周期也受AWR的purge 策略影响。
比如我们的表空间使用率过高,超过了threshold 值,那么可以通过DBA_OUTSTANDING_ALERTS查看到,
当我们添加数据文件之后,警告解除,我们就可以从dba_alert_history视图里查看。

2.3 DBA_ALERT_HISTORY

DBA_ALERT_HISTORY describes a time-limited history of alerts whichare no longer outstanding.
http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_3044.htm

示例:
selectobject_type,reason,creation_time,suggested_action,metric_value fromdba_alert_history

转自:http://wenku.baidu.com/view/f758fb1f227916888486d78d.html
0 0