一. AWR 說明
Oracle 10g之前對資料庫做效能檢測使用statspack工具. Oracle Database 10g 提供了一個新的工具:(AWR:Automatic Workload Repository)。Oracle 建議使用者用這個取代 Statspack。AWR 實質上是一個 Oracle 的內建工具,它採集與效能相關的統計資料,並從那些統計資料中匯出效能量度,以跟蹤潛在的問題。與Statspack 不同,快照由一個稱為 MMON 的新的後台進程及其從進程自動地每小時採集一次。為了節省空間的,採集的資料在 7 天后自動清除。快照頻率和保留時間都可以由使用者修改。它產生兩種類型的輸出:文字格式設定(類似於 Statspack 報表的文字格式設定但來自於 AWR 資訊庫)和預設的 HTML 格式(擁有到部分和子部分的所有超連結)。
AWR 使用幾個表來儲存採集的統計資料,所有的表都儲存在新的名稱為 SYSAUX 的特定資料表空間中的 SYS 模式下,並且以 WRM$_* 和 WRH$_* 的格式命名。前一種類型儲存中繼資料資訊(如檢查的資料庫和採集的快照),後一種類型儲存實際採集的統計資料。H 代表“曆史資料 (historical)”而 M 代表“中繼資料(metadata)”。在這些表上構建了幾種帶首碼 DBA_HIST_ 的視圖,這些視圖可以用來編寫您自己的效能診斷工具。視圖的名稱直接與表相關;例如,視圖DBA_HIST_SYSMETRIC_SUMMARY 是在WRH$_SYSMETRIC_SUMMARY 表上構建的。
注意一點:
statistics_level 有三個取值,分別是ALL,TYPICAL,BASIC,系統預設是typical,在10g中表監控是啟用的,強烈建議在10g中此參數的值是typical。如果STATISTICS_LEVEL設定為basic,不僅不能監控表,而且將禁掉如下一些10g的新功能:
ASH(Active Session History)
ASSM(Automatic Shared Memory Management)
AWR(Automatic Workload Repository)
ADDM(Automatic Database Diagnostic Monitor)
二. 手動產生AWR報告
如果安裝了OEM,則可以通過OEM來產生AWR報告,本例通過手動的產出AWR報告。
SQL> @?/rdbms/admin/awrrpt.sql
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
2100083002 TEST 1 test
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
------------ -------- ------------ ------------ ------------
* 2100083002 1 TEST test even.oracle.
com
Using 2100083002 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: 1
Listing the last day's Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
test TEST 12 20 Dec 2012 10:38 1
13 20 Dec 2012 11:17 1
14 20 Dec 2012 11:42 1
15 20 Dec 2012 11:42 1
16 20 Dec 2012 11:42 1
17 20 Dec 2012 13:00 1
18 20 Dec 2012 13:37 1
19 20 Dec 2012 13:50 1
20 20 Dec 2012 14:00 1
21 20 Dec 2012 14:10 1
22 20 Dec 2012 14:20 1
23 20 Dec 2012 14:30 1
24 20 Dec 2012 14:40 1
25 20 Dec 2012 14:50 1
26 20 Dec 2012 15:00 1
27 20 Dec 2012 15:10 1
28 20 Dec 2012 15:20 1
29 20 Dec 2012 15:30 1
30 20 Dec 2012 15:40 1
31 20 Dec 2012 15:50 1
32 20 Dec 2012 16:36 1
Specify the Begin and End Snapshot Ids
Enter value for begin_snap: 30
Begin Snapshot Id specified: 30
Enter value for end_snap: 32
End Snapshot Id specified: 32
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_30_32.html. To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name: /home/oracle/20121231_AWR_rpt.html
......
.....
......
......
Report written to /home/oracle/20121231_AWR_rpt.html
到此AWR report就產生了,我的報表在/home/oracle/20121231_AWR_rpt.html