0

0

Oracle AWR报告生成与查看

php中文网

php中文网

发布时间:2016-06-07 17:00:22

|

1722人浏览过

|

来源于php中文网

原创

可以通过dba_hist_wr_control查看当前的配置情况,当前awr为每1小时做一次数据快照,保留时间为7天。SYS@PENG SQLgt; select *

可以通过dba_hist_wr_control查看当前的配置情况,当前awr为每1小时做一次数据快照,保留时间为7天。

SYS@PENG SQL> select * from dba_hist_wr_control;
      DBID SNAP_INTERVAL               RETENTION                             TOPNSQL
---------- --------------------------- ------------------------------------ ----------
 620748923 +00000 01:00:00.0           +00007 00:00:00.0                     DEFAULT

Elapsed: 00:00:00.16
SYS@PENG SQL>

调整配置数据:

SYS@PENG SQL> execute dbms_workload_repository.modify_snapshot_settings(interval=>30,retention=>14000);

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.17
再查看修改后的效果:

SYS@PENG SQL> select * from dba_hist_wr_control;
      DBID SNAP_INTERVAL               RETENTION                             TOPNSQL
---------- --------------------------- ------------------------------------ ----------
 620748923 +00000 00:30:00.0           +00009 17:20:00.0                     DEFAULT

Elapsed: 00:00:00.02
SYS@PENG SQL>

除自动建立快照以外,还可以在需要的时候手工创建快照,数据和自动创建的一样使用。

SYS@PENG SQL> select dbms_workload_repository.create_snapshot() from dual;
DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT()
------------------------------------------
                                        68

Elapsed: 00:00:01.00
SYS@PENG SQL> select dbms_workload_repository.create_snapshot() from dual;
DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT()
------------------------------------------
                                        69

Elapsed: 00:00:00.60
SYS@PENG SQL>

[Oracle@localhost admin]$ pwd
/oracle/product/10g/rdbms/admin

这里存放了很多sql脚本,有时间可以打开阅读,对提高水平有作用。这里我们用到awrrpt.sql。

可以先打开看一下内容。

[oracle@localhost admin]$ cat awrrpt.sql

Rem $Header: awrrpt.sql 24-oct-2003.12:04:53 pbelknap Exp $
Rem
Rem awrrpt.sql
Rem
Rem Copyright (c) 1999, 2003, Oracle Corporation.  All rights reserved.
Rem
Rem    NAME
Rem      awrrpt.sql
Rem
Rem    DESCRIPTION
Rem      This script defaults the dbid and instance number to that of the
Rem      current instance connected-to, then calls awrrpti.sql to produce
Rem      the Workload Repository report.
Rem
Rem    NOTES
Rem      Run as select_catalog privileges.
Rem      This report is based on the Statspack report.
Rem
Rem      If you want to use this script in an non-interactive fashion,
Rem      see the 'customer-customizable report settings' section in
Rem      awrrpti.sql
Rem
Rem    MODIFIED   (MM/DD/YY)
Rem    pbelknap    10/24/03 - swrfrpt to awrrpt
Rem    pbelknap    10/14/03 - moving params to rpti
Rem    pbelknap    10/02/03 - adding non-interactive mode cmnts
Rem    mlfeng      09/10/03 - heading on
Rem    aime        04/25/03 - aime_going_to_main
Rem    mlfeng      01/27/03 - mlfeng_swrf_reporting
Rem    mlfeng      01/13/03 - Update comments
Rem    mlfeng      07/08/02 - swrf flushing
Rem    mlfeng      06/12/02 - Created
Rem

--
-- Get the current database/instance information - this will be used
-- later in the report along with bid, eid to lookup snapshots

set echo off heading on underline on;
column inst_num  heading "Inst Num"  new_value inst_num  format 99999;
column inst_name heading "Instance"  new_value inst_name format a12;
column db_name   heading "DB Name"   new_value db_name   format a12;
column dbid      heading "DB Id"     new_value dbid      format 9999999999 just c;

prompt
prompt Current Instance
prompt ~~~~~~~~~~~~~~~~

select d.dbid            dbid
     , d.name            db_name
     , i.instance_number inst_num
     , i.instance_name   inst_name
  from v$database d,
       v$instance i;

@@awrrpti

undefine num_days;
undefine report_type;
undefine report_name;
undefine begin_snap;
undefine end_snap;
--
-- End of file

其中一段的结果为
select d.dbid            dbid
     , d.name            db_name
     , i.instance_number inst_num
     , i.instance_name   inst_name
  from v$database d,
       v$instance i;

      DBID DB_NAME     INST_NUM INST_NAME
---------- --------- ---------- ----------------
 620748923 PENG               1 peng

PictoGraphic
PictoGraphic

AI驱动的矢量插图库和插图生成平台

下载


然后调用了awrrpti.sql,,其内容较多,以后找机会在专门分析。

这里我们直接执行awrrpt.sql。

SYS@PENG SQL> @/oracle/product/10g/rdbms/admin/awrrpt.sql

Current Instance
~~~~~~~~~~~~~~~~

   DB Id    DB Name      Inst Num Instance
