1. 程式人生 > >Oracle-awrddrpt.sql比較兩個AWR差異報告

Oracle-awrddrpt.sql比較兩個AWR差異報告

概述

awrddrpt.sql指令碼位於$ORACLE_HOME/rdbms/admin目錄中。

awrddrpt.sql指令碼比較兩個時間段的AWR報告。

這個指令碼的互動部分最重要的就是需要輸入要進行對比的兩個awr報告的begin snap_id與end snap_id

一旦收集到四個快照號碼,awrddrpt.sql指令碼將建立兩個AWR報告,然後比較這兩個報告。awrddrpt.sql指令碼對於比較兩個經過時間段內的效能非常有用。

示例

我們打算比對3月30號00:00~01:00 和 3月31號00:00~01:00這兩個時間段的AWR

以oracle使用者登入到資料庫主機執行指令碼

.....
Connection established.
To escape to
local shell, press 'Ctrl+Alt+]'. Last login: Sat Mar 31 09:48:24 2018 from 172.25.21.204 Oracle Corporation SunOS 5.10 Generic Patch January 2005 You have new mail. ##處於安全的考慮,以nolog的方式登入 ocsdb01:[/oracle$]sqlplus /nolog SQL*Plus: Release 11.2.0.4.0 Production on Sat Mar 31 11:23:08 2018 Copyright (c) 1982
, 2013, Oracle. All rights reserved. ## 登入特定的使用者,輸入密碼 SQL> connect [email protected]_CC Enter password: Connected. ## 執行awrddrpt指令碼 SQL> @?/rdbms/admin/awrddrpt Current Instance ~~~~~~~~~~~~~~~~ DB Id DB Id DB Name Inst Num Inst Num Instance ----------- ----------- ------------ -------- -------- ------------
2143881171 2143881171 CC 1 1 cc 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' ## 預設html Enter value for report_type: Type Specified: html Instances in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id Inst Num DB Name Instance Host ------------ -------- ------------ ------------ ------------ * 2143881171 1 CC cc ocsdb01 Database Id and Instance Number for the First Pair of Snapshots ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Using 2143881171 for Database Id for the first pair of snapshots Using 1 for Instance Number for the first pair of snapshots 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. #因為今天是31號,我們只需要輸入2天時間範圍就可以獲取到3月30號00:00~01:00的快照 Enter value for num_days: 2 Listing the last 2 days of Completed Snapshots Snap Instance DB Name Snap Id Snap Started Level ------------ ------------ --------- ------------------ ----- cc CC 10080 30 Mar 2018 00:00 1 10081 30 Mar 2018 01:00 1 10082 30 Mar 2018 02:00 1 10083 30 Mar 2018 03:00 1 10084 30 Mar 2018 04:00 1 10085 30 Mar 2018 05:00 1 10086 30 Mar 2018 06:00 1 10087 30 Mar 2018 07:00 1 10088 30 Mar 2018 08:00 1 10089 30 Mar 2018 09:00 1 10090 30 Mar 2018 10:00 1 10091 30 Mar 2018 11:00 1 10092 30 Mar 2018 12:00 1 10093 30 Mar 2018 13:00 1 10094 30 Mar 2018 14:00 1 10095 30 Mar 2018 15:00 1 10096 30 Mar 2018 16:00 1 10097 30 Mar 2018 17:00 1 10098 30 Mar 2018 18:00 1 10099 30 Mar 2018 19:00 1 10100 30 Mar 2018 20:00 1 10101 30 Mar 2018 21:00 1 10102 30 Mar 2018 22:00 1 10103 30 Mar 2018 23:00 1 10104 31 Mar 2018 00:00 1 10105 31 Mar 2018 01:00 1 10106 31 Mar 2018 02:00 1 10107 31 Mar 2018 03:00 1 10108 31 Mar 2018 04:00 1 10109 31 Mar 2018 05:00 1 10110 31 Mar 2018 06:00 1 10111 31 Mar 2018 07:00 1 10112 31 Mar 2018 08:00 1 10113 31 Mar 2018 09:00 1 10114 31 Mar 2018 10:00 1 10115 31 Mar 2018 11:00 1 Specify the First Pair of Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ## 選擇開始的快照 Enter value for begin_snap: 10080 First Begin Snapshot Id specified: 10080 ## 選擇結束的快照 Enter value for end_snap: 10081 First End Snapshot Id specified: 10081 Instances in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id Inst Num DB Name Instance Host ------------ -------- ------------ ------------ ------------ * 2143881171 1 CC cc ocsdb01 Database Id and Instance Number for the Second Pair of Snapshots ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Using 2143881171 for Database Id for the second pair of snapshots Using 1 for Instance Number for the second pair of snapshots 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. #因為今天是31號,我們只需要輸入1天時間範圍就可以獲取到3月31號00:00~01:00 Enter value for num_days2: 1 Listing the last day's Completed Snapshots Snap Instance DB Name Snap Id Snap Started Level ------------ ------------ --------- ------------------ ----- cc CC 10104 31 Mar 2018 00:00 1 10105 31 Mar 2018 01:00 1 10106 31 Mar 2018 02:00 1 10107 31 Mar 2018 03:00 1 10108 31 Mar 2018 04:00 1 10109 31 Mar 2018 05:00 1 10110 31 Mar 2018 06:00 1 10111 31 Mar 2018 07:00 1 10112 31 Mar 2018 08:00 1 10113 31 Mar 2018 09:00 1 10114 31 Mar 2018 10:00 1 10115 31 Mar 2018 11:00 1 Specify the Second Pair of Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ## 選擇開始的快照 Enter value for begin_snap2: 10104 Second Begin Snapshot Id specified: 10104 ## 選擇結束的快照 Enter value for end_snap2: 10105 Second End Snapshot Id specified: 10105 Specify the Report Name ~~~~~~~~~~~~~~~~~~~~~~~ The default report file name is awrdiff_1_10080_1_10104.html To use this name, press <return> to continue, otherwise enter an alternative. ## 輸入awr報告名稱 Enter value for report_name: artisan_awr_diff_rpt Using the report name artisan_awr_diff_rpt ......省略輸出過程 ...... ...... </body></html> Report written to artisan_awr_diff_rpt ## 退出 SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options ocsdb01:[/oracle$] ## 當前目錄下查詢輸出的報告 ocsdb01:[/oracle$]ls artisan_awr_diff_rpt* artisan_awr_diff_rpt.lst ocsdb01:[/oracle$]

檢視報告

這裡寫圖片描述