1. 程式人生 > 資料庫 >如何在Oracle中生成AWR報告

如何在Oracle中生成AWR報告

在本文中,我將介紹一些在Oracle中為不同目的生成AWR報告的方法。DBA應該知道可以生成兩種型別的AWR報告。一種是單例項報告,另一種是群集資料庫報告。

什麼是自動工作量儲存庫(AWR)?AWR是一個用於儲存Oracle資料庫與效能相關的靜態資訊的地方。自動資料庫診斷監視器(ADDM)是一種診斷工具,可以分析AWR資料,然後為資料庫系統的任何發現提供建議。這套功能稱為“。

為單例項資料庫生成AWR報告

對於單例項資料庫報告,您必須執行awrrpt.sql來生成AWR報告。

SQL> @?/rdbms/admin/awrrpt.sql

Current Instance
~~~~~~~~~~~~~~~~


   DB Id    DB Name      Inst Num Instance
----------- ------------ -------- ------------
  933515296 COMPDB              1 primdb


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

Type Specified:  html


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

   DB Id     Inst Num DB Name      Instance     Host
------------ -------- ------------ ------------ ------------
* 933515296         1 COMPDB       primdb       primary01.ex
                                                ample.com

Using  933515296 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

                                                        Snap
Instance     DB Name        Snap Id    Snap Started    Level
------------ ------------ --------- ------------------ -----
primdb       COMPDB               5 04 Feb 2016 09:10      1
                                  6 04 Feb 2016 10:00      1
                                  7 04 Feb 2016 11:00      1
                                  8 04 Feb 2016 12:00      1
                                  9 04 Feb 2016 13:00      1
                                 10 04 Feb 2016 14:00      1



Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 7
Begin Snapshot Id specified: 7

Enter value for end_snap: 8
End   Snapshot Id specified: 8



Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_7_8.html.  To use this name,
press <return> to continue, otherwise enter an alternative.

Enter value for report_name:

Using the report name awrrpt_1_7_8.html

<html lang="en"><head><title>AWR Report for DB: COMPDB, Inst: primdb, Snaps: 7-8</title>

...
Report written to awrrpt_1_7_8.html
SQL> !
[oracle@primary01 ~]$ ll
...
-rw-r--r--. 1 oracle oinstall 533219 Feb  4 14:12 awrrpt_1_7_8.html
[oracle@primary01 ~]$ exit
...
 

其中,@(符號)表示它從以下字串開始執行。?(問號)表示$ORACLE_HOME。有關更多說明,您可以參考這篇文章:

生成群集資料庫的AWR報告

生成AWR報告有兩種基本型別,一種是特定於例項級別的,另一種特定於資料庫級別的。

例項級

對於例項級報告,您必須執行awrrpti.sql一次生成一個AWR報告。在這種情況下,我們選擇例項2作為報告的主要來源。

SQL> @?/rdbms/admin/awrrpti.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:

Type Specified:                                  html


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

   DB Id     Inst Num DB Name      Instance     Host
------------ -------- ------------ ------------ ------------
* 3240481230        1 ERPFINDB     erpfindb1    rac1
  3240481230        2 ERPFINDB     erpfindb2    rac2

Enter value for dbid: 3240481230
Using 3240481230 for database Id
Enter value for inst_num: 2
Using 2 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: 8

Listing the last 8 days of Completed Snapshots

                                                        Snap
Instance     DB Name        Snap Id    Snap Started    Level
------------ ------------ --------- ------------------ -----
erpfindb1    ERPFINDB         83611 16 Apr 2019 00:00      1
...
...
                              83679 23 Apr 2019 00:00      1
...


Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 83611
Begin Snapshot Id specified: 83611

Enter value for end_snap: 83679
End   Snapshot Id specified: 83679



Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_2_83611_83679.html.  To use this name,
press <return> to continue, otherwise enter an alternative.

Enter value for report_name: awr_instance_2_report_20190423.html
...
 

全域性級別

對於全域性級別的報告,必須執行awrgrpt.sql才能為群集資料庫全域性生成AWR報告。

SQL> @?/rdbms/admin/awrgrpt.sql

Current Database
~~~~~~~~~~~~~~~~

   DB Id    DB Name
----------- ------------
 3240481230 ERPFINDB


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:

Type Specified:                                  html


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

   DB Id      INSTT_NUM DB Name
------------ ---------- ------------
INSTT_NAME                                       Host
------------------------------------------------ ------------
* 3240481230          1 ERPFINDB
erpfindb1                                        rac1
* 3240481230          2 ERPFINDB
erpfindb2                                        rac2

Using 3240481230 for database Id
Using instances ALL (default 'ALL')


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

Listing the last 8 days of Completed Snapshots

                                           Snap
DB Name        Snap Id    Snap Started    Level
------------ --------- ------------------ -----
ERPFINDB         83611 16 Apr 2019 00:00      1
...
...
                 83679 23 Apr 2019 00:00      1
...


Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 83611
Begin Snapshot Id specified: 83611

Enter value for end_snap: 83679
End   Snapshot Id specified: 83679



Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_rac_83611_83679.html.  To use this name,
press <return> to continue, otherwise enter an alternative.

Enter value for report_name: awr_global_database_report_20190423.html
...
 

報告範圍的差異

讓我們總結一下SQL指令碼之間統計範圍的差異,如下圖所示。

序號

指令碼

範圍

1

awrrpt.sql

當前例項

2

awrrpti.sql

選定的例項

3

awrgrpt.sql

整個叢集資料庫,
包括所有例項

儘管我們使用awrgrpt.sql為整個群集資料庫生成AWR報告,但是我們可以擁有由awrrpti.sql生成的更詳細的例項AWR報告。