Juliandyke.com 1 © 2012 - Julian Dyke Julian Dyke Independent Consultant Is RAT Worth Catching?

Slides:



Advertisements
Similar presentations
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Backup and Recovery Copyright System Managers LLC 2008 all rights reserved.
Advertisements

Module 12: Auditing SQL Server Environments
Module 17 Tracing Access to SQL Server 2008 R2. Module Overview Capturing Activity using SQL Server Profiler Improving Performance with the Database Engine.
Oracle Database 11g Real Application Testing. 2 What is Real Application Testing? New database option available with EE only Includes two new features.
Acknowledgments Byron Bush, Scott S. Hilpert and Lee, JeongKyu
Overview of Database Administrator (DBA) Tools
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 2 Overview of Database Administrator (DBA) Tools.
Oracle Architecture. Instances and Databases (1/2)
The New Data Pump Caleb Small Next generation Import / Export New features Better performance Improved security Versatile interfaces.
Backup and recovery Basics of Backup and restoration Types of recovery Defining strategy Starting up and shutting down 80/20 rule SLA’s.
1 - Oracle Server Architecture Overview
Harvard University Oracle Database Administration Session 2 System Level.
Backup and Recovery Part 1.
9 Copyright © Oracle Corporation, All rights reserved. Oracle Recovery Manager Overview and Configuration.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Module 14: Scalability and High Availability. Overview Key high availability features available in Oracle and SQL Server Key scalability features available.
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
1 Chapter Overview Transferring and Transforming Data Introducing Microsoft Data Transformation Services (DTS) Transferring and Transforming Data with.
Introduction to Oracle Backup and Recovery
IS 4510 – Database Administration Module – 2 Database Backup 10/24/20141Compiled by: Zafar Iqbal Khan.
1 © 2010 Julian Dyke Real Application Testing Julian Dyke Independent Consultant juliandyke.com Web Version.
1 Data Guard Basics Julian Dyke Independent Consultant Web Version - February 2008 juliandyke.com © 2008 Julian Dyke.
7 Copyright © 2006, Oracle. All rights reserved. Dealing with Database Corruption.
Oracle Database Administration
Introduction and simple using of Oracle Logistics Information System Yaxian Yao
Recovery Manager Overview Target Database Recovery Catalog Database Enterprise Manager Recovery Manager (RMAN) Media Options Server Session.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Oracle10g RAC Service Architecture Overview of Real Application Cluster Ready Services, Nodeapps, and User Defined Services.
Database Technical Session By: Prof. Adarsh Patel.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
11g(R1/R2) Data guard Enhancements Suresh Gandhi
1 © 2005 Julian Dyke Julian Dyke Independent Consultant juliandyke.com Web Version Native PL/SQL Compilation.
Database Systems Slide 1 Database Systems Lecture 5 Overview of Oracle Database Architecture - Concept Manual : Chapters 1,8 Lecturer : Dr Bela Stantic.
1 RAC Internals Julian Dyke Independent Consultant Web Version juliandyke.com © 2007 Julian Dyke.
The protection of the DB against intentional or unintentional threats using computer-based or non- computer-based controls. Database Security – Part 2.
1 Data Guard. 2 Data Guard Reasons for Deployment  Site Failures  Power failure  Air conditioning failure  Flooding  Fire  Storm damage  Hurricane.
Oracle Data Integrator Procedures, Advanced Workflows.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Week 3 Lecture 1 The Redo Log Files and Diagnostic Files.
Continuous DB integration testing with RAT „RATCOIN”
ESRI User Conference 2004 ArcSDE. Some Nuggets Setup Performance Distribution Geodatabase History.
11 Copyright © 2004, Oracle. All rights reserved. Dealing with Database Corruption.
Process Architecture Process Architecture - A portion of a program that can run independently of and concurrently with other portions of the program. Some.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
Chapter 1Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 1 Backup and Recovery Overview MSCD642 Backup and Recovery.
18 Copyright © 2004, Oracle. All rights reserved. Backup and Recovery Concepts.
Distributed Logging Facility Castor External Operation Workshop, CERN, November 14th 2006 Dennis Waldron CERN / IT.
Hyperion Artifact Life Cycle Management Agenda  Overview  Demo  Tips & Tricks  Takeaways  Queries.
2 Copyright © 2006, Oracle. All rights reserved. Configuring Recovery Manager.
3 Copyright © 2007, Oracle. All rights reserved. Using the RMAN Recovery Catalog.
18 Copyright © 2004, Oracle. All rights reserved. Recovery Concepts.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
Log Shipping, Mirroring, Replication and Clustering Which should I use? That depends on a few questions we must ask the user. We will go over these questions.
20 Copyright © 2006, Oracle. All rights reserved. Best Practices and Operational Considerations.
14 Copyright © 2007, Oracle. All rights reserved. Backup and Recovery Concepts.
2 Copyright © 2007, Oracle. All rights reserved. Realistic Testing Using Database Replay.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
SQL Database Management
Running a Forms Developer Application
How To Pass Oracle 1z0-060 Exam In First Attempt?
Recovery Catalog Creation and Maintenance
Web Technologies IT230 Dr Mohamed Habib.
Maximum Availability Architecture Enterprise Technology Centre.
Database Performance Tuning and Query Optimization
Duplicating a Database
Chapter 11 Database Performance Tuning and Query Optimization
Presentation transcript:

