Вы находитесь на странице: 1из 74

REAL APPLICATION TESTING ON 10G STEP BY STEP

1/74
Alejandro Vargas
Principal Support Consultant
Oracle Advanced Customer Services
Summary............................................................................................................................................................................3
Patches Required for RAT..................................................................................................................................................4
Project Implementation Steps.............................................................................................................................................5
Clone production database on test server, start it up.........................................................................................................6
Create 11g database on test server on Windows...............................................................................................................6
Download patches for RAT.................................................................................................................................................6
Download RAT scripts and docs from OTN........................................................................................................................7
Patches Installation............................................................................................................................................................. 7
Install patch 6998002 on Windows 10g database..............................................................................................................9
Install patch 6903335 on Windows 10g clone database...................................................................................................17
Install patch 7044721 on Windows 11g test database.....................................................................................................22
Configure and execute functional RAT tests on Windows................................................................................................36
Create A Small Test Inside To Clone Of Production To Test On Linux............................................................................36
Test Capture On The Production Clone...........................................................................................................................36
Create a filter for the session to capture...........................................................................................................................38
Create a Directory to store the captured load...................................................................................................................39
Start the Capture process.................................................................................................................................................39
Stopping a Workload Capture..........................................................................................................................................41
Check capture process ID and status...............................................................................................................................41
Exporting AWR Data for Workload Capture.....................................................................................................................43
After completing the run gather awr statistics...................................................................................................................45
REAL APPLICATION TESTING ON 10G STEP BY STEP
2/74
Generating a Workload Capture Report Using APIs........................................................................................................46
Workload Preprocessing..................................................................................................................................................47
Workload Replay..............................................................................................................................................................47
Steps for Replaying a Database Workload.......................................................................................................................50
Prepare the Replay Database..........................................................................................................................................51
Execute the Replay Database..........................................................................................................................................51
SQL Performance Analyzer..............................................................................................................................................55
SQL Performance Analyzer Workflow Steps....................................................................................................................55
Capture the SQL workload using APIs.............................................................................................................................55
Create An Empty Sql Tuning Set To Be Populated With Some Load..............................................................................56
Load SQL Statements on the STS...................................................................................................................................56
Displaying the Contents of a SQL Tuning Set..................................................................................................................60
Transporting a SQL Tuning Set........................................................................................................................................63
Transport The Load Table To The Test System...............................................................................................................64
FTP the table to the test system.......................................................................................................................................65
Unpack the STS Into the Test System..............................................................................................................................68
Prepare The Test System.................................................................................................................................................68
Creating a SQL Performance Analyzer Task....................................................................................................................69
Executing the SQL Workload Before a Change...............................................................................................................70
Generate an Report with Analysis Of Task Results..........................................................................................................72
REAL APPLICATION TESTING ON 10G STEP BY STEP
3/74
Summary
This document is a step-by-step example of using Real Application Testing (RAT) to evaluate a platform migration of a
10.2.0.3 production database from Windows 32bit to Linux 64 bit.
The project consider capturing and running production loads on a test environment using SQL Performance Analyzer
(SPA) on a 10g production clone on Linux; and Database Replay on an production clone upgraded to 11g on Linux.
Both tests should provide information to evaluate if the Linux environment actual configuration is capable to sustain a
production load.
The examples provided are limited, RAT offers a wide range of possible configurations, and this is an example of one of
these multiple possibilities.
Complete information about RAT requirements for pre 11g databases can be found on Note 560977.1
Real Application Testing functionality for pre-11g database releases is installed using the opatch utility and following
instructions for the generic and platform specific README for the patches. 11g do need also a patch to be able to use
SQL traces from previous releases and create an SQL Tuning Set (STS).
REAL APPLICATION TESTING ON 10G STEP BY STEP
4/74
Patches Required for RAT
Here Im relating only to the patches I did use on this test, a complete list of RAT required patches for various
platforms could be found on Metalink on Note 560977.1.
If you want to only use Database Replay or SQL Performance Analyzer, then only the patch for that particular
functionality needs to be applied. If you want to use both Database Replay and SQL Performance Analyzer, the
patches for both functionalities need to be applied.
Database Replay is only possible when using an 11g Database for the replay phase
Patches for Database Replay on Windows:
Source Destination Patch
10.2.0.3.0 32-bit >=11.1.0.6.0 10.2.0.3.0 + patch bundle 6998002 Available on Bundle 23.
Patches for Database Replay on Linux:
Source Destination Patch
10.2.0.3.0 >=11.1.0.6.0 10.2.0.3.0 + one off patch 6974999
Patch for SQL Performance Analyzer on Windows
Source Destination Patch
10.2.0.3 10.2.0.4 i) 11.1.0.6 + 6865809(7044721) AND
ii) 10.2.0.3 + 6903335 AND
iii) 10.2.0.4 + 6877038
Download RAT documentation and scripts from
http://www.oracle.com/technology/software/products/database/oracle10g/realapptesting.html
REAL APPLICATION TESTING ON 10G STEP BY STEP
5/74
Project Implementation Steps
1. Clone production database on test server, start it up
2. Create 11g database on test server on Windows
3. Download patch 6998002 for Windows 32 bit
4. Download patch 6903335 for Windows 32 bit
5. Download patch 7044721 for 11.0.6.1 on windows
6. Download patch 6974999 for 10.2.0.3 on Linux
7. Download RAT scripts and docs from OTN
8. Install patch 6998002 on Windows 10g clone database
9. Install patch 6903335 on Windows 10g clone database
10. Install patch 7044721 on Windows 11g test database
11. Install patch 6974999 on Linux 10g test database
12. Configure and execute functional RAT tests on Windows
13. Install 11g on Linux
14. Create 11g Database on Linux
15. Migrate clone of production Database from windows to Linux
16. Configure and execute functional RAT tests on Linux
17. Install patch 6903335 on production database
18. Capture load on production Database
19. Replay production load on Linux
REAL APPLICATION TESTING ON 10G STEP BY STEP
6/74
Clone production database on test server, start it up
Rman was used to create a clone of the production database on the test server.
Create 11g database on test server on Windows
11.1.0.6 was installed on the same test server where the 10g clone of production was created,
A new 11g database REALAPT was created
Download patches for RAT
RAT is available from 10.2.0.4 patch set. For previous releases is made available into one off patches, a complete
matrix of patches can be found on Metalink on Note 560977.1.
Patch 7044721 is required on 11.0.6.1 to be able to use SQL traces from previous releases and create an SQL
Tuning Set (STS) from them.
The following patches were downloaded and applied for this project:
Patch 6998002 for Windows 32 bit
Patch 6903335 for Windows 32 bit
Patch 7044721 for 11.0.6.1 on windows
Patch 6974999 for 10.2.0.3 on Linux
REAL APPLICATION TESTING ON 10G STEP BY STEP
7/74
Download RAT scripts and docs from OTN
RAT functionality can be run from Enterprise Manager or manually using the provided APIs.
Information about both approaches can be obtained from the 10g RAT user Guide that can be downloaded from
OTN.
The RAT user guide comes also as a part of the 11g manuals, can be downloaded from download.oracle.com.
Patches Installation
The patches required for enabling RAT on pre 11g versions and for the 11g version itself are installed using
opatch. A healthy inventory is required, and also you need to setup the path to opatch on the PATH environment
variable.
The patch install is a little bit complex and each one do require several steps, check carefully the requisites as they
are different depending on the patch and the configuration, in general you will see these steps on most of them:
Download
Install
run catcpu
Recompile with utlrp
recompile_precheck<version>
Shutdown
Startup upgrade
view_recompile_<version>
Shutdown
REAL APPLICATION TESTING ON 10G STEP BY STEP
8/74
Startup
Recompile with utlrp
If you get from opatch errors related to the unavailability to copy some dll files, it is related to an Oracle executable
still running, to identify it use the command:
tasklist /m <dll name>
i.e.:
tasklist /m oran10.dll
It will show the program name and PID that is blocking it. You can shutdown this process and retry opatch apply.
REAL APPLICATION TESTING ON 10G STEP BY STEP
9/74
Install patch 6998002 on Windows 10g database
To install the patches prepare the environment to include the path to opatch
set ORACLE_HOME=c:\oracle\product\10.2.0\db_1
set ORACLE_BASE=c:\oracle
set ORACLE_SID=ORCL
set PATH=c:\oracle\product\10.2.0\db_1\bin;C:\oracle\product\10.2.0\db_1\OPatch;C:\Program
Files\Oracle\jre\1.3.1\bin;C:\ProgramFiles\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDO
WS;C:\WINDOWS\System32\Wbem;C:\Program Files\Windows Imaging
Shutdown the database and apply the patch:
C:\RAT-PATCHES\patch-6998002_10203_WINNT\6998002>opatch apply
Invoking OPatch 10.2.0.3.0
Oracle interim Patch Installer version 10.2.0.3.0
Copyright (c) 2005, Oracle Corporation. All rights reserved..
Oracle Home : c:\oracle\product\10.2.0\db_1
Central Inventory : C:\Program Files\Oracle\Inventory
from : n/a
OPatch version : 10.2.0.3.0
OUI version : 10.2.0.3.0
OUI location : c:\oracle\product\10.2.0\db_1\oui
Log file location : c:\oracle\product\10.2.0\db_1\cfgtoollogs\opatch\opatch2008-09-28_11-03-
52AM.log
ApplySession applying interim patch '6998002' to OH 'c:\oracle\product\10.2.0\db_1'
ApplySession: Optional component(s) [ oracle.rdbms.lbac, 10.2.0.3.0 ] , [ oracle.rdbms.dv,
10.2.0.3.0 ] , [ oracle.ntoledb.odp_net_2, 10.2.0.2.20 ] , [ oracle.toledb, 10.2.0.2.20 ] ,
[ oracle.oo4o, 10.2.0.2.20 ] , [ oracle.ntoramts, 10.2.0.3.0 ] , [ oracle.has.crs,
REAL APPLICATION TESTING ON 10G STEP BY STEP
10/74
10.2.0.3.0 ] , [ oracle.ldap.esm, 10.2.0.1.0 ] , [ oacle.precomp.lang, 10.2.0.3.0 ] , [
oracle.rdbms.dv.oc4j, 10.2.0.3.0 ] , [ oracle.rdbms.ic, 10.2.0.3.0 ] not present in the
Oracle Home or a higher version is found.
Subset patches: 5071931
The fixes for Patch 5071931 are included in the patch currently being installed (6998002).
If you continue, they will be rolled back and the new patch (699800) will be installed.
OPatch detected non-cluster Oracle Home from the inventory and will patch the local system
only.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = 'c:\oracle\product\10.2.0\db_1')
Is the local system ready for patching?
Do you want to proceed? [y|n]
y
User Responded with: Y
Backing up files and inventory (not for auto-rollback) for the Oracle Home
Backing up files affected by the patch '6998002' for restore. This might take a while...
Once opatch succeeded to apply the patch continue with the other required steps:
> cd %ORACLE_HOME%\BUNDLE\Patch23
> sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catcpu.sql
SQL> QUIT
REAL APPLICATION TESTING ON 10G STEP BY STEP
11/74
C:\oracle\product\10.2.0\db_1\BUNDLE\PATCH23>sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.3.0 - Production on Sun Sep 28 12:27:35 2008
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SELECT * FROM registry$history where ID = '6452863';
no rows selected <<<<<<<< means that we need to do view recompile
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
C:\oracle\product\10.2.0\db_1\BUNDLE\PATCH23>cd ..
C:\oracle\product\10.2.0\db_1\BUNDLE>dir
Volume in drive C is C_LocalDisk
Volume Serial Number is 7x99-xx66
Directory of C:\oracle\product\10.2.0\db_1\BUNDLE
09/28/2008 11:58 AM <DIR> .
09/28/2008 11:58 AM <DIR> ..
09/28/2008 12:03 PM <DIR> PATCH23
09/28/2008 11:58 AM <DIR> view_recompile
0 File(s) 0 bytes
4 Dir(s) 2,737,711,616 bytes free
REAL APPLICATION TESTING ON 10G STEP BY STEP
12/74
C:\oracle\product\10.2.0\db_1\BUNDLE>cd view_recompile
C:\oracle\product\10.2.0\db_1\BUNDLE\view_recompile>dir
Volume in drive C is C_LocalDisk
Volume Serial Number is 7x99-xx66
Directory of C:\oracle\product\10.2.0\db_1\BUNDLE\view_recompile
09/28/2008 11:58 AM <DIR> .
09/28/2008 11:58 AM <DIR> ..
03/19/2008 11:54 PM 2,089 recompile_precheck_jan2008cpu.sql
03/19/2008 11:54 PM 5,140 view_recompile_jan2008cpu.sql
2 File(s) 7,229 bytes
2 Dir(s) 2,737,711,616 bytes free
C:\oracle\product\10.2.0\db_1\BUNDLE\view_recompile>sqlplus "/ as sysdba"
SQL> @recompile_precheck_jan2008cpu.sql
Running precheck.sql...
Number of views to be recompiled :2404
-----------------------------------------------------------------------
Number of objects to be recompiled :4906
Please follow the README.txt instructions for running viewrecomp.sql
PL/SQL procedure successfully completed.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup upgrade
REAL APPLICATION TESTING ON 10G STEP BY STEP
13/74
ORACLE instance started.
Total System Global Area 2147483648 bytes
Fixed Size 1464608 bytes
Variable Size 494757600 bytes
Database Buffers 1635778560 bytes
Redo Buffers 15482880 bytes
Database mounted.
Database opened.
SQL> @@view_recompile_jan2008cpu.sql
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
1 row created.
Commit complete.
No. of Invalid Objects is :2228
Please refer to README.html to for instructions on validating these objects
PL/SQL procedure successfully completed.
Logfile for the current viewrecomp.sql session is : vcomp_ORCL_28Sep2008_12_33_52.log
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 2147483648 bytes
Fixed Size 1464608 bytes
Variable Size 494757600 bytes
REAL APPLICATION TESTING ON 10G STEP BY STEP
14/74
Database Buffers 1635778560 bytes
Redo Buffers 15482880 bytes
Database mounted.
Database opened.
SQL> @?/rdbms/admin/utlrp
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2008-09-28 12:44:36
DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC> objects in the database. Recompilation time is proportional to the
DOC> number of invalid objects in the database, so this command may take
DOC> a long time to execute on a database with a large number of invalid
DOC> objects.
DOC>
DOC> Use the following queries to track recompilation progress:
DOC>
DOC> 1. Query returning the number of invalid objects remaining. This
DOC> number should decrease with time.
DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC> 2. Query returning the number of objects compiled so far. This number
DOC> should increase with time.
DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC> This script automatically chooses serial or parallel recompilation
DOC> based on the number of CPUs available (parameter cpu_count) multiplied
DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC> On RAC, this number is added across all RAC nodes.
DOC>
DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC> recompilation. Jobs are created without instance affinity so that they
DOC> can migrate across RAC nodes. Use the following queries to verify
REAL APPLICATION TESTING ON 10G STEP BY STEP
15/74
DOC> whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
PL/SQL procedure successfully completed.
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2008-09-28 12:45:12
PL/SQL procedure successfully completed.
DOC> The following query reports the number of objects that have compiled
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
OBJECTS WITH ERRORS
-------------------
257
DOC> The following query reports the number of errors caught during
REAL APPLICATION TESTING ON 10G STEP BY STEP
16/74
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#
ERRORS DURING RECOMPILATION
---------------------------
331
Invoking Ultra Search Install/Upgrade validation procedure VALIDATE_WK
Ultra Search VALIDATE_WK done with no error
PL/SQL procedure successfully completed.
In this case the invalid objects were related to some user applications and not relevant to RAT
This finish the patch installation process on 10g 10.2.0.3
REAL APPLICATION TESTING ON 10G STEP BY STEP
17/74
Install patch 6903335 on Windows 10g clone database
To install the patches prepare the environment to include the path to opatch
set ORACLE_HOME=c:\oracle\product\10.2.0\db_1
set ORACLE_BASE=c:\oracle
set ORACLE_SID=ORCL
set PATH=c:\oracle\product\10.2.0\db_1\bin;C:\oracle\product\10.2.0\db_1\OPatch;C:\Program
Files\Oracle\jre\1.3.1\bin;C:\ProgramFiles\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDO
WS;C:\WINDOWS\System32\Wbem;C:\Program Files\Windows Imaging
Shutdown the database and apply the patch:
C:\RAT-PATCHES\patch-6903335_10203_Windiows\6903335>opatch apply
Invoking OPatch 10.2.0.3.0
Oracle interim Patch Installer version 10.2.0.3.0
Copyright (c) 2005, Oracle Corporation. All rights reserved..
Oracle Home : c:\oracle\product\10.2.0\db_1
Central Inventory : C:\Program Files\Oracle\Inventory
from : n/a
OPatch version : 10.2.0.3.0
OUI version : 10.2.0.3.0
OUI location : c:\oracle\product\10.2.0\db_1\oui
Log file location : c:\oracle\product\10.2.0\db_1\cfgtoollogs\opatch\opatch2008-09-25_17-31-
52PM.log
ApplySession applying interim patch '6903335' to OH 'c:\oracle\product\10.2.0\db_1'
REAL APPLICATION TESTING ON 10G STEP BY STEP
18/74
OPatch detected non-cluster Oracle Home from the inventory and will patch the local system
only.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = 'c:\oracle\product\10.2.0\db_1')
Is the local system ready for patching?
Do you want to proceed? [y|n]
y
User Responded with: Y
Backing up files and inventory (not for auto-rollback) for the Oracle Home
Backing up files affected by the patch '6903335' for restore. This might take a while...
Backing up files affected by the patch '6903335' for rollback. This might take a while...
Patching component oracle.rdbms, 10.2.0.3.0...
Copying file to "c:\oracle\product\10.2.0\db_1\rdbms\admin\prvtspao.plb"
ApplySession adding interim patch '6903335' to inventory
Verifying the update...
Inventory check OK: Patch ID 6903335 is registered in Oracle Home inventory with proper
meta-data.
Files check OK: Files from Patch ID 6903335 are present in Oracle Home.
The local system has been patched and can be restarted.
OPatch succeeded.
C:\RAT-PATCHES\patch-6903335_10203_Windiows\6903335>opatch lsinventory
Invoking OPatch 10.2.0.3.0
Oracle interim Patch Installer version 10.2.0.3.0
Copyright (c) 2005, Oracle Corporation. All rights reserved..
REAL APPLICATION TESTING ON 10G STEP BY STEP
19/74
Oracle Home : c:\oracle\product\10.2.0\db_1
Central Inventory : C:\Program Files\Oracle\Inventory
from : n/a
OPatch version : 10.2.0.3.0
OUI version : 10.2.0.3.0
OUI location : c:\oracle\product\10.2.0\db_1\oui
Log file location : c:\oracle\product\10.2.0\db_1\cfgtoollogs\opatch\opatch2008-09-25_17-42-
11PM.log
Lsinventory Output file location :
c:\oracle\product\10.2.0\db_1\cfgtoollogs\opatch\lsinv\lsinventory2008-09-25_17-42-11PM.txt
--------------------------------------------------------------------------------
Installed Top-level Products (4):
Oracle Database 10g 10.2.0.1.0
Oracle Database 10g Products 10.2.0.1.0
Oracle Database 10g Release 2 Patch Set 1 10.2.0.2.0
Oracle Database 10g Release 2 Patch Set 2 10.2.0.3.0
There are 4 products installed in this Oracle Home.
Interim patches (3) :
Patch 6903335 : applied on Thu Sep 25 17:32:06 IDT 2008
Created on 12 May 2008, 08:56:41 hrs US/Pacific
Bugs fixed:
6903335
Patch 5071931 : applied on Sun Mar 16 15:17:14 IST 2008
Created on 2 May 2007, 07:29:31 hrs PST8PDT
Bugs fixed:
REAL APPLICATION TESTING ON 10G STEP BY STEP
20/74
5071931
Patch 5746875 : applied on Thu Feb 07 14:08:45 IST 2008
Created on 28 Feb 2007, 07:19:02 hrs US/Eastern
Bugs fixed:
5126270, 5726033, 5746875
--------------------------------------------------------------------------------
OPatch succeeded.
Once patch 6903335 is successfully installed the following actions needs to be implemented
Patch Special Instructions:
---------------------------
cd $OH/rdbms/admin
sqlplus / as sysdba
drop table plan_table$; -- drop the plan table if was upgraded.
@catplan.sql -- recreate the plan table
@dbmsxpln.sql -- reload dbms_xplan spec
@prvtxpln.plb -- reload dbms_xplan implementation
@prvtspao.plb -- reload dbms_sqlpa
If the Oracle inventory is not setup correctly this utility will
fail. To check accessibility to the inventory you can use the
command
The execution of prvtspao.plb failed to compile DBMS_SQLPA, you can see the errors on the
following log, the solution was available from Note 605317.1 and 565600.1 that actually
solved the problem: drop plan_table$ and plan_table before retrying prvtspao.plb
SQL> @?/rdbms/admin/prvtspao.plb
REAL APPLICATION TESTING ON 10G STEP BY STEP
21/74
PL/SQL procedure successfully completed.
Package created.
No errors.
Synonym created.
No errors.
Warning: Package Body created with compilation errors.
Errors for PACKAGE BODY DBMS_SQLPA:
LINE/COL ERROR
-------- ------------------------------------------------------
123/5 PL/SQL: SQL Statement ignored
129/44 PL/SQL: ORA-00904: "OTHER_XML": invalid identifier
SQL> alter package DBMS_SQLPA compile body;
Warning: Package Body altered with compilation errors.
SQL> show err
Errors for PACKAGE BODY DBMS_SQLPA:
LINE/COL ERROR
-------- ------------------------------------------------------
123/5 PL/SQL: SQL Statement ignored
129/44 PL/SQL: ORA-00904: "OTHER_XML": invalid identifier
This finish the patch installation process on 10g 10.2.0.3
REAL APPLICATION TESTING ON 10G STEP BY STEP
22/74
Install patch 7044721 on Windows 11g test database
Setup the environment to 11g
set ORACLE_HOME=D:\ORACLE\11g\db11g
set ORACLE_BASE=D:\ORACLE\11g
set ORACLE_SID=REALAPT
set PATH=D:\ORACLE\11g\db11g\bin;D:\ORACLE\11g\db11g\OPatch;C:\Program
Files\Oracle\jre\1.3.1\bin;C:\Program
Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;
Shutdown all resources running on the 11g home and execute opatch apply from the patch directory
C:\RAT-PATCHES\patch-7044721_111060_WINNT\7044721>opatch apply
File Not Found
Invoking OPatch 11.1.0.6.0
Oracle Interim Patch Installer version 11.1.0.6.0
Copyright (c) 2007, Oracle Corporation. All rights reserved.
Oracle Home : D:\ORACLE\11g\db11g
Central Inventory : C:\Program Files\Oracle\Inventory
from : n/a
OPatch version : 11.1.0.6.0
OUI version : 11.1.0.6.0
OUI location : D:\ORACLE\11g\db11g\oui
Log file location : D:\ORACLE\11g\db11g\cfgtoollogs\opatch\opatch2008-09-25_18-14-23PM.log
ApplySession applying interim patch '7044721' to OH 'D:\ORACLE\11g\db11g'
Running prerequisite checks...
REAL APPLICATION TESTING ON 10G STEP BY STEP
23/74
Patch 7044721: Optional component(s) missing : [ oracle.rdbms.ic, 11.1.0.6.0 ] , [
oracle.rdbms.tg4msql, 11.1.0.6.0 ] , [ oracle.sysman.agent, 11.1.0.6.0 ] , [
oracle.ntoledb.odp_net, 11.1.0.6.20 ] , [ oracle.ntoledb.odp_net_2, 11.1.0.6.20 ]
OPatch detected non-cluster Oracle Home from the inventory and will patch the local system
only.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = 'D:\ORACLE\11g\db11g')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files and inventory (not for auto-rollback) for the Oracle Home
Backing up files affected by the patch '7044721' for restore. This might take a while...
Backing up files affected by the patch '7044721' for rollback. This might take a while...
Execution of 'cmd /C "C:\RAT-PATCHES\patch-
7044721_111060_WINNT\7044721\custom\scripts\pre.bat" -apply 7044721 ':
Return Code = 0
Patching component oracle.rdbms.rsf, 11.1.0.6.0...
Copying file to "D:\ORACLE\11g\db11g\bin\oraclient11.dll"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\oraclient11.sym"
Copying file to "D:\ORACLE\11g\db11g\bin\orageneric11.dll"
Copying file to "D:\ORACLE\11g\db11g\bin\orapls11.dll"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\orageneric11.sym"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\orapls11.sym"
Copying file to "D:\ORACLE\11g\db11g\lib\orapls11.lib"
Copying file to "D:\ORACLE\11g\db11g\plsql\mesg\plwus.msb"
Patching component oracle.rdbms, 11.1.0.6.0...
Updating jar file "D:\ORACLE\11g\db11g\rdbms\jlib\CDC.jar" with
"\rdbms\jlib\CDC.jar\oracle\CDC\AdvanceChangeSet.class"
REAL APPLICATION TESTING ON 10G STEP BY STEP
24/74
Copying file to "D:\ORACLE\11g\db11g\bin\oracle.exe"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\oracle.sym"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\catplan.sql"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\dbmsspa.sql"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\dbmssqlt.sql"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\dbmssqlu.sql"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\dbmsxpln.sql"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvsspai.plb"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvssqli.plb"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtxpln.plb"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvsadv.plb"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtadv.plb"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtdadv.plb"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtspa.plb"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtspai.plb"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtsqlu.plb"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtsqli.plb"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtsqlt.plb"
Copying file to "D:\ORACLE\11g\db11g\Bundle\view_recompile\view_recompile_bundlepatch4.sql"
Copying file to
"D:\ORACLE\11g\db11g\Bundle\view_recompile\recompile_precheck_bundlepatch4.sql"
Copying file to "D:\ORACLE\11g\db11g\Bundle\Patch4\catcpu.sql"
Copying file to "D:\ORACLE\11g\db11g\Bundle\Patch4\catcpu_rollback.sql"
Copying file to "D:\ORACLE\11g\db11g\Bundle\Patch4\sdocpu.sql"
Copying file to "D:\ORACLE\11g\db11g\Bundle\Patch4\javcpu.sql"
Patching component oracle.oracore.rsf, 11.1.0.6.0...
Copying file to "D:\ORACLE\11g\db11g\bin\oracore11.dll"
Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\oracore11.sym"
Copying file to "D:\ORACLE\11g\db11g\lib\oracore11.lib"
Patching component oracle.sdo.locator, 11.1.0.6.0...
Copying file to "D:\ORACLE\11g\db11g\md\admin\prvtpidx.plb"
REAL APPLICATION TESTING ON 10G STEP BY STEP
25/74
Patching component oracle.ons, 11.1.0.5.0...
Copying file to "D:\ORACLE\11g\db11g\opmn\bin\ons.exe"
Patching component oracle.rdbms.rsf.ic, 11.1.0.6.0...
Copying file to "D:\ORACLE\11g\db11g\bin\oci.dll"
Patching component oracle.rdbms.oci, 11.1.0.6.0...
Copying file to "D:\ORACLE\11g\db11g\oci\lib\msvc\oci.lib"
Patching component oracle.rdbms.hsodbc, 11.1.0.6.0...
Copying file to "D:\ORACLE\11g\db11g\bin\dg4odbc.exe"
ApplySession adding interim patch '7044721' to inventory
Verifying the update...
Inventory check OK: Patch ID 7044721 is registered in Oracle Home inventory with proper
meta-data.
Files check OK: Files from Patch ID 7044721 are present in Oracle Home.
--------------------------------------------------------------------------------
********************************************************************************
** ATTENTION **
** **
** Please note that the Patch Installation (Patch Deinstallation) is not **
** complete until all the Post Installation (Post Deinstallation) **
** instructions noted in the Readme accompanying this patch, have been **
** successfully completed. **
** **
********************************************************************************
********************************************************************************
--------------------------------------------------------------------------------
Execution of 'cmd /C "C:\RAT-PATCHES\patch-
7044721_111060_WINNT\7044721\custom\scripts\post.bat" -apply 7044721 ':
REAL APPLICATION TESTING ON 10G STEP BY STEP
26/74
Return Code = 0
The local system has been patched and can be restarted.
OPatch succeeded.
After the patch the script catcpu located on directory $ORACLE_HOME\ Bundle\Patch4 needs to be
executed
D:\ORACLE\11g\db11g\Bundle\Patch4>sqlplus / as sysdba
SQL> @catcpu.sql
Session altered.
Session altered.
PL/SQL procedure successfully completed.
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP CPU_BGN 2008-09-25 18:29:45
PL/SQL procedure successfully completed.
Library created.
No errors.
Library created.
Package created.
No errors.
...
... (more output)
...
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP SDO 2008-09-25 18:30:30
DBUA_TIMESTAMP SDO VALID 2008-09-25 18:30:30
REAL APPLICATION TESTING ON 10G STEP BY STEP
27/74
0 rows deleted.
1 row created.
PL/SQL procedure successfully completed.
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP CPU_END 2008-09-25 18:30:30
No. of Invalid Objects is :28
Please refer to README.html to for instructions on validating these objects
PL/SQL procedure successfully completed.
Logfile for the current catcpu.sql session is : APPLY_REALAPT_25Sep2008_18_29_45.log
SQL> SELECT OBJECT_NAME FROM DBA_OBJECTS WHERE STATUS = 'INVALID';
OBJECT_NAME
--------------------------------------------------------------------------------
DBA_HIST_SQLBIND
DBA_HIST_SQLBIND
DBA_SQLSET_BINDS
USER_SQLSET_BINDS
USER_SQLSET_BINDS
ALL_SQLSET_BINDS
ALL_SQLSET_BINDS
PRVT_REPORT_TAGS
PRVT_SQLADV_INFRA
PRVT_SQLSET_INFRA
PRVT_SQLPROF_INFRA
DBMS_MANAGEMENT_PACKS
PRVT_HDM
WRI$_ADV_HDM_T
DBMS_UNDO_ADV
REAL APPLICATION TESTING ON 10G STEP BY STEP
28/74
DBMS_SPM
DBMS_SMB_INTERNAL
DBMS_SMB
PRVT_WORKLOAD_NOPRIV
WRI$_ADV_SQLACCESS_ADV
WRI$_ADV_TUNEMVIEW_ADV
PRVT_PARTREC_NOPRIV
DBMS_XPLAN
DBMS_STATS_INTERNAL
DBMS_SQLDIAG_INTERNAL
DBMS_SQLTCB_INTERNAL
DBMS_SQLDIAG
DBMS_CUBE_ADVISE
28 rows selected.
SQL> @?/rdbms/admin/utlrp
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2008-09-25 18:37:53
DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC> objects in the database. Recompilation time is proportional to the
DOC> number of invalid objects in the database, so this command may take
DOC> a long time to execute on a database with a large number of invalid
DOC> objects.
DOC>
DOC> Use the following queries to track recompilation progress:
DOC>
DOC> 1. Query returning the number of invalid objects remaining. This
DOC> number should decrease with time.
DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
REAL APPLICATION TESTING ON 10G STEP BY STEP
29/74
DOC> 2. Query returning the number of objects compiled so far. This number
DOC> should increase with time.
DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC> This script automatically chooses serial or parallel recompilation
DOC> based on the number of CPUs available (parameter cpu_count) multiplied
DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC> On RAC, this number is added across all RAC nodes.
DOC>
DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC> recompilation. Jobs are created without instance affinity so that they
DOC> can migrate across RAC nodes. Use the following queries to verify
DOC> whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
PL/SQL procedure successfully completed.
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2008-09-25 18:38:21
PL/SQL procedure successfully completed.
DOC> The following query reports the number of objects that have compiled
REAL APPLICATION TESTING ON 10G STEP BY STEP
30/74
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
OBJECTS WITH ERRORS
-------------------
0
DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#
ERRORS DURING RECOMPILATION
---------------------------
0
PL/SQL procedure successfully completed.
Invoking Ultra Search Install/Upgrade validation procedure VALIDATE_WK
Ultra Search VALIDATE_WK done with no error
PL/SQL procedure successfully completed.
SQL> SELECT OBJECT_NAME FROM DBA_OBJECTS WHERE STATUS = 'INVALID';
no rows selected
REAL APPLICATION TESTING ON 10G STEP BY STEP
31/74
After that need to check if view recompilation was done, this select should return one row, if not perform
view recompilation
SQL> SELECT * FROM registry$history where ID = '6452863';
no rows selected
exit
cd D:\ORACLE\11g\db11g\Bundle\view_recompile
D:\ORACLE\11g\db11g\Bundle\view_recompile>sqlplus / as sysdba
SQL> @recompile_precheck_bundlepatch4.sql
Running precheck.sql...
Number of views to be recompiled :2733
-----------------------------------------------------------------------
Number of objects to be recompiled :5543
Please follow the README.txt instructions for running viewrecomp.sql
PL/SQL procedure successfully completed.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup upgrade
ORACLE instance started.
Total System Global Area 292933632 bytes
Fixed Size 1332752 bytes
Variable Size 226494960 bytes
Database Buffers 58720256 bytes
Redo Buffers 6385664 bytes
Database mounted.
Database opened.
REAL APPLICATION TESTING ON 10G STEP BY STEP
32/74
SQL> @view_recompile_bundlepatch4.sql
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
1 row created.
Commit complete.
No. of Invalid Objects is :33
Please refer to README.html to for instructions on validating these objects
PL/SQL procedure successfully completed.
Logfile for the current viewrecomp.sql session is : vcomp_REALAPT_28Sep2008_09_26_40.log
SQL> @?/rdbms/admin/utlrp
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2008-09-28 09:31:05
DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC> objects in the database. Recompilation time is proportional to the
DOC> number of invalid objects in the database, so this command may take
DOC> a long time to execute on a database with a large number of invalid
DOC> objects.
DOC>
DOC> Use the following queries to track recompilation progress:
DOC>
DOC> 1. Query returning the number of invalid objects remaining. This
DOC> number should decrease with time.
DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
REAL APPLICATION TESTING ON 10G STEP BY STEP
33/74
DOC> 2. Query returning the number of objects compiled so far. This number
DOC> should increase with time.
DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC> This script automatically chooses serial or parallel recompilation
DOC> based on the number of CPUs available (parameter cpu_count) multiplied
DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC> On RAC, this number is added across all RAC nodes.
DOC>
DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC> recompilation. Jobs are created without instance affinity so that they
DOC> can migrate across RAC nodes. Use the following queries to verify
DOC> whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
PL/SQL procedure successfully completed.
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2008-09-28 09:31:33
PL/SQL procedure successfully completed.
DOC> The following query reports the number of objects that have compiled
REAL APPLICATION TESTING ON 10G STEP BY STEP
34/74
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
OBJECTS WITH ERRORS
-------------------
0
DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#
ERRORS DURING RECOMPILATION
---------------------------
0
PL/SQL procedure successfully completed.
Invoking Ultra Search Install/Upgrade validation procedure VALIDATE_WK
Ultra Search VALIDATE_WK done with no error
PL/SQL procedure successfully completed.
SQL>
SQL> shutdown immediate
Database closed.
Database dismounted.
REAL APPLICATION TESTING ON 10G STEP BY STEP
35/74
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 292933632 bytes
Fixed Size 1332752 bytes
Variable Size 226494960 bytes
Database Buffers 58720256 bytes
Redo Buffers 6385664 bytes
Database mounted.
Database opened.
SQL>
This finish the patch installation process on 11g 11.1.0.6
REAL APPLICATION TESTING ON 10G STEP BY STEP
36/74
Configure and execute functional RAT tests on Windows
Create A Small Test Inside To Clone Of Production To Test On Linux
>sqlplus "/ as sysdba"
SQL> create tablespace avtest datafile 'E:\ORACLE\ORADATA\ORCL\AVTST_01_TBS.DBF' size 100m;
Tablespace created.
SQL> create user avargas identified by oracle default tablespace avtest temporary tablespace
temp;
User created.
SQL> grant dba , all privileges to avargas;
Grant succeeded.
SQL> connect avargas/oracle
Connected.
SQL> create table test1 as select * from dba_source;
Table created.
SQL> create table test2 as select * from dba_users;
Table created.
Test Capture On The Production Clone
Parameter PRE_11G_ENABLE_CAPTURE=TRUE is required only on 10.2.0.4 lower releases do not need to set
it.
REAL APPLICATION TESTING ON 10G STEP BY STEP
37/74
Before capturing the database may be restarted to assure all transactions are captured, otherwise uncommitted
transactions may be left out of the captured load.
Workload Capture Restrictions
The following types of client requests are not captured in a workload in the current release:
Direct path load of data from external files using utilities such as SQL*Loader
Shared server requests (Oracle MTS)
Oracle Streams
Advanced Replication streams
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)
Remote DESCRIBE and COMMIT operations
Using Database Replay requires four main steps
Workload Capture
Workload Preprocessing
Workload Replay
Analysis and Reporting
Capturing a Database Workload Using APIs
Capturing a database workload using the DBMS_WORKLOAD_CAPTURE package involves:
REAL APPLICATION TESTING ON 10G STEP BY STEP
38/74
Adding and Removing Workload Filters
Starting a Workload Capture
Stopping a Workload Capture
Exporting AWR Data for Workload Capture
Create a filter for the session to capture
BEGIN
DBMS_WORKLOAD_CAPTURE.ADD_FILTER (
fname => 'user_avargas',
fattribute => 'USER',
fvalue => 'AVARGAS');
END;
/
SQL> BEGIN
2 DBMS_WORKLOAD_CAPTURE.ADD_FILTER (
3 fname => 'user_avargas',
4 fattribute => 'USER',
5 fvalue => 'AVARGAS');
6 END;
7 /
PL/SQL procedure successfully completed.
To disable the filter can use:
BEGIN
DBMS_WORKLOAD_CAPTURE.DELETE_FILTER (fname => 'AVARGAS');
END;
/
REAL APPLICATION TESTING ON 10G STEP BY STEP
39/74
Create a Directory to store the captured load
SQL> create or replace directory loadcapt as 'E:\RAT_LOAD_CAPTURE';
Directory created.
SQL> grant read , write on directory loadcapt to public;
Grant succeeded.
Start the Capture process
BEGIN
DBMS_WORKLOAD_CAPTURE.START_CAPTURE (name => 'ORCL Test Capture',
dir => 'LOADCAPT',
duration => 600);
END;
/
SQL> BEGIN
2 DBMS_WORKLOAD_CAPTURE.START_CAPTURE (name => 'ORCL Test Capture',
3 dir => 'LOADCAPT',
4 duration => 600);
5 END;
6 /
PL/SQL procedure successfully completed.
In this example the filter previously created is considered an exclusion filter, user avargas is excluded from
the capture.
REAL APPLICATION TESTING ON 10G STEP BY STEP
40/74
To use it as an inclusion filter for the user defined on it add the parameter "default_action => EXCLUDE" that
indicates to exclude all users except the user or users included in a defined filter.
The default action used is INCLUDE, if not defined will be used and any defined user on a filter will be excluded.
BEGIN
DBMS_WORKLOAD_CAPTURE.START_CAPTURE (name => 'ORCL Test Capture 2',
dir => 'LOADCAPT',
duration => 600,
default_action => 'EXCLUDE');
END;
/
Make some load as avargas
SQL> delete from test1 where substr(name,1,10)='MMS_TIPUL_';
26740 rows deleted.
SQL> commit;
Commit complete.
SQL> delete from test1 where substr(name,1,10)='MRK_PIZUR_';
23849 rows deleted.
SQL> commit;
Commit complete.
SQL> delete from test1 where substr(name,1,5)like 'MGMT';
0 rows deleted.
SQL> delete from test1 where substr(name,1,5)like 'MGMT_';
62217 rows deleted.
REAL APPLICATION TESTING ON 10G STEP BY STEP
41/74
SQL> rollback;
Rollback complete.
SQL> delete from test1 where substr(name,1,5)like 'MGMT_';
62217 rows deleted.
SQL> commit;
Commit complete.
Stopping a Workload Capture
To stop the workload capture, use the FINISH_CAPTURE procedure:
BEGIN
DBMS_WORKLOAD_CAPTURE.FINISH_CAPTURE ();
END;
/
SQL> BEGIN
2 DBMS_WORKLOAD_CAPTURE.FINISH_CAPTURE ();
3 END;
4 /
PL/SQL procedure successfully completed.
Check capture process ID and status
COL NAME FOR A25
COL DIRECTORY FOR A15
COL STATUS FOR A20
SELECT ID,NAME,DIRECTORY,STATUS FROM DBA_WORKLOAD_CAPTURES
/
REAL APPLICATION TESTING ON 10G STEP BY STEP
42/74
SQL> COL NAME FOR A25
SQL> COL DIRECTORY FOR A15
SQL> COL STATUS FOR A20
SQL> SELECT ID,NAME,DIRECTORY,STATUS FROM DBA_WORKLOAD_CAPTURES
/
ID NAME DIRECTORY STATUS
---------- ------------------------- --------------- --------------------
1 ORCL Test Capture LOADCAPT COMPLETED
After second run
SQL> COL NAME FOR A25
SQL> COL DIRECTORY FOR A15
SQL> COL STATUS FOR A20
SQL> SELECT ID,NAME,DIRECTORY,STATUS FROM DBA_WORKLOAD_CAPTURES
2 /
ID NAME DIRECTORY STATUS
---------- ------------------------- --------------- --------------------
1 ORCL Test Capture LOADCAPT COMPLETED
3 ORCL Test Capture 2 LOADCAPT COMPLETED
REAL APPLICATION TESTING ON 10G STEP BY STEP
43/74
Exporting AWR Data for Workload Capture
Exporting AWR data enables detailed analysis of the workload. This data is also required if you plan to run the
AWR Compare Period report on a pair of workload captures or replays.
To export AWR data, use the EXPORT_AWR procedure:
BEGIN
DBMS_WORKLOAD_CAPTURE.EXPORT_AWR (capture_id => 3);
END;
/
SQL> BEGIN
2 DBMS_WORKLOAD_CAPTURE.EXPORT_AWR (capture_id => 1);
3 END;
4 /
PL/SQL procedure successfully completed.
Check the Capture process directory and files
E:\ >CD E:\RAT_LOAD_CAPTURE
E:\RAT_LOAD_CAPTURE>dir
Volume in drive E is New Volume
Volume Serial Number is 9870-7791
Directory of E:\RAT_LOAD_CAPTURE
09/28/2008 03:30 PM <DIR> .
09/28/2008 03:30 PM <DIR> ..
REAL APPLICATION TESTING ON 10G STEP BY STEP
44/74
09/28/2008 03:21 PM 1,112 wcr_4jrvp5w0021m8.rec
09/28/2008 03:14 PM 1,125 wcr_4jrvp5w0025us.rec
09/28/2008 03:22 PM 1,400 wcr_4jrvqsn0024yw.rec
09/28/2008 03:42 PM 1,586,958,336 WCR_CA.DMP
09/28/2008 03:42 PM 29,543 wcr_ca.log
09/28/2008 03:22 PM 39,070 wcr_cr.html
09/28/2008 03:22 PM 19,720 wcr_cr.text
09/28/2008 03:22 PM 199 wcr_fcapture.wmd
09/28/2008 03:14 PM 134 wcr_scapture.wmd
9 File(s) 1,587,050,639 bytes
2 Dir(s) 4,089,331,712 bytes free
The same directory after having removed the previous files and run the 2nd Capture
E:\RAT_LOAD_CAPTURE>dir
Volume in drive E is New Volume
Volume Serial Number is 9870-7791
Directory of E:\RAT_LOAD_CAPTURE
09/28/2008 04:09 PM <DIR> .
09/28/2008 04:09 PM <DIR> ..
09/28/2008 04:03 PM 741 wcr_4jrw0r800207c.rec
09/28/2008 04:08 PM 33,280 wcr_4jrw0sc00258n.rec
09/28/2008 04:04 PM 733 wcr_4jrw0y0002074.rec
09/28/2008 04:04 PM 733 wcr_4jrw0y00020mw.rec
09/28/2008 04:04 PM 733 wcr_4jrw0y00020t0.rec
09/28/2008 04:04 PM 734 wcr_4jrw0y00021zc.rec
09/28/2008 04:04 PM 734 wcr_4jrw0y000248s.rec
09/28/2008 04:04 PM 734 wcr_4jrw0y00024q8.rec
09/28/2008 04:04 PM 734 wcr_4jrw0y00024rs.rec
09/28/2008 04:04 PM 733 wcr_4jrw0y00025j4.rec
09/28/2008 04:04 PM 733 wcr_4jrw0y00025r0.rec
09/28/2008 04:04 PM 67 wcr_4jrw0yc0020nh.rec
REAL APPLICATION TESTING ON 10G STEP BY STEP
45/74
09/28/2008 04:04 PM 68 wcr_4jrw0yc00225c.rec
09/28/2008 04:04 PM 68 wcr_4jrw0yc0024bh.rec
09/28/2008 04:05 PM 68 wcr_4jrw15w0021z0.rec
09/28/2008 04:05 PM 68 wcr_4jrw15w0024a4.rec
09/28/2008 04:05 PM 68 wcr_4jrw15w0024rn.rec
09/28/2008 04:06 PM 68 wcr_4jrw1dc0021zn.rec
09/28/2008 04:06 PM 68 wcr_4jrw1dc0022q0.rec
09/28/2008 04:06 PM 68 wcr_4jrw1dc0024qh.rec
09/28/2008 04:07 PM 68 wcr_4jrw1nw002100.rec
09/28/2008 04:07 PM 68 wcr_4jrw1nw0024n0.rec
09/28/2008 04:07 PM 68 wcr_4jrw1nw0025sn.rec
09/28/2008 04:08 PM 67 wcr_4jrw1wc0020p4.rec
09/28/2008 04:08 PM 68 wcr_4jrw1wc0021bh.rec
09/28/2008 04:08 PM 68 wcr_4jrw1wc0025yc.rec
09/28/2008 04:09 PM 983 wcr_4jrw1zc0022sh.rec
09/28/2008 04:09 PM 38,582 wcr_cr.html
09/28/2008 04:09 PM 19,376 wcr_cr.text
09/28/2008 04:09 PM 203 wcr_fcapture.wmd
09/28/2008 04:03 PM 136 wcr_scapture.wmd
31 File(s) 100,920 bytes
2 Dir(s) 5,676,171,264 bytes free
After completing the run gather awr statistics
BEGIN
DBMS_WORKLOAD_CAPTURE.EXPORT_AWR (capture_id => 3);
END;
/
16:20:35 SQL> BEGIN
16:20:42 2 DBMS_WORKLOAD_CAPTURE.EXPORT_AWR (capture_id => 3);
16:20:42 3 END;
16:20:42 4 /
REAL APPLICATION TESTING ON 10G STEP BY STEP
46/74
PL/SQL procedure successfully completed.
Elapsed: 00:14:32.87
The export_awr generated this file on the capture directory for capture_id 3:
09/28/2008 04:35 PM 1,588,432,896 WCR_CA.DMP
Generating a Workload Capture Report Using APIs
Before applying the captured workload it is convenient to check it. To do that we use the workload capture report
that contains captured workload statistics, information about the top session activities that were captured, and any
workload filters used during the capture process.
To generate a report on the latest workload capture, use the
DBMS_WORKLOAD_CAPTURE.GET_CAPTURE_INFO procedure and the
DBMS_WORKLOAD_CAPTURE.REPORT function:
DECLARE
cap_id NUMBER;
cap_rpt CLOB;
BEGIN
cap_id := DBMS_WORKLOAD_CAPTURE.GET_CAPTURE_INFO(dir => 'LOADCAPT');
cap_rpt := DBMS_WORKLOAD_CAPTURE.REPORT(capture_id => 3,
format => DBMS_WORKLOAD_CAPTURE.TYPE_TEXT);
END;
/
REAL APPLICATION TESTING ON 10G STEP BY STEP
47/74
Workload Preprocessing
Once the workload has been captured, the information in the capture files need to be preprocessed.
Preprocessing creates all necessary metadata needed for replaying the workload.
This must be done once for every captured workload before they can be replayed.
After the captured workload is preprocessed, it can be replayed repeatedly on a replay system running the same
version of Oracle Database.
On the 11g database create a directory pointing to the directory where the capture load files are located
create or replace directory LOADCAPT as 'E:\RAT_LOAD_CAPTURE';
grant read , write on directory LOADCAPT to public;
SQL> EXEC DBMS_WORKLOAD_REPLAY.PROCESS_CAPTURE(capture_dir=>'LOADCAPT');
PL/SQL procedure successfully completed.
Workload Replay
Workload reply has the following stages:
Setting Up the Test System: You need to prepare the database to replay, usually you will make a backup of the
database where the originated workload was captured, and upgrade it or migrate it to match the new scenario.
On this case Im using an export from the 10g database and import on the 11g database:
Export file: EXPDAT.DMP > avargas.dmp
REAL APPLICATION TESTING ON 10G STEP BY STEP
48/74
(1)E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 2
Export grants (yes/no): yes >
Export table data (yes/no): yes >
Compress extents (yes/no): yes >
Export done in IW8ISO8859P8 character set and AL16UTF16 NCHAR character set
About to export specified users ...
User to be exported: (RETURN to quit) > avargas
User to be exported: (RETURN to quit) >
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user AVARGAS
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user AVARGAS
About to export AVARGAS's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export AVARGAS's tables via Conventional Path ...
. . exporting table TEST1 562461 rows exported
. . exporting table TEST2 0 rows exported
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
REAL APPLICATION TESTING ON 10G STEP BY STEP
49/74
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.
On 11g:
SQL> CREATE TABLESPACE AVTEST ;
Tablespace created.
SQL> CREATE USER AVARGAS IDENTIFIED BY ORACLE DEFAULT TABLESPACE AVTEST TEMPORARY TABLESPACE
TEMP;
User created.
SQL> GRANT DBA, ALL PRIVILEGES TO AVARGAS;
Grant succeeded.
E:\RAT_LOAD_CAPTURE>imp avargas
Import: Release 11.1.0.6.0 - Production on Thu Oct 2 12:34:27 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Password:
Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Import file: EXPDAT.DMP > avargas.dmp
Enter insert buffer size (minimum is 8192) 30720>
Export file created by EXPORT:V10.02.01 via conventional path
import done in IW8MSWIN1255 character set and AL16UTF16 NCHAR character set
import server uses IW8ISO8859P8 character set (possible charset conversion)
export client uses IW8ISO8859P8 character set (possible charset conversion)
List contents of import file only (yes/no): no >
Ignore create error due to object existence (yes/no): no >
Import grants (yes/no): yes >
Import table data (yes/no): yes >
Import entire export file (yes/no): no > yes
. importing AVARGAS's objects into AVARGAS
REAL APPLICATION TESTING ON 10G STEP BY STEP
50/74
. . importing table "TEST1" 562461 rows imported
. . importing table "TEST2" 0 rows imported
Import terminated successfully without warnings.
Steps for Replaying a Database Workload
Replay is implemented invoking the wrc utility from the 11g $ORACLE_HOME/bin directory.
First we run it using the calibrate option, that provide information on the captured load that we can use to execute
the replay:
E:\RAT_LOAD_CAPTURE>d:
D:\ORACLE\11g\db11g\BIN>cd D:\ORACLE\11g\db11g\bin
D:\ORACLE\11g\db11g\BIN>wrc mode=calibrate replaydir=E:\RAT_LOAD_CAPTURE
Workload Replay Client: Release 11.1.0.6.0 - Production on Thu Oct 2 12:45:27 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Report for Workload in: E:\RAT_LOAD_CAPTURE
-----------------------
Recommendation:
Consider using at least 1 clients divided among 1 CPU(s).
Workload Characteristics:
- max concurrency: 1 sessions
- total number of sessions: 1
Assumptions:
- 1 client process per 50 concurrent sessions
- 4 client process per CPU
- think time scale = 100
- connect time scale = 100
REAL APPLICATION TESTING ON 10G STEP BY STEP
51/74
- synchronization = TRUE
Prepare the Replay Database
Before actually replaying the load we need to prepare the replay database
BEGIN
DBMS_WORKLOAD_REPLAY.initialize_replay (
replay_name => AVTEST_REPLAY',
replay_dir => 'LOADCAPT');
DBMS_WORKLOAD_REPLAY.prepare_replay (
synchronization => TRUE);
END;
/
SQL> BEGIN
2 DBMS_WORKLOAD_REPLAY.initialize_replay (
3 replay_name => 'AVTEST_REPLAY',
4 replay_dir => 'LOADCAPT');
5 DBMS_WORKLOAD_REPLAY.prepare_replay (
6 synchronization => TRUE);
7 END;
8 /
PL/SQL procedure successfully completed.
Execute the Replay Database
Now we can execute the wrc utility to run the load:
D:\ORACLE\11g\db11g\BIN>wrc avargas/ORACLE@REALAPT mode=replay replaydir=E:\RAT_LOAD_CAPTURE
REAL APPLICATION TESTING ON 10G STEP BY STEP
52/74
Workload Replay Client: Release 11.1.0.6.0 - Production on Thu Oct 2 13:12:10 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Wait for the replay to start (13:12:10)
Left this window open and open a new window for the next step
From within sqlplus start the replay
To actually start the replay we need to execute DBMS_WORKLOAD_REPLAY.start_replay from within sqlplus
BEGIN
DBMS_WORKLOAD_REPLAY.start_replay;
END;
/
E:\RAT_LOAD_CAPTURE>sqlplus / as sysdba
SQL> BEGIN
2 DBMS_WORKLOAD_REPLAY.start_replay;
3 END;
4 /
PL/SQL procedure successfully completed.
The wrc utility will show that replay started
D:\ORACLE\11g\db11g\BIN>wrc avargas/ORACLE@REALAPT mode=replay replaydir=E:\RAT_LOAD_CAPTURE
Workload Replay Client: Release 11.1.0.6.0 - Production on Thu Oct 2 13:12:10 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Wait for the replay to start (13:12:10)
Replay started (13:15:46)
Replay finished (13:23:02)
REAL APPLICATION TESTING ON 10G STEP BY STEP
53/74
Once the replay finish we can analyze its performance
SQL> COLUMN name FORMAT A20
SQL> SELECT id, name FROM dba_workload_replays;
ID NAME
---------- --------------------
1 AVTEST_REPLAY
DECLARE
l_report CLOB;
BEGIN
l_report := DBMS_WORKLOAD_REPLAY.report(replay_id => 1, format =>
DBMS_WORKLOAD_REPLAY.TYPE_HTML);
END;
/
SQL> DECLARE
2 l_report CLOB;
3 BEGIN
4 l_report:= DBMS_WORKLOAD_REPLAY.report(replay_id => 1, format =>
DBMS_WORKLOAD_REPLAY.TYPE_HTML);
5 END;
6 /
PL/SQL procedure successfully completed.
It is possible to check the awr reports the replay span to further check replay performance
SQL> col name for a20
SQL> l
1* select id,name,AWR_BEGIN_SNAP,AWR_END_SNAP from DBA_WORKLOAD_REPLAYS
SQL> /
REAL APPLICATION TESTING ON 10G STEP BY STEP
54/74
ID NAME AWR_BEGIN_SNAP AWR_END_SNAP
---------- -------------------- -------------- ------------
1 AVTEST_REPLAY 167 168
SQL> @?/rdbms/admin/awrrpt
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
3981543668 REALAPT 1 realapt
Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
Would you like an HTML report, or a plain text report?
Enter 'html' for an HTML report, or 'text' for plain text
Defaults to 'html'
Enter value for report_type: text
Type Specified: text
...
...
End of Report
Report written to awrrpt_1_167_168.txt
REAL APPLICATION TESTING ON 10G STEP BY STEP
55/74
SQL Performance Analyzer
SQL Performance Analyzer Workflow Steps
Capture the SQL workload: Capture the set of SQL statements in a SQL Tuning Set (STS)
Measure the performance of the workload before the change: SQL Performance Analyzer executes the SQL
statements captured in the SQL Tuning Set and generates execution plans and execution statistics for each
statement.
Make a change: Make the change whose effect on SQL performance you intend to measure. SQL Performance
Analyzer can analyze the effect of many types of system changes. For example, you can test a database upgrade,
new index creation, initialization parameter changes, optimizer statistics refresh, and so on.
Measure the performance of the workload after the change: After you have made the planned change, SQL
Performance Analyzer re-executes the SQL statements and produces execution plans and execution statistics for
each SQL statement a second time. This execution result represents a new set of performance data that SQL
Performance Analyzer uses for subsequent comparison.
Compare performance: Compares the performance of SQL statements before and after the change and produce
a report identifying any changes in execution plans or performance of the SQL statements.
Capture the SQL workload using APIs
To capture the SQL workload we use the DBMS_SQLPA package
REAL APPLICATION TESTING ON 10G STEP BY STEP
56/74
Main Functions of the DBMS_SQLPA Package
Function Purpose
CREATE_ANALYSIS_TASK Create a SQL Performance Analyzer task to process and
analyze a SQL Tuning Set
SET_ANALYSIS_TASK_PARAMETER Set a SQL analysis task parameter value
EXECUTE_ANALYSIS_TASK Run a previously created task
DROP_ANALYSIS_TASK Drop a task, deleting all performance data
REPORT_ANALYSIS_TASK Generate a report of analysis task results
Create An Empty Sql Tuning Set To Be Populated With Some Load
BEGIN
DBMS_SQLTUNE.CREATE_SQLSET(
sqlset_name => 'RATSQLATEST',
description => 'RAT SQL Analyzer Test');
END;
/
SQL> BEGIN
2 DBMS_SQLTUNE.CREATE_SQLSET(
3 sqlset_name => 'RATSQLATEST',
4 description => 'RAT SQL Analyzer Test');
5 END;
6 /
PL/SQL procedure successfully completed.
Load SQL Statements on the STS
First we can create a simulated load, i.e.:
REAL APPLICATION TESTING ON 10G STEP BY STEP
57/74
E:\RAT_SQL_ANALYZE>sqlplus avargas/oracle
SQL> @runload
Table truncated.
678266 rows created.
236 rows created.
678266 rows deleted.
Commit complete.
That keeps running in a cycle for a while, and then we check the snapshot ids and create a new AWR
snapshot
EXEC dbms_workload_repository.create_snapshot;
SQL> EXEC dbms_workload_repository.create_snapshot;
PL/SQL procedure successfully completed.
Now we get the last snapshot_ids and use them to gather the sql statement
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
ORCL ORCL 17388 02 Oct 2008 15:00 1
17389 02 Oct 2008 15:12 1
The LOAD_SQLSET procedure populates the STS with selected SQL statements. An STS can be loaded from
statements coming from the workload repository, another STS, or the cursor cache.
For both the workload repository and STS, predefined table functions can be used to select columns from the
source to populate a new STS.
REAL APPLICATION TESTING ON 10G STEP BY STEP
58/74
In the following example, procedure calls are used to load 'RATSQLATEST' from AWR reports.
The data has been filtered to select only the top 30 SQL statements.
First a ref cursor is opened to select from the specified AWR reports. Next the statements and their statistics are
loaded into the STS.
FUNCTION SELECT_WORKLOAD_REPOSITORY RETURNS SQLSET
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
BEGIN_SNAP NUMBER IN
END_SNAP NUMBER IN
BASIC_FILTER VARCHAR2 IN DEFAULT
OBJECT_FILTER VARCHAR2 IN DEFAULT
RANKING_MEASURE1 VARCHAR2 IN DEFAULT
RANKING_MEASURE2 VARCHAR2 IN DEFAULT
RANKING_MEASURE3 VARCHAR2 IN DEFAULT
RESULT_PERCENTAGE NUMBER IN DEFAULT
RESULT_LIMIT NUMBER IN DEFAULT
ATTRIBUTE_LIST VARCHAR2 IN DEFAULT
DECLARE
l_cursor dbms_sqltune.sqlset_cursor;
BEGIN
OPEN l_cursor FOR
SELECT VALUE(p)
FROM TABLE (dbms_sqltune.select_workload_repository (
17388, -- begin_snap
17389, -- end_snap
NULL, -- basic_filter
NULL, -- object_filter
NULL, -- ranking_measure1
REAL APPLICATION TESTING ON 10G STEP BY STEP
59/74
NULL, -- ranking_measure2
NULL, -- ranking_measure3
NULL, -- result_percentage
30)) p; -- result_limit
dbms_sqltune.load_sqlset (sqlset_name =>
'RATSQLATEST', populate_cursor => l_cursor);
END;
/
SQL> DECLARE
2 l_cursor dbms_sqltune.sqlset_cursor;
3 BEGIN
4 OPEN l_cursor FOR
5 SELECT VALUE(p)
6 FROM TABLE (dbms_sqltune.select_workload_repository (
7 17388, -- begin_snap
8 17389, -- end_snap
9 NULL, -- basic_filter
10 NULL, -- object_filter
11 NULL, -- ranking_measure1
12 NULL, -- ranking_measure2
13 NULL, -- ranking_measure3
14 NULL, -- result_percentage
15 30)) p; -- result_limit
16
17 dbms_sqltune.load_sqlset (sqlset_name =>
18 'RATSQLATEST', populate_cursor => l_cursor);
19 END;
20 /
PL/SQL procedure successfully completed.
REAL APPLICATION TESTING ON 10G STEP BY STEP
60/74
Displaying the Contents of a SQL Tuning Set
The SELECT_SQLSET table function reads the contents of the STS. After an STS has been created and
populated, you can browse the SQL in the STS using different filtering criteria.
The SELECT_SQLSET procedure is provided for this purpose.
In the following example, the SQL statements in the STS are displayed for statements with a disk-reads to buffer-
gets ratio greater than or equal to 75%.
SELECT * FROM TABLE(DBMS_SQLTUNE.SELECT_SQLSET('RATSQLATEST'));
SQL> SELECT * FROM TABLE(DBMS_SQLTUNE.SELECT_SQLSET('RATSQLATEST'));
SQL_ID FORCE_MATCHING_SIGNATURE SQL_TEXT
------------- ------------------------ ----------------------------
OBJECT_LIST
--------------------------------------------------------------------------------------------
---------------------
BIND_DATA
--------------------------------------------------------------------------------------------
---------------------
PARSING_SCHEMA_NAME MODULE ACTION
ELAPSED_TIME CPU_TIME BUFFER_GETS DISK_READS DIRECT_W
RITES ROWS_PROCESSED FETCHES
------------------------------ ------------------------------------------------ ------------
--------------------
EXECUTIONS END_OF_FETCH_COUNT OPTIMIZER_COST
---------- ------------------ --------------
OPTIMIZER_ENV
--------------------------------------------------------------------------------------------
---------------------
REAL APPLICATION TESTING ON 10G STEP BY STEP
61/74
PRIORITY COMMAND_TYPE FIRST_LOAD_TIME STAT_PERIOD ACTIVE_STAT_PERIOD OTHER
PLAN_HASH_VA
LUE
---------- ------------ ------------------- ----------- ------------------ -----------------
---------------------
SQL_PLAN(STATEMENT_ID, PLAN_ID, TIMESTAMP, REMARKS, OPERATION, OPTIONS, OBJECT_NODE,
OBJECT_OWNER, OBJECT_NAME, OBJECT_ALIAS, OBJECT_INSTANCE, OBJECT_TYPE, OPTI
MIZER, SEARCH_COLUMNS, ID, PARENT_ID, DE
--------------------------------------------------------------------------------------------
---------------------
BIND_LIST()
--------------------------------------------------------------------------------------------
---------------------
fsda22kwya1gu 8.1404E+18 delete from test2
AVARGAS SQL*Plus
61499 61499 5434 0
0 4720 0
20 20 2
E289FB89A3E49800C4001000AEF9C3E2CFFA332056414555519521105555551545545558591555449665851D5511
058555155515152552455580185AA3E4980005040200000200000010000000010000
2000000210D007000000D0070000200300010100
0038F8000200000090010000E80300A3E4980004656464020264320
7
1562589
875
8ypwcums111db 3.1389E+18 select distinct
(case when cd.dbid = wr.dbid and
cd.nam
REAL APPLICATION TESTING ON 10G STEP BY STEP
62/74
SYS sqlplus.exe
859382 15806 37 12
0 2 2
1 1 335
E289FB89A3E49800C4001000AEF9C3E2CFFA332056414555519521105555551545545558591555449665851D5511
058555155515152552455580185AA3E4980005040200000200000010000000010000
2000000210D007000000D0070000200300010100
0038F8000200000090010000E80300A3E4980004656464020264320
3
3511428
958
3xpsk5cub3nvc 1.8204E+19 delete from test1
AVARGAS SQL*Plus
276172192 140496807 15409663 16
0 13565320 0
20 20 2669
E289FB89A3E49800C4001000AEF9C3E2CFFA332056414555519521105555551545545558591555449665851D5511
058555155515152552455580185AA3E4980005040200000200000010000000010000
2000000210D007000000D0070000200300010100
Additional details of the SQL Tuning Sets that have been created and loaded can also be displayed with DBA
views, such as DBA_SQLSET, DBA_SQLSET_STATEMENTS, and DBA_SQLSET_BINDS.
REAL APPLICATION TESTING ON 10G STEP BY STEP
63/74
Transporting a SQL Tuning Set
SQL Tuning Sets can be transported to another system by first exporting the Sql Tuning Set (STS) from one
system to a staging table, then importing the STS from the staging table into another system.
To transport a SQL Tuning Set:
Use the CREATE_STGTAB_SQLSET procedure to create a staging table where the SQL Tuning Sets will be
exported.
BEGIN
DBMS_SQLTUNE.CREATE_STGTAB_SQLSET( table_name => 'RAT_SQLANL_TAB' );
END;
/
SQL> BEGIN
2 DBMS_SQLTUNE.CREATE_STGTAB_SQLSET( table_name => 'RAT_SQLANL_TAB' );
3 END;
4 /
PL/SQL procedure successfully completed.
Use the PACK_STGTAB_SQLSET procedure to export SQL Tuning Sets into the staging table.
BEGIN
DBMS_SQLTUNE.PACK_STGTAB_SQLSET(
sqlset_name => 'RATSQLATEST',
staging_table_name =>'RAT_SQLANL_TAB');
END;
/
REAL APPLICATION TESTING ON 10G STEP BY STEP
64/74
SQL> BEGIN
2 DBMS_SQLTUNE.PACK_STGTAB_SQLSET(
3 sqlset_name => 'RATSQLATEST',
4 staging_table_name =>'RAT_SQLANL_TAB');
5 END;
6 /
PL/SQL procedure successfully completed.
Transport The Load Table To The Test System
E:\RAT_SQL_ANALYZE>exp 'sys as sysdba'
Export: Release 10.2.0.3.0 - Production on Thu Oct 2 15:58:02 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Password:
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Enter array fetch buffer size: 4096 >
Export file: EXPDAT.DMP > ratsqlanl.dmp
(1)E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 3
Export table data (yes/no): yes >
Compress extents (yes/no): yes >
Export done in IW8ISO8859P8 character set and AL16UTF16 NCHAR character set
REAL APPLICATION TESTING ON 10G STEP BY STEP
65/74
About to export specified tables via Conventional Path ...
Table(T) or Partition(T:P) to be exported: (RETURN to quit) > RAT_SQLANL_TAB
. . exporting table RAT_SQLANL_TAB 30 rows exported
. . exporting table RAT_SQLANL_TAB_CBINDS 0 rows exported
. . exporting table RAT_SQLANL_TAB_CPLANS 0 rows exported
Table(T) or Partition(T:P) to be exported: (RETURN to quit) >
Export terminated successfully without warnings.
FTP the table to the test system
C:\Documents and Settings >dir
Volume in drive C has no label.
Volume Serial Number is C49B-DFB9
Directory of C:\Documents and Settings
07/20/2008 11:29 AM <DIR> .
07/20/2008 11:29 AM <DIR> ..
10/02/2008 03:59 PM 79,872 ratsqlanl.dmp
3 File(s) 84,385 bytes
6 Dir(s) 6,144,704,512 bytes free
C:\Documents and Settings >ftp linux
Connected to linux
220 (vsFTPd 1.2.1)
User (linux:(none)): oracle
331 Please specify the password.
Password:
230 Login successful.
ftp> bin
REAL APPLICATION TESTING ON 10G STEP BY STEP
66/74
200 Switching to Binary mode.
ftp> put ratsqlanl.dmp
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 79872 bytes sent in 0.00Seconds 79872000.00Kbytes/sec.
On the system where the SQL Tuning Sets will be imported, use the UNPACK_STGTAB_SQLSET procedure to
import SQL Tuning Sets from the staging table.
linux /home/oracle> ls -ltr *dmp
-rw-r--r-- 1 oracle oinstall 79872 2008-10-02 16:05 ratsqlanl.dmp
linux /home/oracle> imp
Import: Release 10.2.0.3.0 - Production on Thu Oct 2 16:10:50 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Username: sys as sysdba
Password:
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Import file: expdat.dmp > ratsqlanl.dmp
...
...
...
" scale NUMBER, /* bind sca"
"le */"
" max_length NUMBER, /* maximum bind leng"
"th */"
REAL APPLICATION TESTING ON 10G STEP BY STEP
67/74
" last_captured DATE, /* DATE when this bind variable was captur"
"ed */"
" value_string VARCHAR2(4000), /* bind value (text representatio"
"n) */"
" value_anydata ANYDATA) /* bind value (anydata representatio"
"n) */"
IMP-00015: following statement failed because the object already exists:
"CREATE TYPE "SQL_BIND_SET" TIMESTAMP '2007-07-16:18:42:06' OID '00000000000"
"000000000000000020214' "
" AS T"
"ABLE OF sql_bind"
. . importing table "RAT_SQLANL_TAB" 30 rows imported
. . importing table "RAT_SQLANL_TAB_CBINDS" 0 rows imported
. . importing table "RAT_SQLANL_TAB_CPLANS" 0 rows imported
Import terminated successfully with warnings.
BEGIN
DBMS_SQLTUNE.UNPACK_STGTAB_SQLSET(
sqlset_name => '%',
replace => TRUE,
staging_table_name => 'RAT_SQLANL_TAB');
END;
/
REAL APPLICATION TESTING ON 10G STEP BY STEP
68/74
Unpack the STS Into the Test System
SQL*Plus: Release 10.2.0.3.0 - Production on Thu Oct 2 16:12:24 2008
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL > BEGIN
DBMS_SQLTUNE.UNPACK_STGTAB_SQLSET(
sqlset_name => '%',
replace => TRUE,
staging_table_name => 'RAT_SQLANL_TAB');
END;
/
PL/SQL procedure successfully completed.
Prepare the test database to run the load
Prepare The Test System
SQL > CREATE TABLESPACE AVTEST ;
Tablespace created.
SQL > CREATE USER AVARGAS IDENTIFIED BY ORACLE DEFAULT TABLESPACE AVTEST TEMPORARY
TABLESPACE TEMP;
REAL APPLICATION TESTING ON 10G STEP BY STEP
69/74
User created.
SQL > GRANT DBA, ALL PRIVILEGES TO AVARGAS;
Grant succeeded.
SQL > connect avargas/oracle
Connected.
SQL > create table test1 as select * from dba_source where 1=2;
Table created.
SQL > create table test2 as select * from dba_users where 1=2;
Table created.
Creating a SQL Performance Analyzer Task
The next stage is to run the load on the target database.
For this purpose we need to create an SQL Performance Analyzer task by using the
DBMS_SQLPA.CREATE_ANALYSIS_TASK function.
The CREATE_ANALYSIS_TASK function use the following parameters:
task_name specify an optional name for the SQL Performance Analyzer task.
sqlset_name the name of the SQL Tuning Set.
sqlset_owner the owner of the SQL Tuning Set. The default is the current schema owner.
basic_filter the SQL predicate used to filter the SQL from the SQL Tuning Set.
order_by specify an order-by clause on the selected SQL.
REAL APPLICATION TESTING ON 10G STEP BY STEP
70/74
top_sql consider only the top number of SQL statements after filtering and ranking.
VARIABLE sts_task VARCHAR2(100);
EXEC :sts_task := DBMS_SQLPA.CREATE_ANALYSIS_TASK( -
sqlset_name => 'RATSQLATEST', -
description => 'process test workload');
SQL> VARIABLE sts_task VARCHAR2(100);
SQL> EXEC :sts_task := DBMS_SQLPA.CREATE_ANALYSIS_TASK( -
> sqlset_name => 'RATSQLATEST', -
> task_name => 'RAT_SQLANL', -
> description => 'process test workload');
PL/SQL procedure successfully completed.
Executing the SQL Workload Before a Change
Once the analysis task was created we can execute it
These are guidelines to setup the DBMS_SQLPA.EXECUTE_ANALYSIS_TASK execution:
Set the task_name parameter to the name of the SQL Performance Analyzer task that you want to execute.
Set the execution_type parameter in either of the following ways:
Set to EXPLAIN PLAN to generate execution plans for all SQL statements in the SQL Tuning Set without
executing them.
Set to TEST EXECUTE (recommended) to execute all statements in the SQL Tuning Set and generate
their execution plans and statistics. When TEST EXECUTE is specified, the procedure generates
execution plans and execution statistics. The execution statistics enable SQL Performance Analyzer to
REAL APPLICATION TESTING ON 10G STEP BY STEP
71/74
identify SQL statements that have improved or regressed. Collecting execution statistics in addition to
generating execution plans provides greater accuracy in the performance analysis, but takes longer.
Specify a name to identify the execution using the execution_name parameter. If not specified, then SQL
Performance Analyzer automatically generates a name for the task execution.
Specify execution parameters using the execution_params parameters. The execution_params parameters are
specified as (name, value) pairs for the specified execution. For example, you can set the following execution
parameters:
The time_limit parameter specifies the global time limit to process all SQL statements in a SQL Tuning Set
before timing out.
The local_time_limit parameter specifies the time limit to process each SQL statement in a SQL Tuning Set
before timing out.
EXEC DBMS_SQLPA.EXECUTE_ANALYSIS_TASK(task_name => 'RAT_SQLANL', -
execution_type => 'TEST EXECUTE', -
execution_name => 'my_exec_BEFORE_change');
SQL> EXEC DBMS_SQLPA.EXECUTE_ANALYSIS_TASK(task_name => 'RAT_SQLANL', -
> execution_type => 'TEST EXECUTE', -
> execution_name => 'my_exec_BEFORE_change');
PL/SQL procedure successfully completed.
New analysis can be generated and comparison reports can be generated using
DBMS_SQLPA.REPORT_ANALYSIS_TASK
REAL APPLICATION TESTING ON 10G STEP BY STEP
72/74
Generate an Report with Analysis Of Task Results
SELECT DBMS_SQLPA.REPORT_ANALYSIS_TASK(:sts_task, 'TEXT', 'TYPICAL', 'SUMMARY')
FROM DUAL;
SQL> set pages 50000 lines 200 long 50000
SQL> SELECT DBMS_SQLPA.REPORT_ANALYSIS_TASK('RAT_SQLANL', 'TEXT', 'TYPICAL', 'SUMMARY') from
dual;
DBMS_SQLPA.REPORT_ANALYSIS_TASK('RAT_SQLANL','TEXT','TYPICAL','SUMMARY')
--------------------------------------------------------------------------------
GENERAL INFORMATION SECTION
-------------------------------------------------------------------------------
Tuning Task Name : RAT_SQLANL
Tuning Task Owner : SYS
Workload Type : SQL Tuning Set
Execution Count : 1
Current Execution : my_exec_BEFORE_change
Execution Type : TEST EXECUTE
Scope : COMPREHENSIVE
Completion Status : COMPLETED
Started at : 10/02/2008 17:39:36
Completed at : 10/02/2008 17:39:52
SQL Tuning Set (STS) Name : RATSQLATEST
SQL Tuning Set Owner : SYS
Number of Statements in the STS : 29
Number of SQLs Analyzed : 29
Number of SQLs in the Report : 29
Number of SQLs with Findings : 2
Number of SQLs with Errors : 1
-------------------------------------------------------------------------------
SUMMARY SECTION
REAL APPLICATION TESTING ON 10G STEP BY STEP
73/74
-------------------------------------------------------------------------------
SQL Statements Ordered by Elapsed Time
-------------------------------------------------------------------------------
Parse Elapsed CPU Buffer Optimizer
object ID SQL ID Time (s) Time (s) Time (s) Gets Cost
---------- ------------- -------- -------- -------- -------- ---------
27 frvhw30vv4z2t .073 6.206 1.781 17609 1324
9 3xpsk5cub3nvc 0 5.149 .578 20867 3297
29 g337099aatnuj .029 1.29 .015 492 103
3 0j80bq6arfp1h 0 .261 .015 208 59
23 bunssq950snhf .05 .182 .125 170 0
10 47a50dvdgnxc2 .059 .122 0 91 1
15 84qubbrsr0kfn .003 .107 0 251 1
16 88cwftrsh6rjb .02 .067 .015 119 1
25 d8mayxqw0wnpv .184 .043 0 149 29
7 31a13pnjps7j3 .029 .015 0 36 28
12 4t21k5qn4rwpb .125 .013 0 2 9
17 8ypwcums111db .022 .011 0 7 16
5 1gu8t96d0bdmu .033 .01 0 2 2
18 9410b66vr6543 .047 .01 0 2 7
6 2q93zsrvbdw48 0 .009 0 3 4
28 fsda22kwya1gu 0 .008 0 3 2
11 4g4k54qrsawn6 .017 .007 0 2 4
13 6aq34nj2zb2n7 0 .005 0 2 4
19 9g485acn2n30m .021 .002 0 1 2
20 aq8yqxyyb40nn 0 .001 0 1 1
2 04xtrk7uyhknh 0 0 0 3 4
14 6hfvjdrkp32x3 .009 0 0 0 0
21 bhvyz9bgyrhb2 0 0 0 2 3
22 bsa0wjtftg3uw 0 0 0 3 2
24 c6awqs517jpj0 .022 0 0 2 3
30 gdn3ysuyssf82 0 0 0 1 1
-------------------------------------------------------------------------------
REAL APPLICATION TESTING ON 10G STEP BY STEP
74/74
Statements with Errors
-------------------------------------------------------------------------------
object ID SQL ID Error
---------- ------------- ------------------------------------------------------
26 d9zm7p74x91sn ORA-01410: invalid ROWID
-------------------------------------------------------------------------------
End of Report

Вам также может понравиться