十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營維護(hù)+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
這篇文章將為大家詳細(xì)講解有關(guān)如何手工生成AWR運(yùn)行期對(duì)比報(bào)告,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。

AWR(Automatic Workload Repository)報(bào)告是Oracle 10g之后推出的重要性能診斷工具。AWR是作為Statspack報(bào)告的一種有力延伸。借助AWR,我們可以方便的對(duì)Oracle數(shù)據(jù)庫的特定工作時(shí)間段進(jìn)行性能分析評(píng)價(jià),最終達(dá)到發(fā)現(xiàn)瓶頸調(diào)優(yōu)的目標(biāo)。
作為DBA,手工生成AWR報(bào)告是工作基本功之一。筆者在之前的《手工生成AWR報(bào)告記錄》(http://space.itpub.net/17203031/viewspace-700471)中,就已經(jīng)詳細(xì)介紹過如何在sqlplus工具下生成AWR報(bào)告。
1、從AWR到AWR Compare Period Report
AWR是一個(gè)產(chǎn)品體系,根據(jù)定時(shí)收集的系統(tǒng)運(yùn)行數(shù)據(jù),我們其實(shí)可以做的更多。在現(xiàn)在主流的運(yùn)維管理和調(diào)優(yōu)過程中,基線baseline的概念是一直貫穿始終。系統(tǒng)運(yùn)行負(fù)載Baseline、關(guān)鍵SQL執(zhí)行計(jì)劃Baseline等等,反復(fù)出現(xiàn)??傊?,所謂的Baseline,簡(jiǎn)單的說就是一套運(yùn)行負(fù)載指標(biāo)或者執(zhí)行計(jì)劃指標(biāo)。當(dāng)你認(rèn)為系統(tǒng)出現(xiàn)問題的時(shí)候,可以將Baseline作為標(biāo)準(zhǔn)進(jìn)行對(duì)比,發(fā)現(xiàn)問題所在。進(jìn)一步的,可以將Baseline作為應(yīng)急手段,強(qiáng)制使用應(yīng)對(duì)生產(chǎn)(SQL Profile、SPM)。
我們一般的調(diào)優(yōu)過程中,也的確需要這樣的小工具。比如:業(yè)務(wù)高峰期和低谷期,數(shù)據(jù)庫各方面指標(biāo)有什么樣顯著的差異?進(jìn)行調(diào)優(yōu)之后,系統(tǒng)性能指標(biāo)有何種方式變化?這種時(shí)候,生成兩份AWR,看著對(duì)比的確是一種方法。但是,Oracle已經(jīng)為我們提供出AWR Compare Period Report來方便實(shí)現(xiàn)這樣的功能。
從原理上,AWR Compare Period Report不難理解。Oracle將各個(gè)時(shí)間snap的性能數(shù)據(jù)保存在SYSAUX表空間的一系列數(shù)據(jù)字典表中,只要經(jīng)過合理的組織,compare report不是一件困難的事情。
2、手工生成報(bào)告
本文是一篇記錄文章,依然采用手工sqlplus的方法生成報(bào)告。
ü 登錄sqlplus,運(yùn)行腳本
使用sqlplus,登錄入指定系統(tǒng)。
D:\>sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on 星期一 3月 5 09:02:42 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL>(登錄過程略……)
--調(diào)用腳本
SQL> @?/rdbms/admin/awrddrpt.sql
注意:在sqlplus中,?表示$ORACLE_HOME路徑。指定的awrddrpt.sql腳本,也是確實(shí)在客戶端本地的SQL執(zhí)行腳本。如果使用如PL/SQL Developer等開發(fā)工具,請(qǐng)指定直接路徑。
ü 輸入基本報(bào)告類型
首先同AWR報(bào)告一樣, Compare Period Report也存在TEXT和HTML兩種格式支持。在創(chuàng)建過程中,我們需要進(jìn)行選定。
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Id DB Name Inst Num Inst Num Instance
----------- ----------- ------------ -------- -------- ------------
2351142467 2351142467 NBSTEST 1 1 NBSTEST
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 的值:
Type Specified: html
ü 輸入第一對(duì)比時(shí)間段項(xiàng)目
既然要做到對(duì)比,首先需要指定一個(gè)對(duì)比時(shí)間范圍。這個(gè)過程同一般AWR報(bào)告相同,過程不予累述。
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
* 2351142467 1 NBSTEST NBSTEST P550_05_LC
Database Id and Instance Number for the First Pair of Snapshots
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using 2351142467 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
specifying a number lists all completed snapshots.
--輸入對(duì)比時(shí)間范圍
輸入 num_days 的值: 3
之后,Oracle會(huì)列出三天范圍的snap信息。
Listing the last 3 days of Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
NBSTEST NBSTEST 10251 03 3月 2012 00:00 1
10252 03 3月 2012 01:00 1
(篇幅原因,省略部分……)
10305 05 3月 2012 06:00 1
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
NBSTEST NBSTEST 10306 05 3月 2012 07:00 1
10307 05 3月 2012 08:00 1
10308 05 3月 2012 09:00 1
Specify the First Pair of Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
輸入 begin_snap 的值:
--指定時(shí)間片
Specify the First Pair of Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
輸入 begin_snap 的值: 10296
First Begin Snapshot Id specified: 10296
輸入 end_snap 的值: 10298
設(shè)定了開始和結(jié)束時(shí)間snap,作為第一個(gè)時(shí)間。
ü 輸入第二對(duì)比時(shí)間段項(xiàng)目
第二報(bào)告時(shí)間snap信息基本相同,不予累述。
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
* 2351142467 1 NBSTEST NBSTEST P550_05_LC
Database Id and Instance Number for the Second Pair of Snapshots
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using 2351142467 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
specifying a number lists all completed snapshots.
輸入 num_days2 的值:
輸入 num_days2 的值: 1
Listing the last day's Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
NBSTEST NBSTEST 10299 05 3月 2012 00:00 1
(篇幅原因,省略……)
10306 05 3月 2012 07:00 1
10307 05 3月 2012 08:00 1
10308 05 3月 2012 09:00 1
Specify the Second Pair of Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
輸入 begin_snap2 的值:
--輸入時(shí)間片
Specify the Second Pair of Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
輸入 begin_snap2 的值: 10306
Second Begin Snapshot Id specified: 10306
輸入 end_snap2 的值: 10308
ü 指定生成報(bào)告名稱,生成報(bào)告
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrdiff_1_10296_1_10306.html To use this name,
press
輸入 report_name 的值: --使用默認(rèn)名稱,保持為空
Using the report name awrdiff_1_10296_1_10306.html