---
title: "AWR报告生成"
author: "swvip"
date: "2011-02-22T10:32:52Z"
tags: ["HTML", "Oracle", "SQL", "SUN"]
categories: ["数据库"]
slug: "awr"
draft: false
lastmod: "2011-02-22T10:32:52Z"
id: 914250
url: "https://swvip.iteye.com/blog/914250"
---

**一.生成AWR报告**

\[ractest@sun880-1 /u01/app/oracle/orahome/rdbms/admin]$ cd $ORACLE\_HOME/rdbms/admin  
\[ractest@sun880-1 /u01/app/oracle/orahome/rdbms/admin]$ sqlplus / as sysdba  
SQL\*Plus: Release 10.2.0.4.0 - Production on Sun Jan 27 20:47:38 2008  
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.  
Connected to:  
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production  
With the Partitioning, Real Application Clusters, OLAP, Data Mining  
and Real Application Testing options  
SQL&gt; @awrrpt  
......  
//根据Oracle提示生成报告......

 **注**：报告生成在$ORACLE\_HOME/rdbms/admin/目录下。

 

**二.修改awr的默认设置**

//半小时采集一次，采集信息保存3天。  
SQL&gt;exec dbms\_workload\_repository.modify\_snapshot\_settings (interval=&gt;30,retention =&gt;3\*24\*60);

 

SQL&gt; 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&gt;exec dbms\_workload\_repository.modify\_snapshot\_settings (interval=&gt;0,retention =&gt;24\*60);

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

 

 

 

如下是：

# 生成AWR报告的完整过程

Oracle 9i下，使用statspack生成性能报告。  
Oracle 10g下，使用AWR生成性能报告，AWR报告需通过sys账户来生成。一个示例如下：

\[oracle@testserver admin]$ pwd  
/oracle/product/10g/rdbms/admin  
\[oracle@testserver admin]$ sqlplus /nolog

SQL\*Plus: Release 10.2.0.1.0 - Production on 星期四 3月 18 09:33:44 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

SQL&gt; connect /as sysdba  
已连接。  
SQL&gt; @awrrpt

Current Instance  
\~~~~~~~~~~~~~~~~

   DB Id    DB Name      Inst Num Instance  
\----------- ------------ -------- ------------  
1986166942 KMS                 1 kms

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 的值: text

Type Specified:  text

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

   DB Id     Inst Num DB Name      Instance     Host  
\------------ -------- ------------ ------------ ------------  
\* 1986166942        1 KMS          kms          testserver

Using 1986166942 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 &lt;return&gt; without  
specifying a number lists all completed snapshots.

输入 num\_days 的值:  5

Listing the last 5 days of Completed Snapshots

                                                        Snap  
Instance     DB Name        Snap Id    Snap Started    Level  
\------------ ------------ --------- ------------------ -----  
kms          KMS               6634 14 3月  2010 00:00     1  
                               6635 14 3月  2010 01:00     1  
                               6636 14 3月  2010 02:00     1  
                               6637 14 3月  2010 03:00     1  
                               6638 14 3月  2010 04:00     1  
                               6639 14 3月  2010 05:00     1  
                               6640 14 3月  2010 06:00     1  
                               6641 14 3月  2010 07:00     1  
                               6642 14 3月  2010 08:00     1  
                               6643 14 3月  2010 09:00     1  
                               6644 14 3月  2010 10:00     1  
                               6645 14 3月  2010 11:01     1  
                               6646 14 3月  2010 12:01     1  
                               6647 14 3月  2010 13:00     1  
                               6648 14 3月  2010 14:00     1  
                               6649 14 3月  2010 15:00     1  
                               6650 14 3月  2010 16:00     1  
                               6651 14 3月  2010 17:00     1  
                               6652 14 3月  2010 18:00     1  
                               6653 14 3月  2010 19:00     1  
                               6654 14 3月  2010 20:00     1  
                               6655 14 3月  2010 21:00     1  
                               6656 14 3月  2010 22:00     1  
                               6657 14 3月  2010 23:00     1  
                               6658 15 3月  2010 00:00     1  
                               6659 15 3月  2010 01:00     1  
                               6660 15 3月  2010 02:00     1  
                               6661 15 3月  2010 03:00     1  
                               6662 15 3月  2010 04:00     1  
                               6663 15 3月  2010 05:00     1  
                               6664 15 3月  2010 06:00     1  
                               6665 15 3月  2010 07:00     1  
                               6666 15 3月  2010 08:00     1  
                               6667 15 3月  2010 09:00     1  
                               6668 15 3月  2010 10:00     1  
                               6669 15 3月  2010 11:00     1  
                               6670 15 3月  2010 12:00     1  
                               6671 15 3月  2010 13:00     1  
                               6672 15 3月  2010 14:00     1  
                               6673 15 3月  2010 15:00     1  
                               6674 15 3月  2010 16:00     1  
                               6675 15 3月  2010 17:00     1  
                               6676 15 3月  2010 18:00     1  
                               6677 15 3月  2010 19:00     1  
                               6678 15 3月  2010 20:01     1  
                               6679 15 3月  2010 21:01     1  
                               6680 15 3月  2010 22:01     1  
                               6681 15 3月  2010 23:00     1  
                               6682 16 3月  2010 00:00     1  
                               6683 16 3月  2010 01:00     1  
                               6684 16 3月  2010 02:00     1  
                               6685 16 3月  2010 03:00     1  
                               6686 16 3月  2010 04:00     1  
                               6687 16 3月  2010 05:00     1  
                               6688 16 3月  2010 06:00     1

Specify the Begin and End Snapshot Ids  
\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
输入 begin\_snap 的值:    
6634  
Begin Snapshot Id specified: 6634

输入 end\_snap 的值:  6681  
End   Snapshot Id specified: 6681

Specify the Report Name  
\~~~~~~~~~~~~~~~~~~~~~~~  
The default report file name is awrrpt\_1\_6634\_6681.txt.  To use this name,  
press &lt;return&gt; to continue, otherwise enter an alternative.

输入 report\_name 的值:  

&lt;此部分内容为生成的awrrpt报告的内容&gt;

End of Report  
Report written to awrrpt\_1\_6682\_6739.txt