juliandyke.com 1 © Julian Dyke Julian Dyke Independent Consultant Is RAT Worth Catching?

juliandyke.com 2 © Julian Dyke Introduction  Real Application Testing (RAT)  Introduced in Oracle 11gR1  Also referred to as Database Replay  This presentation describes RAT in Oracle 11gR2  Separately licenced option.  Processor license *  Real Application Testing$11,500  Some comparative processor license *  Enterprise Edition$47,500  Real Application Clusters$23,000  Partitioning Option$11,500  * Source – Oracle Technology Global Price List – 08Nov12

juliandyke.com 3 © Julian Dyke Database Replay Client Oracle Database Storage Workload Capture Production Test Workload Preprocessing Workload Replay Analysis & Reporting Storage Application Tier Oracle Database Storage Replay Client

juliandyke.com 4 © Julian Dyke Prerequisites  Workload capture is supported on the following versions:  A one-off patch is required to implement workload capture in versions earlier than  Workload replay is supported in and above  Oracle requires one-off patch VersionOne-off Patch

juliandyke.com 5 © Julian Dyke Capture User  The workload can be captured by SYS  Alternatively a new user can be created to manage the workload capture. For example: CREATE USER ratuser IDENTIFIED BY ratuser DEFAULT TABLESPACE SYSAUX TEMPORARY TABLESPACE TEMP ACCOUNT UNLOCK; GRANT MGMT_USER TO ratuser; GRANT EXECUTE_CATALOG_ROLE TO ratuser GRANT SELECT_CATALOG_ROLE TO ratuser; GRANT CREATE ANY DIRECTORY TO ratuser; GRANT DROP ANY DIRECTORY TO ratuser; GRANT SELECT ON DBA_WORKLOAD_CAPTURES TO RATUSER; GRANT UNLIMITED TABLESPACE TO ratuser; GRANT SELECT ANY TABLE TO ratuser;

juliandyke.com 6 © Julian Dyke Capture Directory  Captured workload is stored in binary files in a directory tree below the capture directory  Capture will stop if capture directory is full  For RAC databases either:  Use a shared file system for workload capture  Use local file systems and subsequently merge contents  For example: $ mkdir /home/oracle/capture1 $ chmod –R 777 /home/oracle/capture1 sqlplus ratuser/ratuser SQL> CREATE OR REPLACE DIRECTORY capture1 AS ‘/home/oracle/capture1’;

juliandyke.com 7 © Julian Dyke Capture Parameters  In Oracle and below, workload capture must be enabled using the PRE_11G_ENABLE_CAPTURE parameter  In Oracle and below:  Workload capture can be enabled using :  $ORACLE_HOME/rdbms/admin/wrrenbl.sql  Workload capture can be disabled using:  $ORACLE_HOME/rdbms/admin/wrrdsbl.sql  Workload capture is enabled by default in Oracle and above  The PRE_11G_ENABLE_CAPTURE parameter is not supported  Workload capture can also be enabled using Enterprise Manager ALTER SYSTEM SET pre_11g_enable_capture=true SID=‘*’; ALTER SYSTEM SET pre_11g_enable_capture=false SID=‘*’;

juliandyke.com 8 © Julian Dyke Starting a Workload Capture  To start a workload capture use the START_CAPTURE procedure: DBMS_WORKLOAD_CAPTURE.START_CAPTURE ( name => ‘CAPTURE1’, dir => ‘CAPTURE1’, duration=> 3600 );  Duration is specified in seconds  1 hour = 3600 seconds  24 hours = seconds  While capture is enabled a temporary file is created in the capture directory.  For example:  wcr_cap_0003n.start  The file contains 0 bytes and is deleted when the capture is disabled

