db replay設定scale_up_multiplier不生效
設定scale_up_multiplier:
BEGIN
DBMS_WORKLOAD_REPLAY.PREPARE_REPLAY (scale_up_multiplier => 10);
END;
但是設定之後,在DBA_WORKLOAD_REPLAYS.SCALE_UP_MULTIPLIER檢查發現,這個值始終是1。
這是因為scale_up_multiplier不支援基於object id的同步。當synchronization的值為object_id,scale_up_multiplier在代碼裡面被hard code為1的(BUG 9774435)。
而synchronization這個參數,預設true時,11g早期版本(好像是11.2.0.3之前),預設值true的情況下是指SCN,在11g的後期版本,預設值true的情況就變成指object_id了。
所以,早期文檔上說的
SQL>exec dbms_workload_replay.prepare_replay(synchronization => TRUE,....
此時的true是SCN,所以,按照早期文檔說明,在早期版本的資料上,執行完prepare之後,再放大scale_up_multiplier是可以的,是可以能放大到指定倍數的。
但是在我的11.2.0.4.5中,如果還是按照早期文檔的說明,設定synchronization => TRUE,就會導致無論怎麼設定scale_up_multiplier都不會生效的問題。
解決方案:顯式設定synchronization => ‘SCN’
BEGIN
DBMS_WORKLOAD_REPLAY.PREPARE_REPLAY (synchronization => 'SCN',scale_up_multiplier => 10);
END;
補充關於db repaly用法
Database Replay主要利用2個package: DBMS_WORKLOAD_CAPTURE 和 DBMS_WORKLOAD_REPLAY,分4個步驟:
1. 捕捉產品資料庫的負載。
2. 預先處理捕獲的負載資訊。
3. 重播資料庫負載。
4. 建立報告並分析結果。[@more@]**********
* 來源資料庫
**********
--建立存放負載資訊的目錄。
SQL> create directory relay_source as 'd:tempsource';
目錄已建立。
--建立資訊過濾器,此處只抓取SCOTT使用者的所有操作。
SQL> exec dbms_workload_capture.add_filter( fname => 'user_scott', fattribute => 'USER', fvalue => 'scott');
PL/SQL 過程已成功完成。
--開始抓取,時間為900秒。
SQL> exec dbms_workload_capture.start_capture(name=>'SCOTT_900',dir=>'RELAY_SOURCE',duration=>900);
PL/SQL 過程已成功完成。
--另一視窗SCOTT使用者的操作
SQL> conn scott/tiger
已串連。
SQL> create table temp1 as select * from dba_objects;
表已建立。
SQL> insert into temp1 select * from temp1;
已建立68366行。
SQL> insert into temp1 select * from temp1;
已建立136732行。
SQL> commit;
提交完成。
SQL> insert into temp1 select * from temp1;
已建立273464行。
SQL> insert into temp1 select * from temp1;
已建立546928行。
SQL> commit;
提交完成。
SQL> insert into temp1 select * from temp1;
已建立1093856行。
SQL> commit;
提交完成。
SQL> create index idx1 on temp1(object_id);
索引已建立。
......
SQL> insert into temp1 select * from temp1;
已建立2187712行。
SQL> commit;
提交完成。
SQL> conn / as sysdba
已串連。
--不到900秒的時候停止抓取資訊。
SQL> exec dbms_workload_capture.finish_capture();
PL/SQL 過程已成功完成。
--目錄下產生的檔案。
D:tempsource:-
2009-02-11 11:44 6,222 wcr_4m4k7ws0020r0.rec
2009-02-11 11:37 1,152 wcr_4m4k7ws00213w.rec
2009-02-11 11:40 0 wcr_4m4k8pc0023v8.rec
2009-02-11 11:45 1,372 wcr_4m4k9r80021m8.rec
2009-02-11 11:46 49,620 wcr_cr.html
2009-02-11 11:46 23,370 wcr_cr.text
2009-02-11 11:45 181 wcr_fcapture.wmd
2009-02-11 11:36 120 wcr_scapture.wmd
************
* 目標資料庫
************
--建立目錄,並將上述檔案從原目錄複寫過來。
SQL> create directory relay_target as 'd:temptarget';
目錄已建立。
--預先處理這些檔案。
SQL> exec dbms_workload_replay.process_capture(capture_dir => 'RELAY_TARGET');
PL/SQL 過程已成功完成。
--預先處理後新產生5個檔案
D:temptarget:-
2009-02-11 13:50 12,288 WCR_CONN_DATA.EXTB
2009-02-11 13:50 142 wcr_login.pp
2009-02-11 13:50 35 wcr_process.wmd
2009-02-11 13:50 12,288 WCR_SCN_ORDER.EXTB
2009-02-11 13:50 12,288 WCR_SEQ_DATA.EXTB
--可以用 wrc的calibrate模式校正一下
D:temptarget>wrc mode=calibrate replaydir=.
Workload Replay Client: Release 11.1.0.6.0 - Production on 星期三 2月 11 135
0 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Report for Workload in: .
-----------------------
Recommendation:
Consider using at least 1 clients divided among 1 CPU(s).
Workload Characteristics:
- max concurrency: 1 sessions
- total number of sessions: 2
Assumptions:
- 1 client process per 50 concurrent sessions
- 4 client process per CPU
- think time scale = 100
- connect time scale = 100
- synchronization = TRUE
--執行下面2個過程,為重播準備。
SQL> exec dbms_workload_replay.initialize_replay(replay_name => 'SCOTT_600', replay_dir=> 'RELAY_TARGET');
PL/SQL 過程已成功完成。
SQL> exec dbms_workload_replay.prepare_replay(synchronization => true);
PL/SQL 過程已成功完成。
--以重播模式啟動wrc,螢幕會處在wait狀態。
D:temptarget>wrc system/oracle mode=replay replaydir=.
Workload Replay Client: Release 11.1.0.6.0 - Production on 星期三 2月 11 14:03:4
4 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Wait for the replay to start (14:03:44)
--另一視窗中運行start_replay過程。
SQL> conn / as sysdba
已串連。
SQL> exec DBMS_WORKLOAD_REPLAY.START_REPLAY ();
PL/SQL 過程已成功完成。
--wrc視窗會顯示重播開始。
Wait for the replay to start (14:03:44)
Replay started (14:04:06)
--重播過程中我們可以看到不同時間點temp1表中的不同資料量。
--註:由於環境所限,這裡的來源資料庫和目標資料庫其實為同一資料庫,在重播前刪除scott使用者的temp1表。
SQL> select count(*) from temp1;
COUNT(*)
----------
1093840
SQL> select count(*) from temp1;
COUNT(*)
----------
2187680
--重播結束後wrc視窗會顯示
Wait for the replay to start (14:03:44)
Replay started (14:04:06)
Replay finished (1443)
--重播後會有報告產生,或者可以使用下面指令碼產生報告。
DECLARE
cap_id NUMBER;
rep_id NUMBER;
rep_rpt CLOB;
BEGIN
cap_id := DBMS_WORKLOAD_REPLAY.GET_REPLAY_INFO(dir => 'RELAY_TARGET');
/* Get the latest replay for that capture */
SELECT max(id)
INTO rep_id
FROM dba_workload_replays
WHERE capture_id = cap_id;
rep_rpt := DBMS_WORKLOAD_REPLAY.REPORT(replay_id => rep_id,
format => DBMS_WORKLOAD_REPLAY.TYPE_TEXT);
END;
/
--下面這些操作不能被抓獲/重播
■ SQL*Loader direct path load of data
■ Oracle Streams
■ Data Pump Import and Export
■ Advanced replication streams
■ Non–PL/SQL-based Advanced Queuing (AQ)
■ Flashback Database and Flashback queries
■ Distributed transactions and remote describe/commit operations
■ Shared server
■ Non–SQL-based object access