五、生成ASH報(bào)表
V$ACTIVE_SESSION_HISTORY 視圖瀏覽起來確實(shí)方便,不過對(duì)于新手朋友其易用性就打了折扣,而且直觀性方面也不太好,幸好ORACLE也提供了相應(yīng)的報(bào)表腳本,可以生成指定的時(shí)間段內(nèi)ASH相關(guān)的報(bào)表。
ORACLE 提供了兩個(gè)報(bào)表腳本,即可以用來生成數(shù)據(jù)庫級(jí)的統(tǒng)計(jì)信息,也可以針對(duì)RAC架構(gòu)中某個(gè)實(shí)例在某個(gè)時(shí)間段的狀態(tài)生成統(tǒng)計(jì),下面分別介紹。
1、生成指定時(shí)間段時(shí)的統(tǒng)計(jì)報(bào)表
生成數(shù)據(jù)庫級(jí)ASH統(tǒng)計(jì)報(bào)表使用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
這里讓選擇生成的報(bào)表類型,同樣是有html和text兩種,默認(rèn)情況下為html類型。
選完類型后,接下來會(huì)顯示數(shù)據(jù)庫的一些基本信息,包括ASH收集到的信息的區(qū)間
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
輸入報(bào)表分析的開始時(shí)間,這里即可以輸入一個(gè)時(shí)間類型的字串,比如09/23/2009 14:30:15,也可以直接輸入時(shí)間,甚至更簡單的,輸入一個(gè)負(fù)整數(shù)例如-10,表示當(dāng)前時(shí)間前10分鐘做為開始時(shí)間。
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
然后要輸入統(tǒng)計(jì)的時(shí)間段,注意喲,不是讓輸入結(jié)束時(shí)間,而是說在前面輸入的開始時(shí)間的基礎(chǔ)上,希望收集多長時(shí)間內(nèi)的信息做統(tǒng)計(jì),默認(rèn)情況下為sysdate-begin_time,即從開始時(shí)間到當(dāng)前時(shí)間,這里為了顯的與眾不同,我就隨便敲了個(gè)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 to continue, otherwise enter an alternative.
Enter value for report_name:
輸入報(bào)表的名稱,默認(rèn)會(huì)根據(jù)前面輸入的值來生成一個(gè)名稱,比如這里默認(rèn)生成的名稱為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
報(bào)表成功生成,可以隨時(shí)打開ashrpt_1_1105_0941.html瀏覽詳細(xì)信息了。
2、生成指定數(shù)據(jù)庫實(shí)例的指定時(shí)間段時(shí)的統(tǒng)計(jì)報(bào)表
對(duì)于RAC架構(gòu)的數(shù)據(jù)庫,有時(shí)候DBA可能會(huì)希望看到其中某個(gè)節(jié)點(diǎn)(或?qū)嵗?的負(fù)載情況,這種情況下,可以使用ashwrpi.sql(附加的i應(yīng)該是表示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
選擇生成的報(bào)表文件類型,仍然選擇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
這里多了兩步,首先是要選擇數(shù)據(jù)庫的DBID,接下來是選擇實(shí)例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:
輸入開始的時(shí)間,后面的步驟與前面生成數(shù)據(jù)庫級(jí)的操作完全相同,不再演示。
前面介紹的這種種特性以及腳本均是工具,工具永遠(yuǎn)都只是起輔助的作用,能不能用好,還是取決于使用工具的人,祝好運(yùn)吧。
|