juliandyke.com 9 © Julian Dyke RAT Trap - Restart the Database  Oracle recommends that the database is restarted immediately before any workload capture  Ensures that any on-going transactions are completed or rolled back before the capture begins  Reduces amount of divergence  Start workload capture immediately after database restart  Restart database in RESTRICTED mode using STARTUP RESTRICT  Login as SYS and start workload capture  Instance will automatically switch to UNRESTRICTED mode  Experience suggests that the database should be also restarted before any workload replay  Changes to system clock affect AWR snapshots

juliandyke.com 10 © Julian Dyke RAT Trap – Capture Restrictions  The following types of client request are known restrictions for workload capture  Direct path load of data from external files using utilities such as SQL*Loader  Non-PL/SQL based Advanced Queuing (AQ)  Flashback queries  Oracle Call Interface (OCI) based object navigations  Non SQL-based object access  Distributed transactions  Any distributed transactions that are captured will be replayed as local transactions

juliandyke.com 11 © Julian Dyke Capture Filters  By default all user sessions are recorded during workload capture  Workload filters can be configured to include or exclude sessions from the capture  Include filters specify user sessions that will be captured. Can be used to capture a subset of the workload  Exclude filters specify user sessions that will not be captured. Can be used to exclude sessions such as  Enterprise Manager Agent,  STATSPACK,  BMC Patrol  Quest Spotlight  Precise I3  etc

juliandyke.com 12 © Julian Dyke Workload Capture Directories and Files  In Oracle 11.2 and above START_CAPTURE creates subdirectories in capture directory  cap  capfiles  inst1  aa to aj  Each session stores data in a record file e.g. wcr_czq45h rec  Compressed file  XML-like format with elements and attributes  All SQL calls including  statement text  bind variables  execution time  rows returned  error code  Flushed periodically

juliandyke.com 13 © Julian Dyke Workload Capture Files  START_CAPTURE generates the following workload metadata (WMD) files automatically in the cap directory  wcr_scapture.wmd- Start capture details  wcr_fcapture.wmd- Finish capture details  In Oracle 11.2 and above START_CAPTURE automatically generates a capture report in the cap directory  wcr_cr.html- Capture report – HTML format  wcr_cr.text- Capture report – Text format

juliandyke.com 14 © Julian Dyke RAT Trap – Minimum CPU time  A replay requires a minimum of 5 minutes captured CPU time  CPU time NOT Elapsed Time  May be a problem for workloads that are:  I/O-bound  Network intensive  Application-bound  Workload capture period must be long enough to capture five minutes CPU  Can use SLEEP functions to artificially capture CPU  Does not work with PL/SQL DBMS_LOCK.SLEEP function  Works with JServer Java sleep class  Works with External C class

juliandyke.com 15 © Julian Dyke RAT Trap – Finishing Capture  Capture files are written using buffered I/O  Advantages are:  Lower overhead  Lower impact on workload  Disadvantages are:  Buffers are not flushed automatically  SQL statements can be “lost”  When capture ends or FINISH_CAPTURE is executed:  Timeout period is specified  Sessions will be informed during next database call  If sessions make a database call within timeout period  Capture file buffer will be flushed  Otherwise contents will be lost

juliandyke.com 16 © Julian Dyke Generating a Capture Report  Determine the capture ID from the capture name e.g.: SELECT id FROM dba_workload_captures WHERE name = ‘CAPTURE1’; ID 1  Generate the capture report e.g.: SET SERVEROUTPUT ON DECLARE l_clobCLOB BEGIN l_clob := dbms_workload_capture.report ( capture_id=>1, format => DBMS_WORKLOAD_CAPTURE.TYPE_TEXT ); DBMS_OUTPUT.PUT_LINE (l_clob); END; /

juliandyke.com 17 © Julian Dyke Generating a Capture Report  The capture report format can be:  DBMS_WORKLOAD_CAPTURE.TYPE_TEXT  DBMS_WORKLOAD_CAPTURE.TYPE_HTML  The capture report includes the following:  Details of workload capture including name, filters, date, time and SCN  Overall statistics including total DB time, number of logins, number of transactions  Profile of captured workload  Profile of workload not captured due to version limitations  Profile of uncaptured workload that was excluded by defined filters  Profile of uncaptured workload consisting of background process and scheduled jobs

