zoukankan      html  css  js  c++  java
  • AWR报告

    AWR(Automatic Workload Repository)报告是我们进行日常数据库性能评定、问题SQL发现的重要手段。熟练掌握AWR报告,是做好开发、运维DBA工作的重要基本功。
          AWR 实质上是一个 Oracle 的内置工具,它采集与性能相关的统计数据,并从那些统计数据中导出性能量度,以跟踪潜在的问题。快照由一个称为 MMON 的后台进程及其从进程自动地每小时采集一次。为了节省空间,采集的数据在 7 天后自动清除。快照频率和保留时间都可以由用户修改。它产生两种类型的输出:文本格式和默认的 HTML 格式,从而提供了非常用户友好的报表。
           AWR 使用几个表来存储采集的统计数据,所有的表都存储在SYSAUX 的特定表空间中的 SYS 模式下,并且以 WRM$_* 和 WRH$_* 的格式命名。前一种类型存储元数据信息(如检查的数据库和采集的快照),后一种类型保存实际采集的统计数据。H 代表“历史数据 (historical)”而 M 代表“元数据 (metadata)”。在这些表上构建了几种带前缀 DBA_HIST_ 的视图,这些视图可以用来编写您自己的性能诊断工具。视图的名称直接与表相关;例如,视图 DBA_HIST_SYSMETRIC_SUMMARY 是在WRH$_SYSMETRIC_SUMMARY 表上构建的。
           本篇中介绍使用手工脚本方式生成AWR的方法,脱离OEM的限制。 
    1、 运行脚本 

    首先,准备一个目录作为AWR生成报告的路径。 
    [oracle@abraham_dba/]$ mkdir -p rpt
    drwxr-xr-x.  2 oracle oinstall 4096 Jun 21 13:01 test 
    [oracle@abraham_dba /]$ cd rpt 
    启动sqlplus等开发工具,调用生成脚本。程序脚本一般保存在$ORACLE_HOME下的rdbms/admin中,名称为awrrpt.sql。 
    [oracle@abraham_dba rpt]$ sqlplus /nolog
    SQL*Plus: Release11.2.0.1.0 Production on Tue Jun 21 13:04:44 2011 
    Copyright (c) 1982, 2009, Oracle. All rights reserved. 
    SQL> conn / as sysdba
    Connected. 

    --调用脚本,生成文件
    SQL> @$ORACLE_HOME/rdbms/admin/awrrpt.sql 
    之后进入报告参数输入模块。 
    2、输入报告参数 
    之后,要持续输入一系列的报告参数。 
    2.1.输入生成报告类型,目前AWR提供txt和html两种格式。需要确认生成格式,默认是html格式。 

    Current Instance
    ~~~~~~~~~~~~~~~~ 
      DB Id   DB Name     Inst Num Instance
    ----------- ------------ -------- ------------
     4143510747 ORA11G             1 ora11g  
    Specify the Report Type
    ~~~~~~~~~~~~~~~~~~~~~~~
    Would you like an HTML report, or a plain text report?
    Enter 'html' for an HTML report, or 'text' for plain text
    Defaults to 'html' 

    2.2.报告涉及天数范围 

    启动报告后,会显示生成实例的名称等基本信息。 
    默认情况下,AWR会将镜像信息保留一个月。手工生成的时候,需要确认生成AWR报告的时间范围。一般情况下,特别是生产环境下,我们通常设置1-7天也就够用了。 
    Instances in this Workload Repository schema
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
      DB Id    Inst Num DB Name     Instance    Host
    ------------ -------- ------------ ------------ ------------
    * 4143510747       1 ORA11G      ora11g      abraham_dba.local
                                                   domain 
    Using 4143510747 for database Id
    Using         1 for instance number 
    Specify the number of days of snapshots to choose from
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Entering the number of days (n) will result in the most recent
    (n) days of snapshots being listed. Pressing without
    specifying a number lists all completed snapshots. 
    Enter value for num_days:3  

    2.3.输入开始和结束的snapshot编号 

    输入天数信息后,AWR生成代码会将天数范围内的snapshot镜像点列出,供输入选择。 
    Listing the last 3 days of Completed Snapshots 
                                                           Snap
    Instance    DB Name       Snap Id   Snap Started   Level
    ------------ ------------ --------- ------------------ -----
    ora11g      ORA11G           1789 20 Jun 2011 13:01     1
                                  1790 20 Jun 2011 14:00     1
                                  1791 20 Jun 2011 15:00     1
                                  1792 20 Jun 2011 16:00     1
                                  1811 21 Jun 2011 11:00     1
                                  1812 21 Jun 2011 12:00     1
                                  1813 21 Jun 2011 13:00     1 
    Specify the Begin and End Snapshot Ids
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    之后,我们需要根据列出的时间范围,输入开始和结束的snap编号。 
    Specify the Begin and End Snapshot Ids
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Enter value for begin_snap:1796
    Begin Snapshot Id specified: 1796 
    Enter value for end_snap:1813  

    2.4.确定报告名称 

    最后就是确定生成报告的名称。一般采用默认的名称就可以了。 
    Specify the Report Name
    ~~~~~~~~~~~~~~~~~~~~~~~
    The default report file name is awrrpt_1_1796_1813.html. To use this name,
    press to continue, otherwise enter an alternative. 
    Enter value for report_name: 
    之后输出内容很多,此处不加以累述。最后提示报告生成成功。 
    Report written to awrrpt_1_1796_1813.html 
    于是,指定目录上可以看到相应的报告文件。 
    [oracle@abraham_dba rpt]$ ls -l
    total 508
    -rw-r--r--. 1 oracle oinstall 515262 Jun 21 13:10 awrrpt_1_1796_1813.html   

    3、说明两个问题 

    首先,此处生成的html格式的报表。如果要求生成txt格式,就在生成过程中选择text格式报表。 
    Specify the Report Type
    ~~~~~~~~~~~~~~~~~~~~~~~
    Would you like an HTML report, or a plain text report?
    Enter 'html' for an HTML report, or 'text' for plain text
    Defaults to 'html'
    Enter value for report_type: text 
    Type Specified: text 
    End of Report
    Report written to awrrpt_1_1789_1800.txt 
    [oracle@abraham_dba test]$ ls -l
    total 692
    -rw-r--r--. 1 oracle oinstall 180601 Jun 21 13:27 awrrpt_1_1789_1800.txt
    -rw-r--r--. 1 oracle oinstall 515262 Jun 21 13:10 awrrpt_1_1796_1813.html 

    4、结论 

    手工生成AWR报告,可以避免受到OEM的限制约束,而且灵活度高。本篇记录,权当备忘

    参考:

    1、http://space.itpub.net/17203031/viewspace-700471
  • 相关阅读:
    Flink 多流转换算子
    Flink 基本算子map、keyBy、sum、reduce
    Scala 调用方法时加不加小括号
    Hive rank函数开窗
    Hive 窗口函数
    Scala 集合Map的基本操作
    LOJ#2402. 「THUPC 2017」天天爱射击 / Shooting 整体二分+树状数组
    LOJ#106. 二逼平衡树 树套树
    LOJ#2340. 「WC2018」州区划分
    LOJ#2304. 「NOI2017」泳池(70pts) dp
  • 原文地址:https://www.cnblogs.com/timlong/p/4969343.html
Copyright © 2011-2022 走看看