----------- ------------ -------- ------------
  620748923 PENG                1 peng


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


Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   DB Id     Inst Num DB Name      Instance     Host
------------ -------- ------------ ------------ ------------
* 620748923         1 PENG         peng         localhost

Using  620748923 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: 2

Listing the last 2 days of Completed Snapshots

                                                        Snap
Instance     DB Name        Snap Id    Snap Started    Level
------------ ------------ --------- ------------------ -----
peng         PENG                58 12 Dec 2010 01:11      1
                                 59 12 Dec 2010 02:01      1
                                 60 12 Dec 2010 03:01      1
                                 61 12 Dec 2010 04:02      1
                                 62 12 Dec 2010 05:02      1

                                 63 13 Dec 2010 01:00      1

                                 64 13 Dec 2010 02:00      1
                                 65 13 Dec 2010 03:02      1
                                 66 13 Dec 2010 04:01      1
                                 67 13 Dec 2010 04:54      1
                                 68 13 Dec 2010 04:59      1
                                 69 13 Dec 2010 05:00      1
                                 70 13 Dec 2010 05:30      1

 

Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 64
Begin Snapshot Id specified: 64

Enter value for end_snap: 70
End   Snapshot Id specified: 70

 

Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_64_70.txt.  To use this name,
press to continue, otherwise enter an alternative.

Enter value for report_name: /tmp/awrrpt_1_64_70.txt

生成文件存放在指定的/tmp下。

文件包含一下内容:

  • Report Summary
  • Wait Events Statistics
  • SQL Statistics
  • Instance Activity Statistics
  • IO Stats
  • Buffer Pool Statistics
  • Advisory Statistics
  • Wait Statistics
  • Undo Statistics
  • Latch Statistics
  • Segment Statistics
  • Dictionary Cache Statistics
  • Library Cache Statistics
  • Memory Statistics
  • Streams Statistics
  • Resource Limit Statistics
  • init.ora Parameters
  • linux

    相关专题

    更多
    php源码安装教程大全
    php源码安装教程大全

    本专题整合了php源码安装教程,阅读专题下面的文章了解更多详细内容。

    150

    2025.12.31

    php网站源码教程大全
    php网站源码教程大全

    本专题整合了php网站源码相关教程,阅读专题下面的文章了解更多详细内容。

    88

    2025.12.31

    视频文件格式
    视频文件格式

    本专题整合了视频文件格式相关内容,阅读专题下面的文章了解更多详细内容。

    90

    2025.12.31

    不受国内限制的浏览器大全
    不受国内限制的浏览器大全

    想找真正自由、无限制的上网体验?本合集精选2025年最开放、隐私强、访问无阻的浏览器App,涵盖Tor、Brave、Via、X浏览器、Mullvad等高自由度工具。支持自定义搜索引擎、广告拦截、隐身模式及全球网站无障碍访问,部分更具备防追踪、去谷歌化、双内核切换等高级功能。无论日常浏览、隐私保护还是突破地域限制,总有一款适合你!

    61

    2025.12.31

    出现404解决方法大全
    出现404解决方法大全

    本专题整合了404错误解决方法大全,阅读专题下面的文章了解更多详细内容。

    493

    2025.12.31

    html5怎么播放视频
    html5怎么播放视频

    想让网页流畅播放视频?本合集详解HTML5视频播放核心方法!涵盖<video>标签基础用法、多格式兼容(MP4/WebM/OGV)、自定义播放控件、响应式适配及常见浏览器兼容问题解决方案。无需插件,纯前端实现高清视频嵌入,助你快速打造现代化网页视频体验。

    16

    2025.12.31

    关闭win10系统自动更新教程大全
    关闭win10系统自动更新教程大全

    本专题整合了关闭win10系统自动更新教程大全,阅读专题下面的文章了解更多详细内容。

    12

    2025.12.31

    阻止电脑自动安装软件教程
    阻止电脑自动安装软件教程

    本专题整合了阻止电脑自动安装软件教程,阅读专题下面的文章了解更多详细教程。

    5

    2025.12.31

    html5怎么使用
    html5怎么使用

    想快速上手HTML5开发?本合集为你整理最实用的HTML5使用指南!涵盖HTML5基础语法、主流框架(如Bootstrap、Vue、React)集成方法,以及无需安装、直接在线编辑运行的平台推荐(如CodePen、JSFiddle)。无论你是新手还是进阶开发者,都能轻松掌握HTML5网页制作、响应式布局与交互功能开发,零配置开启高效前端编程之旅!

    2

    2025.12.31

    热门下载

    更多
    网站特效
    /
    网站源码
    /
    网站素材
    /
    前端模板

    精品课程

    更多
    相关推荐
    /
    热门推荐
    /
    最新课程
    最新Python教程 从入门到精通
    最新Python教程 从入门到精通

    共4课时 | 0.6万人学习

    Node.js 教程
    Node.js 教程

    共57课时 | 7.8万人学习

    CSS3 教程
    CSS3 教程

    共18课时 | 4.2万人学习

    关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
    php中文网:公益在线php培训,帮助PHP学习者快速成长!
    关注服务号 技术交流群
    PHP中文网订阅号
    每天精选资源文章推送

    Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号