juliandyke.com 18 © Julian Dyke Exporting the AWR  An export of the AWR is required for subsequent analysis on the replay system  To export the AWR use the EXPORT_AWR procedure. For example: BEGIN dbms_workload_capture.export_awr (capture_id=>1); END; /  This creates the following files in the capture directory:  wcr_ca.dmp – Data Pump export  wcr_ca.log – Data Pump log file  wcr_cap_uc_graph.extb – User calls graph

juliandyke.com 19 © Julian Dyke  AWR snapshots are required for subsequent reporting  Ensure that the AWR snapshots are exported before they exceed the AWR retention period and are automatically deleted RAT Trap – AWR Snapshots

juliandyke.com 20 © Julian Dyke Restore Strategy  A strategy is required to restore a pre-capture copy of the database to the replay system  One of the following methods can be used:  RMAN backup and restore  RMAN DUPLICATE command  Snapshot standby  Data Pump Import and Export  SAN replication  The database should be restored on the replay system to the point in time at the start of the capture Recommendation Enable flashback logging and test the replay before performing a recorded test

juliandyke.com 21 © Julian Dyke Replay Preparation  Restore pre-capture database to new home ALTER DATABASE OPEN RESETLOGS;  Modify archive log destination ALTER SYSTEM SET log_archive_dest_1 = ‘LOCATION=/11/oradata/ /arch MANDATORY REOPEN=300’;  Run standard upgrade ALTER SYSTEM SET compatibility = ’ ’ SCOPE = SPFILE; ALTER SYSTEM SET optimizer_features_enable = ’ ’ SCOPE = SPFILE;  Update COMPATIBILITY and OPTIMIZER_FEATURES_ENABLE parameters  Ensure replay database parameters have equivalent values to capture database parameters

juliandyke.com 22 © Julian Dyke Replay User  Replay can be performed by SYS user  Alternatively create a dedicated replay user e.g. RATUSER. $ sqlplus / as sysdba SQL> GRANT DBA TO ratuser;

juliandyke.com 23 © Julian Dyke Replay Directory  The contents of the capture directory should be copied across to the replay server.  It will be necessary to recreate the Oracle directory object: $ sqlplus ratuser/ratuser SQL> CREATE OR REPLACE DIRECTORY capture1 AS ‘/home/oracle/capture1’;

juliandyke.com 24 © Julian Dyke Replay Preprocessing  Pre-process the capture for replay.  For example: BEGIN dbms_workload_replay.process_capture ( capture_dir => ‘CAPTURE1’ ); END; /  Analyses the workload capture found in the CAPTURE_DIR  Creates workload replay metadata files required to replay the given workload capture  Can be run multiple times on same capture directory  Must be run in same database version as replay  Can run multiple replays following execution of PROCESS_CAPTURE

juliandyke.com 25 © Julian Dyke Replay Pre-processing  In Oracle the PROCESS_CAPTURE procedure creates a new subdirectory called pp in the capture directory containing the following files:  wcr_calibrate.html  wcr_commits.extb  wcr_conn_data.extb  wcr_data.extb  wcr_dep_graph.extb  wcr_login.pp  wcr_process.wmd  wcr_references.extb  wcr_scn_order.extb  wcr_seq_data.extb

juliandyke.com 26 © Julian Dyke Replay Preprocessing  To determine how long pre-processing will take use: SELECT dbms_workload_replay.process_capture_remaining_time FROM dual;  Returns an estimate of remaining capture time in minutes  An accurate estimate of remaining processing time cannot be determined during the first minute  Function returns NULL if invoked within first minute of capture pre- processing  To determine what percentage of capture pre-processing is complete use: SELECT dbms_workload_replay.process_capture_completion FROM dual;  Returns percentage of capture files that have already been processed  Percentage is updated every 60 seconds

juliandyke.com 27 © Julian Dyke Workload Analyzer  Workload Analyzer  Available in and above  Java program that analyses a workload capture directory  Identifies parts of captured workload that may not replay accurately e.g.  Insufficient data  Errors occurring during workload capture  Usage features not supported by Database Replay  Results are stored in capture directory in the following files:  wcr_cap_analysis.html  wcr_cap_analysis.xml  Executed automatically by Enterprise Manager during capture pre-processing  Must be invoked manually otherwise  Requires :  $ORACLE_HOME/jdbc/lib/dbranalyzer.jar  $ORACLE_HOME/jdbc/lib/dbrparser.jar  Java 1.5 or above

