(8)生成ASH報表 |
[君三思] 2009-11-7 |
五、生成ASH報表V$ACTIVE_SESSION_HISTORY 視圖瀏覽起來確實方便,不過對于新手朋友其易用性就打了折扣,而且直觀性方面也不太好,幸好ORACLE也提供了相應的報表腳本,可以生成指定的時間段內ASH相關的報表。 ORACLE 提供了兩個報表腳本,即可以用來生成數據庫級的統計信息,也可以針對RAC架構中某個實例在某個時間段的狀態生成統計,下面分別介紹。 1、生成指定時間段時的統計報表生成數據庫級ASH統計報表使用ashrpt.sql腳本,該文件保存在$ORACLE_HOME/rdbms/admin目錄下,基本上操作與AWR腳本非常類似,例如: SQL> @$ORACLE_HOME/rdbms/admin/ashrpt.sql Current Instance ~~~~~~~~~~~~~~~~ DB Id DB Name Inst Num Instance ----------- ------------ -------- ------------ 3812548755 TEST08 1 test08 Specify the Report Type ~~~~~~~~~~~~~~~~~~~~~~~ Enter ¨html¨ for an HTML report, or ¨text¨ for plain text Defaults to ¨html¨ Enter value for report_type: html這里讓選擇生成的報表類型,同樣是有html和text兩種,默認情況下為html類型。 選完類型后,接下來會顯示數據庫的一些基本信息,包括ASH收集到的信息的區間 Type Specified: html Instances in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id Inst Num DB Name Instance Host ------------ -------- ------------ ------------ ------------ * 3812548755 1 TEST08 test08 yans1 Defaults to current database Using database id: 3812548755 Defaults to current instance Using instance number: 1 ASH Samples in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Oldest ASH sample available: 09-10 月-09 10:11:02 [ 38853 mins in the past] Latest ASH sample available: 05-11 月-09 09:43:09 [ 0 mins in the past] Specify the timeframe to generate the ASH report ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter begin time for report: -- Valid input formats: -- To specify absolute begin time: -- [MM/DD[/YY]] HH24:MI[:SS] -- Examples: 02/23/03 14:30:15 -- 02/23 14:30:15 -- 14:30:15 -- 14:30 -- To specify relative begin time: (start with ¨-¨ sign) -- -[HH24:]MI -- Examples: -1:15 (SYSDATE - 1 Hr 15 Mins) -- -25 (SYSDATE - 25 Mins) Defaults to -15 mins Enter value for begin_time: -10輸入報表分析的開始時間,這里即可以輸入一個時間類型的字串,比如09/23/2009 14:30:15,也可以直接輸入時間,甚至更簡單的,輸入一個負整數例如-10,表示當前時間前10分鐘做為開始時間。 Report begin time specified: -10 Enter duration in minutes starting from begin time: Defaults to SYSDATE - begin_time Press Enter to analyze till current time Enter value for duration: 8然后要輸入統計的時間段,注意喲,不是讓輸入結束時間,而是說在前面輸入的開始時間的基礎上,希望收集多長時間內的信息做統計,默認情況下為sysdate-begin_time,即從開始時間到當前時間,這里為了顯的與眾不同,我就隨便敲了個8。 Report duration specified: 8 Using 05-11 月-09 09:33:44 as report begin time Using 05-11 月-09 09:41:44 as report end time ........................ ........................ Specify the Report Name ~~~~~~~~~~~~~~~~~~~~~~~ The default report file name is ashrpt_1_1105_0941.html. To use this name, press 輸入報表的名稱,默認會根據前面輸入的值來生成一個名稱,比如這里默認生成的名稱為ashrpt_1_1105_0941.html。 Using the report name ashrpt_1_1105_0941.html Summary of All User Input ------------------------- Format : HTML DB Id : 3812548755 Inst num : 1 Begin time : 05-11 月-09 09:33:44 End time : 05-11 月-09 09:41:44 Slot width : Default Report targets : 0 Report name : ashrpt_1_1105_0941.html 報表成功生成,可以隨時打開ashrpt_1_1105_0941.html瀏覽詳細信息了。 2、生成指定數據庫實例的指定時間段時的統計報表對于RAC架構的數據庫,有時候DBA可能會希望看到其中某個節點(或實例)的負載情況,這種情況下,可以使用ashwrpi.sql(附加的i應該是表示instance),例如: SQL> @$ORACLE_HOME/rdbms/admin/ashrpti.sql Specify the Report Type ~~~~~~~~~~~~~~~~~~~~~~~ Enter ¨html¨ for an HTML report, or ¨text¨ for plain text Defaults to ¨html¨ Enter value for report_type: html選擇生成的報表文件類型,仍然選擇html類型。 Type Specified: html Instances in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id Inst Num DB Name Instance Host ------------ -------- ------------ ------------ ------------ 948405229 2 JSSDB jssdbn2 jssdbn2 * 948405229 1 JSSDB jssdbn1 jssdbn1 Defaults to current database Enter value for dbid: 948405229這里多了兩步,首先是要選擇數據庫的DBID,接下來是選擇實例ID。 Using database id: 948405229 Defaults to current instance Enter value for inst_num: 1 Using instance number: 1 ASH Samples in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Oldest ASH sample available: 15-Oct-09 21:24:53 [ 29499 mins in the past] Latest ASH sample available: 05-Nov-09 09:00:56 [ 3 mins in the past] Specify the timeframe to generate the ASH report ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter begin time for report: -- Valid input formats: -- To specify absolute begin time: -- [MM/DD[/YY]] HH24:MI[:SS] -- Examples: 02/23/03 14:30:15 -- 02/23 14:30:15 -- 14:30:15 -- 14:30 -- To specify relative begin time: (start with ¨-¨ sign) -- -[HH24:]MI -- Examples: -1:15 (SYSDATE - 1 Hr 15 Mins) -- -25 (SYSDATE - 25 Mins) Defaults to -15 mins Enter value for begin_time:輸入開始的時間,后面的步驟與前面生成數據庫級的操作完全相同,不再演示。 前面介紹的這種種特性以及腳本均是工具,工具永遠都只是起輔助的作用,能不能用好,還是取決于使用工具的人,祝好運吧。 |