您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)oracle 11g如何創(chuàng)建基線,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
性能優(yōu)化時(shí)大體有如下兩種評(píng)估方式:如果希望知道性能度量值指示服務(wù)器接近容量限制,則應(yīng)設(shè)置絕對(duì)值;但是如果希望知道今天的性能與上周(或者上個(gè)月)同一時(shí)間的性能之間的差異,則當(dāng)前性能必須與基線進(jìn)行比較,基線是某個(gè)時(shí)段內(nèi)生成的一組快照,按照統(tǒng)計(jì)學(xué)對(duì)這些快照進(jìn)行了分組,以便獲得一組隨時(shí)間變化的基線值,可以以任何時(shí)段快照采樣來(lái)做基線,只不過(guò)一般情況下我們大多會(huì)選擇系統(tǒng)正常時(shí)段的快照來(lái)做基線。
基線在oracle 10g中就出現(xiàn)了,而在oracle database 11g進(jìn)一步增強(qiáng)了自動(dòng)工作量資料檔案庫(kù)基線:
1 即用型移動(dòng)窗口基線,可通過(guò)該基線指定自適應(yīng)閥值
2 使用基線模板安排基線的創(chuàng)建操作
3 重命名基線
4 設(shè)置基線的到期日期
AWR baseline是指一個(gè)特定時(shí)間段內(nèi)的性能數(shù)據(jù),保留這些數(shù)據(jù)是為了在性能問(wèn)題產(chǎn)生時(shí)與其他類似的工作負(fù)載時(shí)間段進(jìn)行比較:
fixed baseline:fixed baseline表示的是您制定的一個(gè)固定的、連續(xù)的時(shí)間段
moving window baseline:表示的是war保留期內(nèi)存在的所有war數(shù)據(jù)
Baseline template:您可以使用baseline template創(chuàng)建將來(lái)某個(gè)連續(xù)時(shí)間段的baseline,oracle中有兩種baseline模板分別是single和repeating
創(chuàng)建fixed baseline:
SQL> begin
2 dbms_workload_repository.create_baseline(
3 start_snap_id=>1510,
4 end_snap_id=>1511,
5 baseline_name=>'test_baseline');
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> select dbid,baseline_name,start_snap_id,end_snap_id,MOVING_WINDOW_SIZE,EXPIRATION from dba_hist_baseline;
DBID BASELINE_NAME START_SNAP_ID END_SNAP_ID MOVING_WINDOW_SIZE EXPIRATION
---------- ---------------------------------------------------------------- ------------- ----------- ------------------ ----------
4257181262 test_baseline 1510 1511
4257181262 SYSTEM_MOVING_WINDOW 1515 1591 8
創(chuàng)建baseline的procedure和function
根據(jù)snap_id創(chuàng)建:
PROCEDURE CREATE_BASELINE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
START_SNAP_ID NUMBER IN
END_SNAP_ID NUMBER IN
BASELINE_NAME VARCHAR2 IN
DBID NUMBER IN DEFAULT
EXPIRATION NUMBER IN DEFAULT
FUNCTION CREATE_BASELINE RETURNS NUMBER
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
START_SNAP_ID NUMBER IN
END_SNAP_ID NUMBER IN
BASELINE_NAME VARCHAR2 IN
DBID NUMBER IN DEFAULT
EXPIRATION NUMBER IN DEFAULT
根據(jù)時(shí)間創(chuàng)建:
PROCEDURE CREATE_BASELINE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
START_TIME DATE IN
END_TIME DATE IN
BASELINE_NAME VARCHAR2 IN
DBID NUMBER IN DEFAULT
EXPIRATION NUMBER IN DEFAULT
FUNCTION CREATE_BASELINE RETURNS NUMBER
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
START_TIME DATE IN
END_TIME DATE IN
BASELINE_NAME VARCHAR2 IN
DBID NUMBER IN DEFAULT
EXPIRATION NUMBER IN DEFAULT
還可以刪除和重命名baseline:
SQL> begin
2 dbms_workload_repository.drop_baseline(
3 baseline_name=>'test_baseline',
4 cascade=>true);
5 end;
6 /
PL/SQL procedure successfully completed.
在oracle 11g中系統(tǒng)已經(jīng)默認(rèn)創(chuàng)建moving window baseline:
SQL> select dbid,baseline_name,start_snap_id,end_snap_id,MOVING_WINDOW_SIZE,EXPIRATION from dba_hist_baseline;
DBID BASELINE_NAME START_SNAP_ID END_SNAP_ID MOVING_WINDOW_SIZE EXPIRATION
---------- ---------------------------------------------------------------- ------------- ----------- ------------------ ----------
4257181262 SYSTEM_MOVING_WINDOW 1515 1591 8
drop baseline時(shí)如果指定cascade=>true,將把baseline對(duì)應(yīng)的snap也級(jí)聯(lián)刪除了
oracle database會(huì)自動(dòng)維護(hù)系統(tǒng)定義的moving window baseline,系統(tǒng)定義的moving window baseline的默認(rèn)窗口大小就是當(dāng)前的AWR保留期,如果打算使用自適應(yīng)閥值,請(qǐng)考慮使用更長(zhǎng)的移動(dòng)窗口,比如30天,以便精確的計(jì)算閥值。移動(dòng)窗口的大小調(diào)整為小于或等于AWR的保留天數(shù),因?yàn)橐黾右苿?dòng)窗口的大小,必須要先增加相應(yīng)的AWR保留期限。
調(diào)整awr的保留周期:
SQL> exec dbms_workload_repository.modify_snapshot_settings(retention=>43200);
PL/SQL procedure successfully completed.
SQL> select retention from dba_hist_wr_control;
RETENTION
---------------------------------------------------------------------------
+00030 00:00:00.0
SQL> select baseline_id,baseline_name,moving_window_size from dba_hist_baseline;
BASELINE_ID BASELINE_NAME MOVING_WINDOW_SIZE
----------- ---------------------------------------------------------------- ------------------
0 SYSTEM_MOVING_WINDOW 8
SQL> exec dbms_workload_repository.modify_baseline_window_size(window_size=>30);
PL/SQL procedure successfully completed.
SQL> select baseline_id,baseline_name,moving_window_size from dba_hist_baseline;
BASELINE_ID BASELINE_NAME MOVING_WINDOW_SIZE
----------- ---------------------------------------------------------------- ------------------
0 SYSTEM_MOVING_WINDOW 30
基線模板:基線模板允許定義可能在將來(lái)要捕捉的基線,create_baseline_template存儲(chǔ)過(guò)程定義單一基線或重復(fù)基線的捕捉,創(chuàng)建單一基線模板與創(chuàng)建基于時(shí)間的基線類似,除了將來(lái)的時(shí)間外。
single基線模板:
PROCEDURE CREATE_BASELINE_TEMPLATE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
START_TIME DATE IN
END_TIME DATE IN
BASELINE_NAME VARCHAR2 IN
TEMPLATE_NAME VARCHAR2 IN
EXPIRATION NUMBER IN DEFAULT
DBID NUMBER IN DEFAULT
SQL> exec DBMS_WORKLOAD_REPOSITORY.create_baseline_template(start_time=>TO_DATE('09-MAR-2016 00:00', 'DD-MON-YYYY HH24:MI'),end_time=>TO_DATE('16-MAR-2016 05:00', 'DD-MON-YYYY HH24:MI'),baseline_name=>'09_11_14_BS1',template_name =>'09_11_14_TP1',expiration=> 10);
PL/SQL procedure successfully completed.
SQL> select dbid,template_name,template_type,baseline_name_prefix,start_time,end_time,duration,expiration from dba_hist_baseline_template;
DBID TEMPLATE_NAME TEMPLATE_ BASELINE_NAME_PREFIX START_TIME END_TIME DURATION EXPIRATION
---------- ------------------------------ --------- ------------------------------ ------------------- ------------------- ---------- ----------
4257181262 09_11_14_TP1 SINGLE 09_11_14_BS1 2016-03-09 00:00:00 2016-03-16 05:00:00 10
重復(fù)基線模板稍微有點(diǎn)不同,因?yàn)樗枰{(diào)度信息,start_time和end_time參數(shù)分別在模板激活和釋放時(shí)定義,day_of_week、hour_in_day和duration定義產(chǎn)生基線的日期、時(shí)間和持續(xù)時(shí)間,因?yàn)槟0鍟?huì)產(chǎn)生多個(gè)基線,基線名是以baseline_name_prefix開(kāi)始的。
repeat基線模板:
PROCEDURE CREATE_BASELINE_TEMPLATE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
DAY_OF_WEEK VARCHAR2 IN
HOUR_IN_DAY NUMBER IN
DURATION NUMBER IN
START_TIME DATE IN
END_TIME DATE IN
BASELINE_NAME_PREFIX VARCHAR2 IN
TEMPLATE_NAME VARCHAR2 IN
EXPIRATION NUMBER IN DEFAULT
DBID NUMBER IN DEFAULT
exec DBMS_WORKLOAD_REPOSITORY.create_baseline_template(day_of_week=>'MONDAY',hour_in_day=>0,duration=>5,start_time=>SYSDATE,end_time=>ADD_MONTHS(SYSDATE, 6),baseline_name_prefix =>'monday_morning_bl',template_name=>'monday_morning_tp',expiration=> NULL);
SQL> select dbid,TEMPLATE_NAME,TEMPLATE_TYPE,BASELINE_NAME_PREFIX,START_TIME,END_TIME,DAY_OF_WEEK,HOUR_IN_DAY,DURATION,EXPIRATION,REPEAT_INTERVAL from dba_hist_baseline_template;
DBID TEMPLATE_NAME TEMPLATE_ BASELINE_NAME_PREFIX START_TIME END_TIME DAY_OF_WE HOUR_IN_DAY DURATION EXPIRATION
---------- ------------------------------ --------- ------------------------------ ------------------- ------------------- --------- ----------- ---------- ----------
REPEAT_INTERVAL
--------------------------------------------------------------------------------
4257181262 09_11_14_TP1 SINGLE 09_11_14_BS1 2016-03-09 00:00:00 2016-03-16 05:00:00 10
4257181262 monday_morning_tp REPEATING monday_morning_bl 2016-03-15 02:54:55 2016-09-15 02:54:55 MONDAY 0 5
FREQ=WEEKLY;INTERVAL=1;BYDAY=MON;BYHOUR=0;BYMINUTE=0;BYSECOND=0
上面介紹了基線,那么如何來(lái)使用基線和指定時(shí)段的快照做awr數(shù)據(jù)對(duì)比了,其實(shí)Oracle為我們提供出AWR Compare Period Report來(lái)方便實(shí)現(xiàn)指定時(shí)段的awr數(shù)據(jù)對(duì)比。
由于基線又由于可以一直保存在awr快照中,DBA做性能分析時(shí)則可以利用基線和故障時(shí)段的awr做對(duì)比,更進(jìn)一步的分析數(shù)據(jù)庫(kù)的性能趨勢(shì)變化,下面簡(jiǎn)單的來(lái)做一個(gè)AWR數(shù)據(jù)時(shí)段對(duì)比:
SQL> select dbid,min(snap_id),max(snap_id) from dba_hist_snapshot group by dbid;
DBID MIN(SNAP_ID) MAX(SNAP_ID)
---------- ------------ ------------
4257181262 1508 1669
這里創(chuàng)建snap_id 1656到1657的基線
SQL> begin
2 dbms_workload_repository.create_baseline(
3 start_snap_id=>1656,
4 end_snap_id=>1657,
5 baseline_name=>'test_baseline');
6 end;
7 /
PL/SQL procedure successfully completed.
刪除大部分snapshot
SQL> exec dbms_workload_repository.drop_snapshot_range(1508, 1667, 4257181262);
PL/SQL procedure successfully completed.
SQL> select snap_id,begin_interval_time,end_interval_time from dba_hist_snapshot where dbid=4257181262;
SNAP_ID BEGIN_INTERVAL_TIME END_INTERVAL_TIME
---------- --------------------------------------------------------------------------- ---------------------------------------------------------------------------
1669 15-MAR-16 10.23.42.387 PM 15-MAR-16 11.10.41.380 PM
1656 11-MAR-16 10.00.33.158 PM 14-MAR-16 08.40.27.499 PM
1657 14-MAR-16 08.40.27.499 PM 14-MAR-16 10.00.35.439 PM
1668 15-MAR-16 08.41.44.009 PM 15-MAR-16 10.23.42.387 PM
這里也驗(yàn)證了之前awr baseline的部分對(duì)應(yīng)的snapshot并不會(huì)被awr保留策略或者手動(dòng)刪除awr而刪除掉。
接下來(lái)使用awrddrpt.sql腳本來(lái)生成兩個(gè)awr的對(duì)比數(shù)據(jù):
SQL> @awrddrpt.sql
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Id DB Name Inst Num Inst Num Instance
----------- ----------- ------------ -------- -------- ------------
4257181262 4257181262 ORA11G 1 1 ora11g
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'
Enter value for report_type: html
Type Specified: html
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
2350429211 1 TLINK tlink ylqz_s
* 4257181262 1 ORA11G ora11g redhat-ora
Database Id and Instance Number for the First Pair of Snapshots
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using 4257181262 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
without
specifying a number lists all completed snapshots.
Enter value for num_days: 3
Listing the last 3 days of Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
ora11g ORA11G 1656 14 Mar 2016 20:40 1
1657 14 Mar 2016 22:00 1
1668 15 Mar 2016 22:23 1
1669 15 Mar 2016 23:10 1
Specify the First Pair of Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 1656
First Begin Snapshot Id specified: 1656
Enter value for end_snap: 1657
First End Snapshot Id specified: 1657
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
2350429211 1 TLINK tlink ylqz_s
* 4257181262 1 ORA11G ora11g redhat-ora
Database Id and Instance Number for the Second Pair of Snapshots
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using 4257181262 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
without
specifying a number lists all completed snapshots.
Enter value for num_days2: 3
Listing the last 3 days of Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
ora11g ORA11G 1656 14 Mar 2016 20:40 1
1657 14 Mar 2016 22:00 1
1668 15 Mar 2016 22:23 1
1669 15 Mar 2016 23:10 1
Specify the Second Pair of Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap2: 1668
Second Begin Snapshot Id specified: 1668
Enter value for end_snap2: 1669
Second End Snapshot Id specified: 1669
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrdiff_1_1656_1_1668.html To use this name,
press
to continue, otherwise enter an alternative.
Enter value for report_name: /home/oracle/awr0316.hmtl
關(guān)于“oracle 11g如何創(chuàng)建基線”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。