juliandyke.com 28 © Julian Dyke Workload Analyzer  Syntax is java –classpath \ $ORACLE_HOME/jdbc/lib/ojdbc5.jar:\ $ORACLE_HOME/rdbms/jlib/dbrparser.jar:\ $ORACLE_HOME/rdbms/jlib/dbranalyzer.jar \ oracle.dbreplay.workload.checker/CaptureChecker  - operating system path of the capture directory  - connection string of Oracle database (11.1 and above)  e.g.  In Oracle this utility only works with JDBC thin client  JDBC thick client (OCI) fails  Tested successfully with Java 1.6 and ojdbc6.jar  Analyzer will prompt for username/password of database user e.g. ratuser

juliandyke.com 29 © Julian Dyke RAT Trap - System Clock  Reset the system clock on the replay system to the start time of the capture  Ensure NTP daemon is disabled on replay server  Restart all database instances after resetting the system clock  Consider generating a new ID for the database to ensure AWR snapshots can still be created automatically after the system clock is reset

juliandyke.com 30 © Julian Dyke RAT Trap – External References  Reconfigure references to external systems to avoid impact on production systems during replay  References that should be resolved include:  Database Links  External Tables  Directory Objects  URLs  servers

juliandyke.com 31 © Julian Dyke Initialize Replay  After workload capture has been pre-processed, replay data can be initialized  Loads necessary metadata required by workload replay into tables  captured connection strings are loaded into a table where they can be remapped for replay  For example: BEGIN dbms_workload_replay.initialize_replay ( replay_name => ‘CAPTURE1_REPLAY1’, replay_dir => ‘CAPTURE1’ ); END; /  Known to populate the following base tables:  WRR$_REPLAYS  WRR$_CONNECTION_MAP

juliandyke.com 32 © Julian Dyke Remap Connections  During capture, connection strings used to connect to production system are captured  Connection strings must be remapped to replay system SELECT ‘EXEC dbms_workload_replay.remap_connection (‘||a.conn_id||’,’’(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST= )(PORT= )) (CONNECT_DATA=(SID= )))’’);’ FROM dba_workload_connection_map a, dba_workload_replays b WHERE a.replay_id = b.id AND b.status = ‘INITIALIZED’ ORDER BY a.conn_id; Note that the TNS address is enclosed by a pair of two single quotes, NOT a pair of double quotes

juliandyke.com 33 © Julian Dyke RAT Trap – Remap Connections  Ensure that connections are remapped from the capture database to the replay database  If connections are not remapped, workload may be replayed against production database

juliandyke.com 34 © Julian Dyke Prepare Replay  Specify parameters for workload replay using the PREPARE_REPLAY procedure  For example:  PREPARE_REPLAY parameters include:  SYNCHRONIZATION – Determines how replay will be synchronized. Options are:  SCN – COMMIT order in captured workload is preserved during replay  OBJECT_ID – COMMIT order is maintained for relevant objects only. Relevant objects are objects referenced within current action  OFF – replay is unsynchronized  CONNECT_TIME_SCALE – Scales elapsed time from start of workload capture to time when session connects. Can be used to increase or decrease concurrency. Default is 100% EXECUTE dbms_workload_replay.prepare_replay (synchronization => TRUE);

juliandyke.com 35 © Julian Dyke Prepare Replay  PREPARE_REPLAY parameters (continued):  THINK_TIME_SCALE – Scales elapsed time between successive user calls from same session. Default is 100%. If 0 then no delays between user calls  THINK_TIME_AUTO_CORRECT – Automatically correct think time between calls when user calls take longer to complete during replay than capture  SCALE_UP_MULTIPLIER – Defines number of times workload is scaled up during replay  Each captured session will be replayed number of times specified by this parameter  Only one session in each set will execute both queries and updates  Remaining sessions in set will only execute queries  CAPTURE_STS – specifies whether or not to capture a SQL tuning set in parallel with workload replay  STS_CAP_INTERVAL – specifies duration of SQL tuning set capture from cursor cache in seconds

juliandyke.com 36 © Julian Dyke RAT Trap - Synchronization  Most workloads require full synchronization  Failure to synchronize will increase amount of divergence  Potentially invalidates results  Object synchronization may be useful for a limited range of workloads

