重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1686|回复: 0
打印 上一主题 下一主题

[Oracle] awr报告时间间隔解析

[复制链接]
跳转到指定楼层
楼主
发表于 2022-1-17 14:06:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 denglj 于 2022-1-17 14:07 编辑

在进行数据库性能分析时,往往需要取出最近一段时间的awr报告。
众所周知,awr报告默认情况是每隔一个小时产生一个,
那么怎么修改awr报告的间隔时间呢?
以下为实际演练过程:
查询当前awr报告间隔时间,如下SNAP_INTERVAL为1小时
SQL> select * from dba_hist_wr_control

      DBID SNAP_INTERVAL                  RETENTION                      TOPNSQL        CON_ID   SRC_DBID SRC_DBNAME
---------- ------------------------------ ------------------------------ ---------- ---------- ---------- ------------------------------
2860573172 +00000 01:00:00.0              +00008 00:00:00.0              DEFAULT             0 2860573172 CDB$ROOT

SQL> select dbid,snap_interval,snapint_num,retention from wrm$_wr_control;

      DBID SNAP_INTERVAL                  SNAPINT_NUM RETENTION
---------- ------------------------------ ----------- ------------------------------
2860573172 +00000 01:00:00.0                     3600 +00008 00:00:00.0

修改间隔时间为30分钟,保留时间8*24*60(8天*24小时*60分钟)不变
SQL> exec dbms_workload_repository.modify_snapshot_settings(interval=>30,retention=>8*24*60);

PL/SQL procedure successfully completed.

确认SNAP_INTERVAL修改状况
SQL> select * from dba_hist_wr_control

      DBID SNAP_INTERVAL                  RETENTION                      TOPNSQL        CON_ID   SRC_DBID SRC_DBNAME
---------- ------------------------------ ------------------------------ ---------- ---------- ---------- ------------------------------
2860573172 +00000 00:30:00.0              +00008 00:00:00.0              DEFAULT             0 2860573172 CDB$ROOT

执行awrrpt.sql验证:
SQL> @?/rdbms/admin/awrrpt.sql

Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
AWR reports can be generated in the following formats.  Please enter the
name of the format at the prompt.  Default value is 'html'.

'html'          HTML format (default)
'text'          Text format
'active-html'   Includes Performance Hub active report

Enter value for report_type:
old   1: select 'Type Specified: ',lower(nvl('&&report_type','html')) report_type from dual
new   1: select 'Type Specified: ',lower(nvl('','html')) report_type from dual

Type Specified:  html

old   1: select '&&report_type' report_type_def from dual
new   1: select 'html' report_type_def from dual

old   1: select '&&view_loc' view_loc_def from dual
new   1: select 'AWR_PDB' view_loc_def from dual

Current Instance
~~~~~~~~~~~~~~~~
DB Id          DB Name        Inst Num       Instance       Container Name
-------------- -------------- -------------- -------------- --------------
2860573172     ORCLCDB                     1 orclcdb        CDB$ROOT

Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  DB Id      Inst Num   DB Name      Instance     Host
------------ ---------- ---------    ----------   ------
* 2860573172     1      ORCLCDB      orclcdb      dbserver

Using 2860573172 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 <return> without
specifying a number lists all completed snapshots.

Enter value for num_days:

Listing all Completed Snapshots
Instance     DB Name      Snap Id       Snap Started    Snap Level
------------ ------------ ---------- ------------------ ----------
orclcdb      ORCLCDB             26  09 Jan 2022 15:56    1
                                             27  09 Jan 2022 17:00    1
                                             28  09 Jan 2022 18:00    1
                                             29  09 Jan 2022 19:00    1
                                             30  09 Jan 2022 20:00    1
                                             31  09 Jan 2022 21:00    1
                                             32  09 Jan 2022 22:00    1
                                             33  13 Jan 2022 23:00    1
                                             34  13 Jan 2022 09:00    1
                                             35  13 Jan 2022 09:21    1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 34
Begin Snapshot Id specified: 34

Enter value for end_snap: 35
End   Snapshot Id specified: 35
...
此时就能取出不是非整点的awr报告,取完后记得将间隔时间修改回1小时。

其实,此处要取出9点到当前时间点的awr报告,还可以在当前时间点创建一个快照,如下:
exec dbms_workload_repository.create_snapshot();   
此后执行命令@?/rdbms/admin/awrrpt.sql 就会出现最近一个快照的Snap Id提供选择。

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-4-19 22:39 , Processed in 0.087969 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表