-【優秀資料】AWR學習_第1頁
-【優秀資料】AWR學習_第2頁
-【優秀資料】AWR學習_第3頁
-【優秀資料】AWR學習_第4頁
-【優秀資料】AWR學習_第5頁
已閱讀5頁,還剩38頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、一.ash和awr的故事1. 1 關于ash我們都知道,用戶在oracle數據庫中執行操作時,必然耍創建相應的連接和會話,其 中,所冇當前的會話信息都保存在動態性能視圖vssession中,通過該視圖,dba可以查看 用戶實際執行的操作,或者當前的等待事件等。通常這部分信息是調優過程小的關鍵信息, 不過,一旦連接斷開。會話信息就會被同時從v$sesston及其它相關視圖中清除,也就是說, 川戶執行完操作走人,而你(dba),如果不能在當前逮到他,過了這點,就不知道它曾經做 過什么了。10g版木中,oracle又新增加了一個視圖(其它是若干,不過咱們還是以session為引 子說):v$ act

2、 i ve_sess t on_hi story,看名字就知道,就是活動會話的歷史記錄,這下,即 使用八操作完成后,斷開了連接也不怕,因為其會話的情況己經被記錄了下來,這項特性就 是ash 了,全稱與視圖名相同,正是:active session history。ash每秒鐘收集一次當詢處于非空閑等待事件的、活動狀態的、session的信息,并保 存在v$act1ve session history視圖中,我們(應該以及必須)知道,動態性能視圖其實上 是oracle b行構造的一堆存在于sga內存區的虛表,就是說,ash的數據是保存在內存里 的,實際上,oracle分配給ash的空間并不是無限

3、大(更何況oracle自身管理的內存空間 也不是無限大),查看ash可供使用的內存空間,可以通過如下sql:sql> select pool, name, bytes/1024/1024 mb from v$sgastat where name like "ash ;poolnamembshared pool ash buffers15.5直口的講,v$act1ve_sess1on_h1story 能夠記錄多少會話信息,一方面取決于該 數據庫的sga分配給ash buffers的人小,另一方面取決于數據庫的啟動和關閉(重啟數 據庫時將重構sga內存區)。這兩方面的因素制約了 v

4、$acttve_sesstonjitstory中能夠保存 的會話信息的能力,做為dba,我們肯定是希望八sh盡可能多的保簾關于會話的信息,但冃 前來看單純依靠v$active_session_history肯定無法實現這點,那怎么辦呢?別擔心, oracle 乂提供了 awr特性,ash收集到的會話信息,是做為awr小快照信息的一部分,被保 存到了硬盤上。1.2關于awrawr 是 oracle log 版本 推出的新特性,全稱叫 automatic work 1 oad repository- 白動負載信息庫。談到這一特性呢,不得不先提statspack, statspack稱的上是orac

5、le 世界里的老人了,不過畢竟年歲大了,腿腳雖然還算靈便,但效率不那么高了,用時髦話講 就是不能適應時代發展步伐,不能緊跟時代潮流,不能保持做為一名優秀黨員的先進性,始 終堅持帶三個表的為dba服務。但是,說到底statspack還是為了黨國事業奮斗了一輩了, 在黨內還是有勢力有威信有地位有影響的四有老人,還有余熱可以發揮,雖然其在統計實 時性方面,表現已不足以滿足dba多變的需求,依然 不能一下就將其拿下,因此oracle釆 収漸進方式先推出了 awr,說是輔助statspack i作,其實明眼人一看就明了,這是新指 定的接班人哪。提示:關于statspack的學和用請參考三思筆記相關章節:

6、 http:/www. 5ienet. com/note/html/stat/index. shtmlawr與前輩statspack在職業定位方面是相同的,都是負責收集、處理并維護性能統計 信息,用于檢查和分析性能問題(甚至生成的報告格式都非常接近),awr生成的統計數據即 可以通過v$視圖和dba_*數據字典杳看,也可以通過腳本來生成相應報表。談到相比 statspack, awr究竟在哪些方面冇所提升呢,撿主要的講就兩條:自動+實時,至于功能上 的些許提高,不過是因為awr年輕腿腳利索罷了。提示:進入10g版本,oracle更加注重強調使川em (enterprise manager)管理