juliandyke.com 37 © Julian Dyke Synchronization INSERT INTO t ROWS SELECT FROM t ROWS UPDATE t ROWS DELETE FROM t ROWS A B C D 14:3014:4515:0015:1515:30 Capture – Table t contains 0 rows at end of capture Sessions

juliandyke.com 38 © Julian Dyke Synchronization INSERT INTO t ROWS SELECT FROM t 0 ROWS UPDATE t 0 ROWS DELETE FROM t 0 ROWS A B C D 14:3014:4515:0015:1515:30 Replay without synchronization In this example table t contains rows at end of replay Sessions

juliandyke.com 39 © Julian Dyke RAT Trap – Connect and Think Times  Changing connect times and/or think times  Can introduce or alleviate contention  May not be representative of workload  No granularity  Connect / think times must be changed for entire workload  For example cannot distinguish between OLTP and batch within workload  Beware of  Time dependent workload e.g. feeds from other systems  External schedulers e.g. Control M  Application server bottlenecks e.g. Java

juliandyke.com 40 © Julian Dyke Timing A B C D BATCH OLTP 14:3014:4515:0015:1515:30 Sessions Capture – OLTP sessions run at 14:30 and complete by 14:45 Batch runs at 15:00

juliandyke.com 41 © Julian Dyke Timing A B C D BATCH OLTP 14:3014:4515:0015:1515:30 Sessions Replay with connect time set to 0% Batch and OLTP all start at 14:30 – may result in resource contention

juliandyke.com 42 © Julian Dyke RAT Trap – Scaling  RAT offers limited scaling of workloads  For a specific session  SELECT statements can be scaled to multiple sessions  DML statements are only executed in one session  Therefore scaling can only be considered appropriate for read-only workloads  For all other workloads,  Further analysis will be required  Scaling may not be appropriate

juliandyke.com 43 © Julian Dyke Workload Replay Client  Replay client is a multi-threaded program called wrc located in $ORACLE_HOME/bin  Included in Oracle and above client  Each thread submits a workload from a captured session  Database will wait for replay clients to connect before replay begins  Replay clients should run on separate hardware to database  Replay clients must have access to replay directory  Replay directory should contain pre-processed workload capture  Replay directory should be in different file system to database files  Replay client must specify username/password  user must have DBA role  user cannot be SYS

juliandyke.com 44 © Julian Dyke Workload Replay Client - Calibration  Run calibration to determine how many replay clients are required to support the replay workload  For example: wrc ratuser/ratuser MODE=calibrate REPLAYDIR=‘/home/oracle/capture1’;  Advanced parameters are:  PROCESS_PER_CPU - Maximum number of client process than can be run per CPU (Default: 4)  THREADS_PER_PROCESS - Maximum number of threads than can be run within a client process (Default: 50)

juliandyke.com 45 © Julian Dyke Workload Replay Client - Calibration  Sample output: Workload Replay Client: Release Production on Thu May 24 20:01: Report for Workload in: /home/oracle/rat/capture31 Recommendation: Consider using at least 2 clients divided among 1 CPU(s) You will need at least 135 MB of memory per client process. If your machine(s) cannot match that number, consider using more clients. Workload Characteristics: - max concurrency: 71 sessions - total number of sessions: Assumptions: - 1 client process per 50 concurrent session - 4 client process per CPU KB of memory cache per concurrent session - think time scale = connect time scale = synchronization = TRUE

juliandyke.com 46 © Julian Dyke Workload Replay Client - Replay  To replay the workload specify the REPLAY mode  For example: wrc ratuser/ratuser MODE=replay REPLAYDIR=‘/home/oracle/capture1’  Options include:  WORKDIR – directory for trace files  DEBUG – ON or OFF (Default : OFF)  CONNECTION_OVERRIDE – If TRUE the ignore replay connections specified in DBA_WORKLOAD_CONNECTION_MAP. If FALSE (default) use replay connections in DBA_WORKLOAD_CONNECTION_MAP  SERIALIZE_CONNECTS – if TRUE all replay threads will connect to database serially (one after another). Recommended for clients using bequeath protocol. If FALSE (default) replay threads will connect to database concurrently  DSCN_OFF – If TRUE then ignore all dependencies due to block contention during capture when synchronizing replay. If FALSE (default) honour all captured dependencies

