Using Workload Capture and Replay (文件 ID 445116.1)
In this Document
Applies to:Oracle Database - Enterprise Edition - Version 10.1.0.2 and laterInformation in this document applies to any platform. GoalTo give a basic introduction to workload capture and replay SolutionWhat is the workload capture/replay utility?
Before you begin
1) The Real Application Testing Option must be installed RestrictionsThe following workloads are captured but not supported. It is suggested that capture filters be used to minimise the possiblity of the replay failing:
The following additional restrictions also apply: Capturing a workloadThe capture scripts should be run as sys. Create a directory to hold the workload informationIf one does not already exist then create a directory to hold the workload information (The directory must be empty):-
create directory my_workload_dir as '/home/%usernm%/my_workload_directory';
Start the database in restricted mode
You should now start the database in restricted mode for the capture to work correctly. This ensures that users are not in the middle of connecting or transactions when the capture begins. Once the capture is started then the database will be automatically placed in unrestricted mode.
ERROR at line 1:
ORA-15504: cannot start workload capture because instance 1 not present in RESTRICTED SESSION mode ORA-06512: at "SYS.DBMS_WORKLOAD_CAPTURE", line 723 ORA-06512: at line 1
shutdown
startup restrict ...or..
ALTER SYSTEM ENABLE RESTRICTED SESSION
Start the CaptureYou can now start the capture using a name to identify the capture.
execute dbms_workload_capture.start_capture('test_capture_1','MY_WORKLOAD_DIR');
A few points to note:- At this point the work now being done will be captured by the RDBMSTo stop the capture use:-
execute dbms_workload_capture.finish_capture();
Using filters with workload captureA filter is a set of attributes and values that define a set of actions which can be included or excluded from a capture session. The filter is defined using :
execute dbms_workload_capture.ADD_FILTER( fname IN VARCHAR2,
fattribute IN VARCHAR2, fvalue IN VARCHAR2);
execute dbms_workload_capture.ADD_FILTER('my_filter','USER','SCOTT');
To then run the capture session you would call:-
execute dbms_workload_capture.start_capture('test_capture_1','MY_WORKLOAD_DIR',default_action='EXCLUDE');
If I wanted to use the filter to EXCLUDE work carried out by user SCOTT:-
execute dbms_workload_capture.start_capture('test_capture_1','MY_WORKLOAD_DIR',default_action='INCLUDE');
Filters NOT USED in a capture yet can be maintained by using DELETE filter , eg dbms_workload_capture.DELETE_FILTER('my_filter') Displaying information on a captureTo show the latest capture id:-
select id,name,status,start_time,end_time,connects,user_calls,dir_path from dba_workload_captures where id = (select max(id) from dba_workload_captures) ;
If you wish to see a report of the capture (let's assume the above was id 1) then do:-
set pagesize 0 long 30000000 longchunksize 1000
select dbms_workload_capture.report(1,'TEXT') from dual; The output will be something like:-
Database Capture Report For V11B5
DB Name DB Id Release RAC Capture Name Status ------------ ----------- ----------- --- -------------------------- ---------- V11B5 2825011450 11.1.0.5.0 NO test_capture_1 COMPLETED Start time: 23-Jul-07 13:18:19 (SCN = 1483775) End time: 23-Jul-07 13:21:29 (SCN = 1484135) Duration : 3 minutes 10 seconds Capture size : 3.81 KB Directory object : MY_WORKLOAD_DIR Directory path : /home/%usernm%/my_workload_directory Directory shared in RAC : FALSE Filters used : 0 Captured Workload Statistics DB: V11B5 Snaps: 475-476 -> 'Value' represents the corresponding statistic aggregated across the entire captured database workload. -> '% Total' is the percentage of 'Value' over the corresponding system-wide aggregated total. Statistic Name Value % Total ---------------------------------------- ------------- --------- DB time (secs) 11.91 25.61 Average Active Sessions 0.06 User calls captured 17 22.67 User calls captured with Errors 6 Session logins 2 10.00 Transactions 29 100.00 ------------------------------------------------------------- Workload Filters DB: V11B5 Snaps: 475-476 No data exists for this section of the report. ------------------------------------------------------------- End of Report You can also see the files in the directory (ie /home/%usernm%/my_workload_directory) :
ls -la /home/%usernm%/my_workload_directory
total 88 drwxr-xr-x 2 oracle oinstall 4096 Jul 25 14:12 . drwxr-xr-x 9 oracle oinstall 4096 Jul 24 09:42 .. -rw-r--r-- 1 oracle oinstall 1192 Jul 25 14:10 wcr_4d9txtc002qfz.rec -rw-r--r-- 1 oracle oinstall 15305 Jul 25 14:11 wcr_4d9txu8002qpm.rec -rw-r--r-- 1 oracle oinstall 1394 Jul 25 14:12 wcr_4d9ty0w002qqu.rec -rw-r--r-- 1 oracle oinstall 251 Jul 25 14:12 wcr_capture.wmd -rw-r--r-- 1 oracle oinstall 11342 Jul 25 14:12 wcr_cr.html -rw-r--r-- 1 oracle oinstall 3646 Jul 25 14:12 wcr_cr.text -rw-r--r-- 1 oracle oinstall 0 Jul 25 14:09 wcr_rec_0000q.start Running an AWR report for the period of the captureAs part of the capture, the RDBMS will also initiate an AWR report for the duration of the capture period. This can be seen by running the following for a given capture id :-
select id,AWR_BEGIN_SNAP,AWR_END_SNAP from dba_workload_captures;
ID AWR_BEGIN_SNAP AWR_END_SNAP ---------- -------------- ------------ 1 475 476 So, we can now run @?/rdbms/admin/awrrpt for the given begin and end snapids to get the report (See Document 276103.1)
Database ReplayPreparing for the replayAn instance identical to the instance used for the capture should exist - by identical, it should be logically the same. If the replay is purely read only (selects etc) then the structure of the database should be that same and if the replay includes update/delete then the copy must be able to support this logically. The files created by the capture should also be transferred to the new server , preferably in their own directory , and be readable by the oracle software owner. You should also consider setting the system time on the replay machine to be the same as that prior to the capture being run on the original instance to ensure that time sensitive operations (ie SQL relying on SYSDATE) replay accurately First of all you need to ensure that there are sufficient replay clients running in order to replay the workload. To determine how many clients you need, once you have got as far as processing the capture directory(DBMS_WORKLOAD_REPLAY.PROCESS_CAPTURE) you can run:-
wrc replaydir=XXXXXXXXXX mode=calibrate
Which will then tell you how many clients it recommends you start:- Workload Replay Client: Release 11.1.0.5.0 - Beta on Thu Jul 26 11:57:16 2007 Copyright (c) 1982, 2007, Oracle. All rights reserved. Report for Workload in: /home/%usernm%/my_workload_directory ----------------------- 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 From the OS command line you can start the client(s) using:-
wrc replaydir=XXXXXXXXXX (where XXXXXXXXX the replay directory , ie /home/%usernm%/my_workload_directory)
You would then see something like:- Workload Replay Client: Release 11.1.0.5.0 - Beta on Wed Jul 25 15:57:31 2007 Copyright (c) 1982, 2007, Oracle. All rights reserved. Wait for the replay to start (15:57:31) The process appears as a session in the instance , ie:-
oracle 25962 1 1 16:08 ? 00:00:00 oracleJCREPLAY (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
And from a session perspective , will appear in v$session and sit on event 'WRR: replay client notify' while it waits for work. Ensure the directory exists:-
create directory my_workload_dir as '/home/%usernm%/my_workload_directory';
First of all , we need to process the CAPTURE in the directory :-
execute DBMS_WORKLOAD_REPLAY.PROCESS_CAPTURE('MY_WORKLOAD_DIR');
This will create additional files which contain metadata required for the replay in the directory:- drwxr-xr-x 2 oracle oinstall 4096 Jul 25 14:18 . drwxr-xr-x 9 oracle oinstall 4096 Jul 24 09:42 .. -rw-r--r-- 1 oracle oinstall 1192 Jul 25 14:10 wcr_4d9txtc002qfz.rec -rw-r--r-- 1 oracle oinstall 15305 Jul 25 14:11 wcr_4d9txu8002qpm.rec -rw-r--r-- 1 oracle oinstall 1394 Jul 25 14:12 wcr_4d9ty0w002qqu.rec -rw-r--r-- 1 oracle oinstall 251 Jul 25 14:12 wcr_capture.wmd -rw-r----- 1 oracle oinstall 12288 Jul 25 14:18 wcr_conn_data.extb * New File -rw-r--r-- 1 oracle oinstall 11342 Jul 25 14:12 wcr_cr.html -rw-r--r-- 1 oracle oinstall 3646 Jul 25 14:12 wcr_cr.text -rw-r--r-- 1 oracle oinstall 141 Jul 25 14:18 wcr_login.pp * New File -rw-r--r-- 1 oracle oinstall 35 Jul 25 14:18 wcr_process.wmd * New File -rw-r--r-- 1 oracle oinstall 0 Jul 25 14:09 wcr_rec_0000q.start -rw-r----- 1 oracle oinstall 12288 Jul 25 14:18 wcr_scn_order.extb * New File -rw-r----- 1 oracle oinstall 12288 Jul 25 14:18 wcr_seq_data.extb * New File We now need to put the database in a state of readiness for replaying the workload:-
execute DBMS_WORKLOAD_REPLAY.INITIALIZE_REPLAY('test_replay_1', 'MY_WORKLOAD_DIR');
This loads the connection maps so that we can remap them to the new instance if required (See Connection Maps). We can then put the database in a replay state:- execute DBMS_WORKLOAD_REPLAY.PREPARE_REPLAY(synchronization IN BOOLEAN DEFAULT TRUE, connect_time_scale IN NUMBER DEFAULT 100, think_time_scale IN NUMBER DEFAULT 100, think_time_auto_correct IN BOOLEAN DEFAULT TRUE); Where :-
Using all the above , typically we would just run:-
execute DBMS_WORKLOAD_REPLAY.PREPARE_REPLAY(
..which would just prepare to replay the SQL in exactly the same way it was recorded Executing the replayOnce all the above is completed then the replay can begin:
execute DBMS_WORKLOAD_REPLAY.START_REPLAY
What can be observed during this time is the work will be picked up by the wrc clients. You will see this in the client session:-
Replay started (16:19:27)Replay finished (16:20:38)
Once this has completed you can view dba_workload_replays:-
select name,status from dba_workload_replays;
NAME STATUS ------------------------------------------ test_replay_1 COMPLETED You can also view a report of the replay:-
set pagesize 0 long 30000000 longchunksize 1000
select dbms_workload_replay.report(1,'TEXT') from dual; DB Replay Report for test_replay_1 --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------- | DB Name | DB Id | Release | RAC | Replay Name | Replay Status | --------------------------------------------------------------------------- | JCREPLAY | 147275354 | 11.1.0.5.0 | NO | test_replay_1 | COMPLETED | --------------------------------------------------------------------------- Replay Information -------------------------------------------------------------------------------------------------- | Information | Replay | Capture | -------------------------------------------------------------------------------------------------- | Name | test_replay_1 | test_capture_2 | -------------------------------------------------------------------------------------------------- | Status | COMPLETED | COMPLETED | -------------------------------------------------------------------------------------------------- | Database Name | JCREPLAY | V11B5 | -------------------------------------------------------------------------------------------------- | Database Version | 11.1.0.5.0 | 11.1.0.5.0 | -------------------------------------------------------------------------------------------------- | Start Time | 25-JUL-07 16:19:27 | 25-JUL-07 14:09:49 | -------------------------------------------------------------------------------------------------- | End Time | 25-JUL-07 16:20:31 | 25-JUL-07 14:12:11 | -------------------------------------------------------------------------------------------------- | Duration | 1 minute 4 seconds | 2 minutes 22 seconds | -------------------------------------------------------------------------------------------------- | Directory Object | MY_WORKLOAD_DIR | MY_WORKLOAD_DIR | -------------------------------------------------------------------------------------------------- | Directory Path | /home/%usernm%/my_workload_directory | /home/%usernm%/my_workload_directory | -------------------------------------------------------------------------------------------------- Replay Options --------------------------------------------------------- | Option Name | Value | --------------------------------------------------------- | Synchronization | TRUE | --------------------------------------------------------- | Connect Time | 100% | --------------------------------------------------------- | Think Time | 100% | --------------------------------------------------------- | Think Time Auto Correct | TRUE | --------------------------------------------------------- | Number of WRC Clients | 1 (1 Completed, 0 Running ) | --------------------------------------------------------- Replay Statistics ------------------------------------------------ | Statistic | Replay | Capture | ------------------------------------------------ | DB Time | 932061 | 1006294 | ------------------------------------------------ | Average Active Sessions | .01 | .01 | ------------------------------------------------ | User calls | 46 | 50 | ------------------------------------------------ | Network Time | 2724 | . | ------------------------------------------------ | Think Time | 17159449 | . | ------------------------------------------------ | Elapsed Time Difference | 148907 | . | ------------------------------------------------ | New Errors | 0 | . | ------------------------------------------------ | Mutated Errors | 0 | . | ------------------------------------------------ --------------------------------------------------------------------------------------------------- Workload Profile Top Events (+) Show (-) Hide -------------------------------------------------- | No data exists for this section of the report. | -------------------------------------------------- Top Service/Module/Action (+) Show (-) Hide -------------------------------------------------- | No data exists for this section of the report. | -------------------------------------------------- Top SQL with Top Events (+) Show (-) Hide -------------------------------------------------- | No data exists for this section of the report. | -------------------------------------------------- Top Sessions with Top Events (+) Show (-) Hide -------------------------------------------------- | No data exists for this section of the report. | -------------------------------------------------- Replay Divergence Session Failures By Application (+) Show (-) Hide -------------------------------------------------- | No data exists for this section of the report. | -------------------------------------------------- Error Divergence By Application (+) Show (-) Hide -------------------------------------------------- | No data exists for this section of the report. | -------------------------------------------------- By SQL (+) Show (-) Hide -------------------------------------------------- | No data exists for this section of the report. | -------------------------------------------------- By Session (+) Show (-) Hide -------------------------------------------------- | No data exists for this section of the report. | -------------------------------------------------- DML Data Divergence By Application (+) Show (-) Hide -------------------------------------------------- | No data exists for this section of the report. | -------------------------------------------------- By SQL (+) Show (-) Hide -------------------------------------------------- | No data exists for this section of the report. | -------------------------------------------------- SELECT Data Divergence By Application (+) Show (-) Hide -------------------------------------------------- | No data exists for this section of the report. | -------------------------------------------------- End of Report. You should use the report to ascertain that the replay ran without error first of all - any errors may well constitute an invalid replay so these should be address where possible and the replay resubmitted. Connection MapsObviously, when connections are being made during capture, those are only pertinent to the instance where the capture occured. Any connection strings etc need to be remapped during the replay to ensure they point to the correct instance. Current connections can be viewed by selecting against DBA_WORKLOAD_CONNECTION_MAP To change a connection you can use:-
execute dbms_workload_replay.REMAP_CONNECTION(connection_id,replay_connection);
Where connection_id is the connection_id of the connection you wish to change and replay_connection is the new connection string. ReferencesBUG:13524303 - DATABASE REPLAY CLIENT FAILS WITH OCI-24550NOTE:276103.1 - Performance Tuning Using Advisors and Manageability Features: AWR, ASH, ADDM and Sql Tuning Advisor |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17252115/viewspace-1332144/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle OCP IZ0-053 Q692(Workload Capture and Replay)OracleAPT
- Database Capture and Replay: Common Errors and Reasons (文件 ID 463263.1)DatabaseAPTError
- Oracle OCP 1Z0 053 Q479(Workload Capture&Replay)OracleAPT
- Oracle OCP 1Z0 053 Q409(Workload Capture&Replay)OracleAPT
- Oracle OCP 1Z0 053 Q410(Workload Capture&Replay)OracleAPT
- Oracle OCP 1Z0-053 Q137(Workload Capture&Replay)OracleAPT
- Oracle OCP IZ0-053 Q257(workload capture)OracleAPT
- Using Parallel Execution (文件 ID 203238.1)Parallel
- Oracle OCP IZ0-053 Q411(Workload Capture of RAC)OracleAPT
- Oracle OCP 1Z0-053 Q516(Workload Capture)OracleAPT
- Running Workload Repository Reports Using SQL ScriptsSQL
- Oracle OCP 1Z0-053 Q412(Workload Replay report difference)Oracle
- HOW TO SHRINK A TABLE USING ONLINE REDEFINITION (文件 ID 1357878.1)
- How to Move a Database Using Transportable Tablespaces (文件 ID 1493809.1)Database
- 11g Using Snapshot Standby Database. (文件 ID 443720.1)Database
- Local Capture and Downstream CaptureAPT
- 11gR2 RAC DB switchover using DG broker (文件 ID 880017.1)
- Using Distributed AD in Applications Release 11.5. (文件 ID 236469.1) - 2APP
- TcpreplayTCP
- Oracle Database ReplayOracleDatabase
- Oracle11g新特性之Replay a captured workload 捕獲工作負載新環境重放負載測試壓力OracleAPT負載
- goreplay 使用教程Go
- oracle rat database replayOracleDatabase
- Video Division with using OpenCvIDEOpenCV
- Android memory leak using MATAndroid
- Oracle replayc測試Oracle
- Android 程式設計下 Using ViewPager for Screen SlidesAndroid程式設計ViewpagerIDE
- database replay基礎學習Database
- Systemwide Tuning using STATSPACK ReportsIDE
- 使用apidoc文件神器,快速生成api文件API
- AWR: Automatic Workload Repository
- Automatic Workload Repository ViewsView
- DBMS_WORKLOAD_REPOSITORY包
- AWR(Automatic Workload Repository)
- Step By Step Guide To Create Physical Standby Database Using RMAN [ID 469493.1]GUIIDEDatabase
- V$SQL_BIND_CAPTURESQLAPT
- top sql capture script.SQLAPT
- 解決最近fiddler出現“The system proxy was changed,click to reenable fiddler capture”的問題APT