Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Database Capture n Replay Using 11.1.0.7 & 11.2.0.

2
Krishan Kumar
August 26, 2011
Yahoo! Confidential 1

Introduction
Basics of Database capture and replay Details about each APIs Comparison Reports

Yahoo! Confidential

What is Database Replay


By capturing a workload on the production system and replaying it on a test system, Database replay enables realistic testing of system changes by essentially recreating the production workload environment on a test system. You can use database replay process to test any significant system changes like OS, DB upgrade, Init parameter change, storage change, network, interconnect change, OS & HW migration, converting single instance to RAC. Captured workload can only be played on 11.1.0.6 onwards
Yahoo! Confidential 3

Contd
11gR1 onwards database capture can be started without making any changes. In version 10.2.0.4 you need to enable pre_11g_enable_capture; prior to 10.2.0.4 release 9373986 patch needs to be applied, more information can be found in ML note 560977.1

Yahoo! Confidential

How over all process works


Following steps are needed to test database replay
Workload Capture: On source database Workload Preprocessing: On target database Analysis & Reporting: On target database

Source database version: 11.1.0.7 Target database version: 11.2.0.2

Yahoo! Confidential

Workload Capture
Required permission
Grant Create Directory to the user who is going to start database capture process. Grant Execute permission on DBMS_WORKLOAD_CAPTURE, DBMS_WORKLOAD_REPLAY, DBMS_WORKLOAD_REPOSITORY to user who is going to start capture & replay process plus going to generate reports.

Yahoo! Confidential

Contd
Create directory and grant read write permission to it create directory irdb_test as '/n01/orabkup/irdb'; grant read,write on directory irdb_test to krishan; Start workload capture on source database from user which you are going to use for all activity. In my case it is krishan exec DBMS_WORKLOAD_CAPTURE.START_CAPTURE
(name=>'irdb_test',dir=>'IRDB_TEST);

Note: Other parameters can be passed: duration, default_action & auto_unrestrict


Yahoo! Confidential 7

Contd
Finish workload capture process exec DBMS_WORKLOAD_CAPTURE.FINISH_CAPTURE();

Note: You can pass timeout parameter too


Now Export AWR statistics for reporting purpose select dbms_workload_capture.get_capture_info('IRDB_TEST ') from dual; exec DBMS_WORKLOAD_CAPTURE.EXPORT_AWR (capture_id => value from above select);

Yahoo! Confidential

Contd
Check status column under dba_workload_captures for progress of Capture process. Copy all files from replay dir to test host under the same dir as dir object irdb_test or create new one. Generate Capture Report: use following API to generate capture report set pagesize 0 long 30000000 longchunksize 2000 select dbms_workload_capture.report (capture_id => &capture_id,'TEXT') from dual; Capture_id can be found in dba_workload_captures
Yahoo! Confidential 9

Replay process
Setup test system and copy all the files under capture dir on Capture system to Replay dir on Replay/test system Connect to the user which you used for database capture Resolving References to External Systems Specially Database links, External tables, directory objects, urls, emails Pre Process captured file exec DBMS_WORKLOAD_REPLAY.PROCESS_CAPTURE
(capture_dir => 'IRDB_TEST');
Yahoo! Confidential 10

Contd
Initialize workflow exec DBMS_WORKLOAD_REPLAY.INITIALIZE_REPLAY
(replay_name => 'irdb_test', replay_dir => 'IRDB_TEST');

Prepare replay
exec DBMS_WORKLOAD_REPLAY.PREPARE_REPLAY (capture_sts=>TRUE);

Yahoo! Confidential

11

Contd
Run WRC client in new window wrc krishan mode=replay replaydir=/n01/orabkup/irdb connection_override=true connection_override: Use this when you do not want to use connect strings stored in DBA_WORKLOAD_CONNECTION_MAP Run calibrate command to see how many WRC clients you need to start to replay the load wrc krishan mode=calibrate replaydir=/n01/orabkup/irdb

Yahoo! Confidential

12

Contd
Start replay process exec DBMS_WORKLOAD_REPLAY.START_REPLAY; Replay progress can be found in dba_workload_replays If you want to cancel reply than exec DBMS_WORKLOAD_REPLAY.CANCEL_REPLAY (); otherwise reply will finish automatically and wrc client screen will show message like "Replay finished (07:22:49)"

Yahoo! Confidential

13

Replay Report
Use following API to get replay report set pagesize 0 long 30000000 longchunksize 2000 select dbms_workload_replay.report(replay_id => &replay_id,format => 'TEXT') from dual; Replay_id can be found in dba_workload_replays

Yahoo! Confidential

14

AWR report
Import AWR data into Replay database to get AWR report for Capture vs Replay select dbms_workload_capture.import_awr(capture_id => &capture_id, staging_schema => 'KRISHAN') from dual; Now get snap ids for capture vs replay select id, awr_begin_snap bid1, awr_end_snap eid1 from dba_workload_captures; select id, awr_begin_snap bid2, awr_end_snap eid2 from dba_workload_replays;

Yahoo! Confidential

15

Contd
Use dbms_workload_repository.awr_diff_report_text or dbms_workload_repository.awr_diff_report_html to generate a comparison report. select *from table(DBMS_WORKLOAD_REPOSITORY.AWR_DIFF _REPORT_TEXT(dbid1=>196594835,inst_num1=>1,bi d1=>23350,eid1=>23494,dbid2=>2554412232,inst_nu m2=>1,bid2=>23353,eid2=>24215)); You can get value of dbid1 and dbid2 from capture and replay reports respectively.
Yahoo! Confidential 16

Capture vs Replay Report


Use following function to generate Capture vs Replay Report set serveroutput on long 4000000 var report_bind clob; BEGIN DBMS_WORKLOAD_REPLAY.COMPARE_PERIOD_REPORT (replay_id1 => 3,replay_id2=>null,format => DBMS_WORKLOAD_CAPTURE.TYPE_HTML,result => :report_bind); END; /

Where: if replay_id2 is passed null than it will generate report by comparing capture data otherwise it will compare two replay reports
Yahoo! Confidential 17

Contd
Capture vs Replay report Please check file CaptureVsReplay_report.html

Yahoo! Confidential

18

References
http://download.oracle.com/docs/cd/B28359_01/server. 111/e12253/dbr_intro.htm#BABBDGIB http://download.oracle.com/docs/cd/E11882_01/server. 112/e16540/dbr_preprocess.htm#CHDHCAHI http://download.oracle.com/docs/cd/E11882_01/appdev .112/e16760/d_workload_repos.htm http://download.oracle.com/docs/cd/E11882_01/appdev .112/e16760/d_workload_replay.htm

Yahoo! Confidential

19

You might also like