juliandyke.com 47 © Julian Dyke Starting a Workload Replay  After the replay clients have been started, the replay must be started on the database BEGIN dbms_workload_replay.start_replay; END;  The START_REPLAY procedure does not take any arguments  When executed within SQL*Plus,  session returns to the prompt after replay has been started  replay continues to execute in background

juliandyke.com 48 © Julian Dyke Workload Replay Directories  The replay creates a new replay directory within the capture directory  For example if the capture directory is /home/oracle/rat/capture31:  /home/oracle/rat/capture31/rep  The replay directory name includes the REPLAY_DIR_NUMBER which is reported in DBA_WORKLOAD_REPLAYS SELECT replay_dir_number FROM dba_workload_replays WHERE id = 31; REPLAY_DIR_NUMBER  The workload replay creates several files within the replay directory:  wcr_replay.wmd- Replay workload metadata  wcr_rep_uc_graph_ extb- Replay user calls graph  wcr_rr_ xml- Replay report – XML format

juliandyke.com 49 © Julian Dyke Managing a Workload Replay  To pause a workload replay use: EXECUTE dbms_workload_replay.pause_replay;  To resume a paused workload replay use: EXECUTE dbms_workload_replay.resume_replay;  To check if a replay is paused use: SELECT dbms_workload_replay.is_replay_paused FROM dual;  To cancel a workload replay use: EXECUTE dbms_workload_replay.cancel_replay;

juliandyke.com 50 © Julian Dyke Exporting AWR Data  AWR data  can be exported to provide detailed workload analysis  is also required for AWR Compare Period report  To export AWR use the EXPORT_AWR procedure e.g: EXECUTE dbms_workload_replay.export_awr (replay_id=>107);/ AWR snapshots are required for subsequent reporting Ensure that the AWR snapshots are exported before they exceed the AWR retention period and are automatically deleted  Replay AWR data is exported into the replay directory, for example:  /home/oracle/rat/capture31/rep  The export files include the REPLAY_DIR_NUMBER:  wcr_ra_ dmp  wcr_ra_ log

juliandyke.com 51 © Julian Dyke Generating a Replay Report  Identify the most recent replay ID SELECT MAX(id) AS id FROM dba_workload_replays WHERE status = 'COMPLETED'; ID 2  Generate the replay report SET SERVEROUTPUT ON DECLARE l_clobCLOB BEGIN l_clob := dbms_workload_replay.report ( replay_id=>1, format => DBMS_WORKLOAD_REPLAY.TYPE_TEXT ); DBMS_OUTPUT.PUT_LINE (l_clob); END; /

juliandyke.com 52 © Julian Dyke Generating a Replay Report  The replay report format can be:  DBMS_WORKLOAD_REPLAY.TYPE_TEXT  DBMS_WORKLOAD_REPLAY.TYPE_HTML  DBMS_WORKLOAD_REPLAY.TYPE_XML  The AWR snapshots must still exist in the replay database to generate the replay report  The replay report includes the following:  Details of workload replay including name, filters, date and time  Replay options and number of replay clients started  Overall statistics about the replay and capture including total DB time, number of logins, number of transactions  Profile of replayed workload  Replay divergence  Error divergence  DML and SQL query data divergence

juliandyke.com 53 © Julian Dyke Divergence  When a workload is replayed there can be divergence between the capture and the replay  There are two types of divergence  Performance Divergence – occurs when changes on the replay system affect overall performance. Changes may include  Software  Hardware  Parameters  Data Divergence – occurs when results of DML or SQL queries do not match  For example a SELECT statement may return fewer rows during replay than during capture

juliandyke.com 54 © Julian Dyke Listing Divergences  Divergences are reported in DBA_WORKLOAD_REPLAY_DIVERGENCE  Each divergence is identified by  REPLAY_ID  STREAM_ID  CALL_COUNTER  Information about a divergence is reported by the GET_DIVERGING_STATEMENT procedure in DBMS_WORKLOAD_REPLAY

juliandyke.com 55 © Julian Dyke RAT Trap – PLSQL Blocks  Anonymous PL/SQL blocks are captured  PL/SQL calls within those blocks are not captured  SQL statement calls within those blocks are not captured  Only errors returned by PL/SQL block exceptions are recorded  If recursive exceptions are caught and handled internally these will not be reported  If PL/SQL logic is different, this may not be captured  Replay may be affected by  Changes in supplied PL/SQL packages  Changes in application PL/SQL packages

