Wednesday, 13 June 2012

Using database replay with oracle 11g


This is a post which will help you to use one of the newest features of oracle database 11g  which is Database Replay basically,The Database Replay functionality of Oracle 11g allows you to capture workloads on a production system and replay them exactly as they happened on a test system. This provides an accurate method to test the impact of a variety of system changes including:


  • Database upgrades.
  • Operating system upgrades or migrations.
  • Configuration changes, such as changes to initialization parameters or conversion from a single node to a RAC environment.
  • Hardware changes or migrations.

Follow these simple steps of how you can use Database Replay in your 11g database,Screenshots are also provided for a better result

Step 1)_create an empty directory in any location for storing captured stats,this directory will be used for the storing of the files generated during the Database Replay



Step 2)_create a directory using the CREATE OR REPLACE DIRECTORY command pointing towards the already created empty directory


Step 3)_start the capture using start_capture procedure.NOTE-null means you have to manually stop the capture process

BEGIN
  DBMS_WORKLOAD_CAPTURE.start_capture (name     => 'test_capture_1', 
                                       dir      => 'DB_REPLAY_CAPTURE_DIR',
                                       duration => NULL);
END;
/




Step 4)_create a user for which the capture process will run
NOTE:-the capture process is already running and all the task which is being performed in the database is being captured



Step 5)_connect with the newly created user



Step 6)_let us do some work on the database so that the work can be captured,you can make a table and populate it with data


Step 7)_connect with sys user and stop the capture process using finish capture procedure,this will stop the capturing of data


Step 8)_check the capture folder for capture files generation,you can see that there were some files being generated in that folder


Step 9)_check for the capture directory number to generate AWR report associated with this number of capture

SELECT DBMS_WORKLOAD_CAPTURE.get_capture_info('DB_REPLAY_CAPTURE_DIR')
FROM   dual;




Step 10)_generate the AWR report associated with the capture


Step 11)_Physically copy the captured data to the test server and create a directory into the test db using the step 2 above for creating a directory


Step 12)_We can now prepare to replay(not start the replay) the existing capture logs using the PROCESS_CAPTURE, INITIALIZE_REPLAY and PREPARE_REPLAY procedures

BEGIN
  DBMS_WORKLOAD_REPLAY.process_capture('DB_REPLAY_CAPTURE_DIR');

  DBMS_WORKLOAD_REPLAY.initialize_replay (replay_name => 'test_capture_1',
                                          replay_dir  => 'DB_REPLAY_CAPTURE_DIR');

  DBMS_WORKLOAD_REPLAY.prepare_replay (synchronization => TRUE);
END;
/




Step 13)_Before we can start the replay, we need to calibrate and start a replay client using the WRC utility.


Step 14)_The calibration step suggest a single client on a single CPU is enough, so we only need to start a single replay client, which is shown below.


Step 15)_start the replay from sys user account

BEGIN
  DBMS_WORKLOAD_REPLAY.start_replay;
END;
/




NOTE:-the replay will take sometime to complete so just wait patiently

Step 16)_after the completion of the replay you can check for the table that you have created on the production server and the data which was captured


Congratulations!!!!!!

You have successfully used database replay with oracle 11g

No comments:

Post a Comment