7、各項操作, 不過考慮性能、通用度等各方而因素,這里-:思仍然主要通過腳本操作來使用awr 和ash的各項功能。二、生成分析報表awr是通過對比兩次快照(snapshot)收集到的統計信息,來生成報表數據,生成的報表 包括多個部分,這點statspack生成的報告非常類似。不過awr在生成報告吋,nj以選擇 生成txt或html兩種格式的報告,相對來說,html更利于閱讀,而txt的適用性更廣(即 使在不能使用瀏覽器的機器上也能看)0操作過statspack的朋友都還記的,牛成報告使用 $oracle_home/rdbms/admin/spreport. sql腳本,到了 awr這片,操作步驟基

8、本上相同,不 過生成報告的腳本多了很多選擇,包括: awrrpt. sql :生成指定快照區間的統計報表; awrrpti. sql :生成指定數據庫實例,并且指定快照區間的統計報表; awrsqlrpt. sql :牛成指定快照區間,指定sql語句(實際指定的是該語句的sql1d) 的統計報表; awrsqrpi. sql :生成指定數據庫實例,指定快照區間的指定sql語句的統計報表; awrddrpt.sql :指定兩個不同的時間周期,生成這兩個周期的統計對比報表; awrddrpi. sql :指定數據庫實例,并指定兩個的不同吋間周期,生成這兩個周期的 統計對比報表;下而的章節中,我們就

9、來一一例舉。提示:與使用statspack 樣,耍想讓awr收集到準確的統計信息,從而生成可靠 的性能分析報告,必須將初始化參數statistics_level的值設置為typical或al丄。2. 1生成標準統計報表過程并不復雜,卜列操作中加粗的部分,是需要指定值的位置(注意,執行報表生成的 用戶必須擁冇dba角色):jssweb>$oracle_home/rdbms/admin/awrrpt. sqlcurrent instancedb td db name tnstnum instance3812548755 test08 1 testosspecify the report ty

10、pewould you like an html report, or a plain text report?enter html " for an html report, or " text " for plain textdefaults to * html *enter value for reporttype: html此處需指定生成的報表格式,有txt和html兩種選擇,默認情況下為html格式,這里 為演示起見,輸入html otype specified: htmlinstances in this workload repository sch

11、emadb td tnstnum db name instance host* 3812548755 1 test08 test08 yanslusing 3812548755 for database idusing 1 for instanee numberspecify the number of days of snapshots to choose fromentering the number of days (n) wi 11 resul t in the most recent(n) days of snapshots being listed. pressing withou

12、t specifying a number lists all completed snapshots.enter value for num days: 2mm此處需指定要讀収多少天內的快照倍息!listing the last 2 days of completed snapshotssnapinstanee db name snap id snap started leveltestob test08 733073312010月200973322010月200973332010月200973342010月200973352010刀200920 10 月 2009 00:00 101:00

13、 102:00 103:00 104:00 105:01 17336 20 10 刀 2009 06:00 17337 20 10 m 2009 07:01 173382010刀200908:0073392010月200909:0073402010月200910:0073412010月200911:0073422010月200912:0073432010刀200913:0073442010刀200914:0073452010刀200915:0073462010月200916:0073472010月200917:0073482010月200918:0073492010月200919:007350

14、2010刀200920:0073512010月200921:0073522010刀200922:0073532010月200923:0073542110月200900:0073552110月200901:0073562110月200902:0073572110月200903:0073582110月200904:0073592110刀200905:0011111111111111111111117360 21 10 刀 2009 06:00 173612110月200907:00173622110刀200908:00173632110月200909:00173642110月200910:0017

15、3652110月200911:00173662110月200912:00173672110刀200913:00173682110刀200914:001specifythe begin and end snapshot tdsenter value for begin snap: 7331begin snapshot id specified: 7331enter value for end snap: 7355end snapshot id specified: 7355specify the report namethe default report file name is awrrpt

