awr详解

上一篇 / 下一篇  2012-10-18 15:59:01

性能测试中如何收集Oracle AWR报告

AWRAutomatic Workload Repository)常常用来帮助分析数据库潜在的性能问题。开发测试环境上收集AWR报告简单的可以按以下四个步骤进行。

步骤一、生成快照

性能测试之前,收集数据库当前的信息,以便在性能测试过程中或结束后进行对比。

SQL> conn / as sysdba

Connected.

SQL>exec dbms_workload_repository.create_snapshot;

PL/SQL procedure successfully completed.

SQL>

步骤二、进行性能测试

此过程中对数据库产生压力。

步骤三、生成快照

方法同步骤一。收集数据库当前的信息,以便在于步骤一中的数据进行对比。

SQL> conn / as sysdba

Connected.

SQL>exec dbms_workload_repository.create_snapshot;

PL/SQL procedure successfully completed.

SQL>

步骤四、生成报告

数据库通过对比两次快照之间的差异输出期间数据库的各种统计数据。

SQL>@ ?/rdbms/admin/awrrpt.sql?会被解析为$ORACLE_HOME

 

Current Instance

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

 

  DB Id   DB Name     Inst Num Instance

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

 588460999 PTLDB              1 ptldb

 

 

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文件】

 

 

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:1【系统列出1天内的报告列表】

 

Enter value for num_days: 1

 

Listing the last day's Completed Snapshots

 

                                                       Snap

Instance    DB Name       Snap Id   Snap Started   Level

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

ptldb       PTLDB            7236 28 Dec 2010 00:00     1

….

                              7258 28 Dec 2010 21:25     1

                              7259 28 Dec 2010 21:25     1

 

 

 

Specify the Begin and End Snapshot Ids

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

Enter value for begin_snap:7258【输入起始的快照,性能测试之前产生的】

Enter value for end_snap:7259【输入结束的快照,性能测试之后产生的】

 

Specify the Report Name

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

The default report file name is awrrpt_1_7258_7259.html. To use this name,

press <return> to continue, otherwise enter an alternative.

 

Enter value for report_name:/home/oracle/awrrpt_1_7258_7259.html【输入报告文件名】

<p />

End of Report

</body></html>

Report written to /home/oracle/awrrpt_1_7258_7259.html

SQL>

 

修改awr的默认设置

//半小时采集一次,采集信息保存3天。
SQL>
exec dbms_workload_repository.modify_snapshot_settings (interval=>30,retention =>3*24*60);

 

SQL> select * from dba_hist_wr_control;

      DBID SNAP_INTERVAL                RETENTION           TOPNSQL
---------- ---------------------------- ------------------- ----------
2420544136 +00000 02:00:00.0            +00005 00:00:00.0   DEFAULT

 

关闭AWR自动收集

SQL>exec dbms_workload_repository.modify_snapshot_settings (interval=>0,retention =>24*60);

10g默认是自动开启awr信息收集的,会对系统有一定的影响(很小);如果要关闭awr信息收集,只需设置interval参数为0即可。但interval0后,AWR报告无法生成。

 


相关阅读:

TAG: awr

 

评分:0

我来说两句

日历

« 2024-04-25  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 3156
  • 日志数: 7
  • 建立时间: 2012-09-12
  • 更新时间: 2012-10-18

RSS订阅

Open Toolbar