juliandyke.com 56 © Julian Dyke Replay Analysis  The following types of reports are available to analyse workload capture and replay:  Capture Report  Replay Report  Compare Period Report  Compare SQLSET report

juliandyke.com 57 © Julian Dyke Importing a Capture AWR  Before running the compare reports, it is necessary to import the capture AWR  The workload analyzer attempts to import the capture AWR, but this version does not appear to be usable  The capture AWR should be imported into a new schema.  In this example the new schema is called CAPTURE31  RESOURCE role appears to be necessary and sufficient CREATE USER capture31 IDENTIFIED BY capture31; GRANT RESOURCE TO capture31;  Identify the ID of the capture workload SELECT id FROM dba_workload_captures WHERE name = ‘CAPTURE31’; ID 115

juliandyke.com 58 © Julian Dyke Importing a Capture AWR  Import the AWR using the IMPORT_AWR procedure. For example: SET SERVEROUTPUT ON DECLARE l_dbid NUMBER; BEGIN l_dbid := dbms_workload_capture.import_awr ( capture_id => 115, staging_schema => 'CAPTURE31‘ ); dbms_output.put_line (‘DBID = '||l_dbid); END; / DBID =  The IMPORT_AWR function returns the new DBID assigned to the imported AWR.

juliandyke.com 59 © Julian Dyke Compare Period Reports  Compare Period reports allow comparison of  Workload replay with workload capture  Workload replay with another workload replay from same capture  Only workload replays containing at least 5 minutes of database time can be compared using this report

juliandyke.com 60 © Julian Dyke Compare Period Reports  For example: SET PAGESIZE 0 SET TRIMSPOOL ON SET LINESIZE 500 SET FEEDBACK OFF SET LONG SET SERVEROUTPUT ON VAR v_clob CLOB BEGIN dbms_workload_replay.compare_period_report ( replay_id1 => 31, replay_id2 => NULL, format => DBMS_WORKLOAD_REPLAY.TYPE_HTML, result => :v_clob ); END; / PRINT v_clob

juliandyke.com 61 © Julian Dyke RAT Trap – DB Time  DB time is the best and possibly only metric to compare captures with replays  Other metrics can be used to compare replays with each other  DB time may be affected by  Changes in hardware e.g.  SSD,  10GbE networks  faster CPU  more memory  Changes in Oracle version  Additional functionality  Longer code paths  Background workload  Divergence  Make sure you understand all the differences between environments before making a decision based on Database Replay outcomes

juliandyke.com 62 © Julian Dyke Compare SQLSET Reports  SQL Performance Analyzer (SPA) reports can be generated using the DBMS_WORKLOAD_REPLAY package  The SPA can be used to compare  a SQL tuning set from a workload replay with the SQL tuning set from the workload capture  a SQL tuning set from a workload replay with the SQL tuning set from another workload replay from the same workload capture

juliandyke.com 63 © Julian Dyke Compare SQLSET Report SET PAGESIZE 0 SET TRIMSPOOL ON SET LINESIZE 500 SET FEEDBACK OFF SET LONG VAR v_clob CLOB DECLARE l_result VARCHAR2(200); BEGIN l_result := dbms_workload_replay.compare_sqlset_report ( replay_id1 => 44, replay_id2 => NULL, format => DBMS_WORKLOAD_REPLAY.TYPE_HTML, result => :v_clob ); END; / PRINT v_clob SPOOL OFF Compare replay with original capture

juliandyke.com 64 © Julian Dyke Compare SQLSET Report SET PAGESIZE 0 SET TRIMSPOOL ON SET LINESIZE 500 SET FEEDBACK OFF SET LONG VAR v_clob CLOB DECLARE l_result VARCHAR2(200); BEGIN l_result := dbms_workload_replay.compare_sqlset_report ( replay_id1 => 44, replay_id2 => 42, format => DBMS_WORKLOAD_REPLAY.TYPE_HTML, result => :v_clob ); END; / PRINT v_clob SPOOL OFF Compare replay with another replay

juliandyke.com 65 © Julian Dyke Conclusions  RAT can be very good at capturing and replaying workloads  Requires a lot of user discipline  Follow the capture and replay recommendations  Unsupported workload features can increase divergence  For best results avoid using “enhancements” such as  Object synchronization  Connect time modifications  Think time modifications  Workload scaling

juliandyke.com 66 © Julian Dyke Acknowledgements  This presentation would not have been possible without the help of:  Andrew Ashworth (Ash)  Pete Taylor  Thank you