16、1 7331 7355. html. to use this name, press to continue, otherwise enter an alternative.enter value for report_name:此處為要生成的報告指定一個文件名,默認會根據前而輸入的snap.id生成一個文件 名,比如這里生成的默認文件名為awrrpt_l_7331-7355. html,當然dba可以根據實際情況 對文件名進行自定義。這里三思偷個懶,就用默認文件名好了,直接回車。接下來就不需要dba再輸入什么了,等著oracle給你生成報表吧。using the report name aw

17、rrpt_l_7331_7355.htmlend of reportreport written to qwrrpt_l_7331_7355.html打開最終牛成的統計報表,界而如下:workload repository report fordb namebldtest083812548755 test08inst numreleaserachost |r.0noyanslinstancesnap idsnap timesessionscursors/session |begin snap:733120-10 月-09 3:00:571 17|3.5end snap:7355

18、21-10月(k 01:00:14i16| 2.8(elapsed:|1,439.29 (mins)|db伽氏1.06 (mins)report summarycache sizesbeginendbuffer cache:2,016m2,016mstd block size:|16kshared pool size:|20m320mlog buffer:|4.356kload profile提示:問:前面提示輸入snaps時哪來的這么多snapshots啊?答:這都是oracle偷偷摸摸一點一點(每小時一次)收集的啊!問:它究竟收集了多久的啊?答:從當前的記錄看,至少有7天了!問:究竟啥是s

19、napshot啊?答:接著往下看!2.2生成指定數據庫實例的統計報表這項統計報表一般是針對多實例數據庫,前面使用的腳本是生成數據庫級別的統計報 表,對于多實例的數據庫,有時候dba可能希望看到某個實例的表現,那么本腳本就能派上 用場了。其實操作與上非常類似(都比較簡單,需耍dba敲的字符加一塊也沒幾個),注意執 行的腳本不同的喲。sql> $oracle_home/rdbms/admin/awrrpti. sqlspecify the report typewould you 1ike an html report, or a plain text report?enter "

20、" html * for an html report, or text for plain textdefaults to " htmlenter value for report type:此處需指定生成的報表格式,冇txt和html兩種選擇,默認情況下為html格式。type specified: htmlinstances in this workload repository schemadb id inst num db nameinstance host9484052292 jssdbjssdbn2 jssdbn2* 9484052291 jssdbjssdb

21、nljssdbnlenter value for dbid: 948405229using 948405229 for database identer value for instnum: 1using 1 for instanee number相比標準統計報表的生成,這里多了兩個需指定的值,就是選擇要工成報表的db1d以 及實例的idospecify the number of days of snapshots to choose fromentering the rmmber of days (n) wi11 result in the most recent (n) days of

22、snapshots being listed. pressing <return> without specifying a number lists all completed snapshots.enter value for num_days: 2指定要讀取多少天內的快照信息。listing the last 2 days of completed snapshotssnapinstance db namesnap id snap started leveljssdbnljssdb235 22 oct 2009 00:00236 22 oct 2009 01:0011237

23、22 oct 2009 02:001238 22 oct 2009 03:001239 22 oct 2009 04:001240 22 oct 2009 05:001241 22 oct 2009 06:001242 22 oct 2009 07:001oct 2009 08:00oct200909:00oct200910:00oct200911:00oct200912:00oct200913:00oct200914:00oct200915:00oct200916:00oct200917:00oct200918:00oct200919:00oct200920:00oct200921:00oc

24、t200922:00oct200923:00oct200900:00oct200901:00oct200902:00oct200903:00oct200904:00oct200905:00oct200906:00oct200907:00267 23 oct 2009 08:00specify the begin and end snapshot tdsenter value for begin_snap:剩下的步驟就與標準統計報表的步驟完全相同,這里就不重復演示了。2.3生成指定sql語句的統計報表這項統計專門用來分析某條指定的sql語句,通過awrsqrpt. sql腳木,awr能夠生成 指

25、定sql (曾經執行過的sql)的執行計劃,消耗的資源等等信息,有助于dba進行sql調優。具體操作如下,首先還是執行生成腳木:sql> $0racle_h0me/rdbms/admin/awrsqrpt. sqlcurrent instancedb id db nameinst num instance1 test083812548755 test08specify the report typewould you like an html report, or a plain text report?enterhtml for an html report, or text for

26、plain textdefaults to htmlenter value for report_type: html選擇生成的報表格式,沒啥說的,就默認的h51格式吧。type specified: htmlinstances in this workload repository schemadb id inst num db nameinstancehost* 38125487551 test08test08van siusing 3812548755 for database idusing1 for instance numberspecify the numbcr of days

27、of snapshots to choose fromentering the numbcr of days (n) will result in the most recent(n) days of snapshots being 1isted. pressing <return> without specifying a number lists all completed snapshots.enter value for num_days: 2指定報表快照的生成區間!listing the last 2 days of completed snapshotssnapinst

28、ance db namesnap id snap started leveltest08test0874502510刀200900:00174512510月200901:00174522510月200902:00174532510月200903:00174542510月200904:00174552510月200905:00174562510月200906:00174572510月200907:00174582510月200908:00174592510月200909:00174602510月200910:00174612510月200911:00174622510月200912:001746

29、32510月200913:00174642510月200914:00174652510月200915:00174662510月200916:00174672510月200917:00174682510月200918:00174692510刀200919:00174702510月200920:00174712510月200921:00174722510月200922:00174732510月200923:00174742610刀200900:00174752610月200901:00174762610月200902:00174772610月200903:00174782610月200904:00

30、174792610月200905:00174802610月200906:00174812610月200907:00174822610月200908:00174832610月200909:00174842610月200910:001specify the begin and end snapshot idsenter value for begin snap: 7451begin snapshot id specified: 7451enter value for end snap: 7475endsnapshot id specified: 7475指定開始和結束的快照id:specify t

31、he sql identer value for sqlid: a51q9un8jlkv6注意嘍,這里要指定分析的sql_1d,你可能想問,要分析的sql id從何而來呢? 一般 來說,提出這種問題說明你還未操作過awr或看到一條sql。為什么這么說呢,因為一般來 講,獲取問題sql的途徑要么是通過v$sql(及其它相關視圖),要么是通過awr/statspack 等工具,而這些方式找到sql語句時,只要你再稍微拿眼神的旁光這么一掃,就會發現在語 句的旁邊有一條sql id靜靜的品立著:)sql id specified: a51q9un8jlkv6specify the report nam

32、ethe default report file name is awrsqlrpt 1 7451 7475.him1 to use thi s name,press <return> to continue, otherwise enter an alternative.enter value for report_name: awr_sqlrpt_l_7451_7475.htmlusing the report name awr sqlrpt 1 7451 7475.html<htmlxheadxtttle>awr sql report</tttlexstyl

33、e type二text/css>輸入完sql id后,短暫等待兒秒鐘,報告就生成了。2.4生成指定數據庫實例中指定sql語句的統計報表本項統計報表主要針對多實例數據庫,不過革本操作與上非常類似(都比較簡單,需要 dba敲的字符加一塊也沒幾個),具體操作如下:sql> $oracle_home/rdbms/admin/awrsqrpi. sqlspecify the report typewould you like an html report, or a plain text report?enter html for an html report, or "text

34、for plain textdefaults to " html "enter value for report_type:type specified: htmlinstances in this workload repository schemadb idinst num db nameinstancehost9484052292 jssdbjssdbn2jssdbn2* 9484052291 jssdbjssdbnljssdbnlenter value fordbid: 948405229using 948405229for database identer val

35、ue forinst num: 1using 1 for instanee number指定dbid以及實例的id序號。choose fromspecify the number of days of snapshots toentering the number of days (n) wi11 result in the most rccent (n) days of snapshots being 1isted. pressing <return> without specifying a number lists all completed snapshots.enter

36、value for num days: 2listing the last 7 days of completed snapshotssnapinstaneedb namesnap id snap started leveljssdbnl jssdb23522oct200900:00123622oct200901:00123722oct200902:00123822oct200903:00123922oct200904:00124022oct200905:00124122oct200906:001oct 2009 07:00oct200908:00oct200909:00oct200910:0

37、0oct200911:00oct200912:00oct200913:00oct200914:00oct200915:00oct200916:00oct200917:00oct200918:00oct200919:00oct200920:00oct200921:00oct200922:00oct200923:00oct200900:00oct200901:00oct200902:00oct200903:00oct200904:00oct200905:00oct200906:00266 23 oct 2009 07:00267 23 oct 2009 08:001specify the begi

38、n and end snapshot tdsenter value for begin snap: 236begin snapshot id specified: 236enter value for end_snap: 260endsnapshot id specified: 260指定開始和結束的快照id:specify the sql idenler value for sql id: 7tc5u8t3mmzgf 指定要分析的sql_tdosql id specified: 7tc5u8t3mmzgfspecify the report namethe default report fi

39、le name is awrsq1rpt 1 236 260. html. to use this name,press <return> to continue, otherwise enter an alternative.enter value for report_name:using the report name awrsqlrpt 1 236 260. html<htmlxheadxtitle>awr sql report</title>awr 口動生成分析報農。2.5生成不同時間段時的統計對比報表在沒冇awrz前,如果希望對不同時間段時,數據

40、庫的整體影響進行對比,只能依靠 dba手工查詢和關視圖,并通過時間條件來獲取差異(還有些統計已經無法對比),而在awr 中,直接就提供了,對不同時間段吋,數據庫的性能統計做差異對比的功能。執行腳木如下:sql> $oracle_home/rdbms/admin/awrddrpt. sqlcurrent tnstaneedb iddb id db nameinst num inst num instance3812548755 3812548755 test0811 testobspecify the report typewou1d you 1 ike an html report, o

41、r a plain text report?enter " html for an html report, or text for plain textdefaults to " htmlenter value for report_type: html牛成的報表格式,沒啥說的,就默認的html格式吧。type specified: htmlinstances in this workload repository schemadb tdinst num db nameinstancehost* 38125487551 test08test08yansldatabase

42、td and tnstance number for the first pair of snapshotsusing 3812548755 for database id for the first pair of snapshotsusing1 for instanee number for the first pair of snapshots注意,下面緊接著,是選擇笫一份報表的和關參數,包括快照的區間,以及開始和結束 的快照1d:specify the number of days of snapshots to choose fromentering the number of da

43、ys (n) wi 11 result in the most recent(n) days of snapshots being iistedpressing <return> withoutspecifying a number 1ists al 1 completed snapshots.enter value for numdays: 2listing the last 2 days of completed snapshotssnapinstaneedb namesnap id snap started leveltest08test0874502510月200900:0

44、0174512510月200901:00174522510月200902:00174532510月200903:00174542510月200904:00174552510月200905:00174562510月200906:00174572510月200907:00174582510月200908:00174592510月200909:00174602510月200910:00174612510月200911:00174622510刀200912:00174632510月200913:00174642510月200914:00174652510月200915:00174662510月2009

45、16:00174672510月200917:00174682510月200918:00174692510月200919:00174702510月200920:00174712510月200921:00174722510月200922:00174732510月200923:00174742610月200900:00174752610月200901:00174762610月200902:00174772610刀200903:00174782610月200904:00174792610月200905:00174802610月200906:0017481 2610月200907:0017482 261

46、0月200908:0017483 2610月200909:0017484 2610月200910:0017485 2610月200911:0017486 2610月200912:0017487 2610月200913:0017488 2610月200914:0017489 2610月200915:001specify the first pair of begin and end snapshot idsenter value for begin snap: 7459first begin snapshot td specified: 7459enter value for end_snap:

47、 7462first endsnapshot id specified: 7462然后,是選擇要對比的報表相關參數,包括快照的區間,以及開始和結束的快照1d:instances in this workload repository schemadb id inst num db name instance host* 38125487551 test08testobyansldatabase id and instanee number for the second pair of snapshotsusing 3812548755 for database id for the secon

48、d pair of snapshotsusing1 for instance number for the second pair of snapshotsspecify the number of days of snapshots to choose fromentering the number of days (n) wi11 result in the most recent (n) days of snapshots being listed pressing <return> without speci fying a number 1ists al i completed snapshots.enter value for num davs2: 2listing the last 2 days of completed snapshotssnapinstancedb namesnap id snap started leveltest08test0874502510月200900:00174512510月200901:00174522510月200902:00174532510月200903:00174542510月200904:00174552510月200905:00174562510月200906:0017

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論