1)AWR的采样间隔及信息保留等信息可以通过如下视图查询得到:
SQL> select * from dba_hist_wr_control;
DBID SNAP_INTERVAL RETENTION TOPNSQL
---------- -------------------- -------------------- ----------
1293815896 +00000 01:00:00.0 +00007 00:00:00.0 DEFAULT
2)AWR的行为受到数据库一个重要参数的影响:
SQL> show parameter statistics_level
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
statistics_level string TYPICAL
BASIC:AWR的统计信息收集和所有的自我调整的特性都被关闭。
TYPICAL:数据库收集部分统计信息,默认值。
ALL:所有可能的统计信息都被收集。
3)AWR的信息记录在wrh$_active_session_history分区表中,可以通过视图dba_hist_active_sess_history来查看。
简单总结一下:
v$session代表数据库活动的开始,视为源起;
v$session_wait视图用以实时记录活动session的等待情况,是当前信息;
v$session_wait_history是对v$session_wait的简单增强,激活活动session的最近10次等待;
v$active_session_history是ASH的核心,用以记录活动session的历史等待信息,每秒采样一次,这部分内容记录在内存中,期望值是记录一个小时的内容;
wrh$_active_session_history是v$active_session_history在AWR的存储池,v$active_session_history中记录的信息会被定期(每小时一次)的刷新到负载库中,并缺省保留一个星期用于分析;
dba_hist_active_sess_history视图是wrh$_active_session_history视图和其他几个视图的联合展现,通常通过这个视图进行历史数据的访问。
其他:
在Oracle 10g中新增的SYSAUX表空间就是AWR信息的存储地。
awrrpti.sql可以生产其他数据库或实例上的AWR报告。这个脚本对于RAC结果的数据库很有用处,我们直接连接上一个实例就可以生成所有实例的AWR性能报告。
awrextr.sql脚本用于导出AWR信息,awrload.sql脚本用于AWR数据的加载。而加载后的数据可以通过awrrpti.sql来生产报告。
比如,将生产数据库的采样数据导入测试库,就可以比较两者或多者之间的性能差异变化。
注意:将采样信息导出/导入这个过程在10.2.0.4和10.2.0.5中存在问题,导入非常缓慢!
AWR报告的生成:
[oracle@linux db_1]$ sqlplus / as sysdba @?/rdbms/admin/awrrpt.sql
SQL*Plus: Release 10.2.0.4.0 - Production on 星期五 11月 4 10:46:22 2011
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
1290103567 ORCL 1 orcl
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'
输入 report_type 的值: html --这里是生成html格式的awr报告。
Type Specified: html
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
* 1290103567 1 ORCL orcl linux
Using 1290103567 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.
输入 num_days 的值: 1 --显示最近1天的性能收集信息。
Listing the last day's Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
orcl ORCL 13 07 10月 2011 12:07 1
14 07 10月 2011 13:00 1
15 07 10月 2011 14:01 1
16 07 10月 2011 15:00 1
17 07 10月 2011 16:00 1
18 07 10月 2011 17:00 1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
输入 begin_snap 的值: 17
Begin Snapshot Id specified: 17 --开始快照号是17。
输入 end_snap 的值: 18
End Snapshot Id specified: 18 --结束快照号是18。
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_17_18.html. To use this name,
press <return> to continue, otherwise enter an alternative.
输入 report_name 的值: /u01/app/oracle/awr.html --生成awr报告的路径和名字。
using ...
... ...
... ...
... ...
Report written to /u01/app/oracle/awrr.html