ITPub博客

首页 > 数据库 > Oracle > Oracle生成标准统计报表

Oracle生成标准统计报表

原创 Oracle 作者:wolaiye320 时间:2016-06-03 17:18:59 0 删除 编辑

AWR 是通过对比两次快照(snapshot)收集到的统计信息,来生成报表数据,生成的报表 包括多个部分,这点与 Statspack 生成的报告非常类似。不过 AWR 在生成报告时,可以选 择生成 TXT 或 HTML 两种格式的报告,相对来说,HTML 更利于阅读,而 TXT 的适用性 更广(即使在不能使用浏览器的机器上也能看)。

 

操 作 过 Statspack 的 朋 友 都 还 记 的 , 生 成 报 告 使 用 $ORACLE_HOME/rdbms/admin/spreport.sql 脚本,到了 AWR 这片,操作步骤基本上相同, 不过生成报告的脚本多了很多选择,包括:

 

?      awrrpt.sql:生成指定快照区间的统计报表;

 

?      awrrpti.sql:生成指定数据库实例,并且指定快照区间的统计报表;

 

?      awrsqlrpt.sql:生成指定快照区间,指定 SQL 语句(实际指定的是该语句的 SQLID)

 

的统计报表;

 

?      awrsqrpi.sql:生成指定数据库实例,指定快照区间的指定 SQL 语句的统计报表;

 

?      awrddrpt.sql:指定两个不同的时间周期,生成这两个周期的统计对比报表;

 

?      awrddrpi.sql:指定数据库实例,并指定两个的不同时间周期,生成这两个周期的统 计对比报表;

 

下面的章节中,我们就来一一例举。


提示:与使用 Statspack 一样,要想让 AWR 收集到准确的统计信息,从而生成可靠的


性能分析报告,必须将初始化参数 STATISTICS_LEVEL 的值设置为 TYPICAL 或 ALL。


 

 

 

 

 

 


 

2.1 生成标准统计报表

 

 

过程并不复杂,下列操作中加粗的部分,是需要指定值的位置(注意,执行报表生成的 用户必须拥有 DBA 角色):


JSSWEB> @$ORACLE_HOME/rdbms/admin/awrrpt.sql


Current Instance


~~~~~~~~~~~~~~~~

 

DB Id

DB Name

Inst Num Instance

----------- ------------ -------- ------------

3812548755 TEST08

1 test08

 

 

 


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: html

 

此处需指定生成的报表格式,有 txt 和 html 两种选择,默认情况下为 html 格式,这里 为演示起见,输入 html。


Type Specified:    html


 

 

Instances in this Workload Repository schema


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

DB Id

Inst Num DB Name

Instance

Host

------------ -------- ------------ ------------ ------------

 

* 3812548755

1 TEST08

test08

yans1

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

 

此处需指定要读取多少天内的快照信息!

 

Listing the last 2 days of Completed Snapshots

 

 

 

 

 

 

 

 

Snap

Instance

DB Name

Snap Id

Snap Started

Level

------------ ------------ --------- ------------------ -----

 

 

test08

TEST08

7330 20 10 月 2009 00:00

1

 

 

7331 20 10 月 2009 01:00

1

 

 

7332 20 10 月 2009 02:00

1

 

 

7333 20 10 月 2009 03:00

1

 

 

7334 20 10 月 2009 04:00

1

 

 

7335 20 10 月 2009 05:01

1

 

 

7336 20 10 月 2009 06:00

1

 

 

7337 20 10 月 2009 07:01

1

 

 

7338 20 10 月 2009 08:00

1

 

 

7339 20 10 月 2009 09:00

1

 

 

7340 20 10 月 2009 10:00

1

 

 

7341 20 10 月 2009 11:00

1

 

 

7342 20 10 月 2009 12:00

1

 

 

7343 20 10 月 2009 13:00

1

 

 

7344 20 10 月 2009 14:00

1

 

 

7345 20 10 月 2009 15:00

1

 

 

7346 20 10 月 2009 16:00

1

 

 

7347 20 10 月 2009 17:00

1

 

 

7348 20 10 月 2009 18:00

1

 

 

7349 20 10 月 2009 19:00

1

 

 

7350 20 10 月 2009 20:00

1

 

 

7351 20 10 月 2009 21:00

1

 

 

7352 20 10 月 2009 22:00

1

 

 

7353 20 10 月 2009 23:00

1

 

 

7354 21 10 月 2009 00:00

1

 

 

7355 21 10 月 2009 01:00

1

 

 

7356 21 10 月 2009 02:00

1

 

 

7357 21 10 月 2009 03:00

1

 

 

7358 21 10 月 2009 04:00

1

 

 

7359 21 10 月 2009 05:00

1

 

 

7360 21 10 月 2009 06:00

1

 

 

7361 21 10 月 2009 07:00

1

 

 

7362 21 10 月 2009 08:00

1

 

 

7363 21 10 月 2009 09:00

1


 

 


7364 21 10 月 2009 10:00

1

7365 21 10 月 2009 11:00

1

7366 21 10 月 2009 12:00

1

7367 21 10 月 2009 13:00

1

7368 21 10 月 2009 14:00

1

 

 


Specify the Begin and End Snapshot Ids


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Enter value for begin_snap: 7331


Begin Snapshot Id specified: 7331


Enter value for end_snap: 7355


End       Snapshot Id specified: 7355


 

 

 

 

Specify the Report Name


~~~~~~~~~~~~~~~~~~~~~~~


The default report file name is awrrpt_1_7331_7355.html. To use this name, press <return> to continue, otherwise enter an alternative.


Enter value for report_name:

 

此处为要生成的报告指定一个文件名,默认会根据前面输入的snap_id 生成一个文件名, 比如这里生成的默认文件名为 awrrpt_1_7331_7355.html,当然 DBA 可以根据实际情况对文 件名进行自定义。这里三思偷个懒,就用默认文件名好了,直接回车。

 

接下来就不需要 DBA 再输入什么了,等着 ORACLE 给你生成报表吧。


Using the report name awrrpt_1_7331_7355.html


..................


.......................


<P>


End of Report </BODY></HTML>


Report written to awrrpt_1_7331_7355.html

 

更多知识参考http://www.infocol.net

 

打开最终生成的统计报表,界面如下:


 

 

 

 

 

 

 

 

 

 

 

提示:


问:前面提示输入 snaps 时哪来的这么多 snapshots 啊?


答:这都是 ORACLE 偷偷摸摸一点一点(每小时一次)收集的啊!


问:它究竟收集了多久的啊?


答:从当前的记录看,至少有 7 天了!


问:究竟啥是 snapshot 啊?


答:接着往下看!

 

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1700919/viewspace-2113602/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-06-23

  • 博文量
    19
  • 访问量
    827664