注:提前言明 本文借鉴了以下博主、书籍或网站的内容,其列表如下:



Oracle的学习心得和知识总结(十七)|Oracle数据库Real Application Testing之重放客户端wrc工具-LMLPHP


文章快速说明索引

学习目标:

目的:接下来这段时间我想做一些兼容Oracle数据库Real Application Testing (即:RAT)上的一些功能开发,本专栏这里主要是学习以及介绍Oracle数据库功能的使用场景、原理说明和注意事项等,基于PostgreSQL数据库的功能开发等之后 由新博客进行介绍和分享!


学习内容:(详见目录)

1、Oracle数据库Real Application Testing之重放客户端wrc工具


学习时间:

2023年04月03日 21:49:57


学习产出:

1、Oracle数据库Real Application Testing之重放客户端wrc工具
2、CSDN 技术博客 1篇


注:下面我们所有的学习环境是Centos7+PostgreSQL15.0+Oracle19c+MySQL5.7

postgres=# select version();
                                   version                                   
-----------------------------------------------------------------------------
 PostgreSQL 15.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.1.0, 64-bit
(1 row)

postgres=#

#-----------------------------------------------------------------------------#

SQL> select * from v$version; 

BANNER									    BANNER_FULL 								BANNER_LEGACY									CON_ID
--------------------------------------------------------------------------- --------------------------------------------------------------------------- --------------------------------------------------------------------------- ----------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production	    Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production	Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production		     0
									    Version 19.3.0.0.0


SQL>
#-----------------------------------------------------------------------------#

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.19    |
+-----------+
1 row in set (0.06 sec)

mysql>

重放客户端的设置

重放客户端是一个多线程程序(一个名为 wrc 的可执行文件,位于 $ORACLE_HOME/bin 目录中),其中每个线程从捕获的会话中提交工作负载。在重放开始之前,数据库将等待重放客户端连接。此时,您需要设置并启动重放客户端,它将连接到重放系统并根据工作负载中捕获的内容发送请求。

[oracle@dbserver bin]$ pwd
/home/oracle/oracle19c/product/19c/dbhome_1/bin
[oracle@dbserver bin]$ 
[oracle@dbserver bin]$ ll wrc 
-rwxr-x--x. 1 oracle oracle 750992 2月   1 2021 wrc
[oracle@dbserver bin]$
[oracle@dbserver bin]$ wrc MODE=VERSION

Workload Replay Client: Release 19.3.0.0.0 - Production on Mon Apr 3 14:36:07 2023

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.


[oracle@dbserver bin]$

在启动重放客户端之前,请确保:

  • 重放客户端软件安装在将要运行的主机上
  • 重放客户端可以访问重放目录
  • 重放目录包含预处理的工作负载捕获
  • 重放用户拥有正确的用户ID、密码和权限(重放用户需要DBA角色,不能是SYS用户)
  • 重放客户端未在运行数据库的系统上启动
  • 重放客户端在与数据库文件所在的文件系统不同的文件系统上读取捕获目录

为此,将捕获目录复制到重放客户端将运行的系统。回放完成后,您可以删除捕获目录。


满足这些先决条件后,您可以使用 wrc 可执行文件继续设置和启动重放客户端。wrc 可执行文件使用以下语法:

wrc [user/password[@server]] MODE=[value] [keyword=[value]]
  • 参数 user、password 和 server 指定用于连接到重放数据库的用户名、密码和连接字符串
  • 参数 mode 指定运行 wrc 可执行文件的模式。可能的值包括 replay(默认值)、calibrate 和 list_hosts
  • 参数关键字指定用于执行的选项,并且取决于所选的模式
  • 要显示可能的关键字及其相应的值,请运行不带任何参数的 wrc 可执行文件
[oracle@dbserver bin]$ wrc HELP=Y

Workload Replay Client: Release 19.3.0.0.0 - Production on Mon Apr 3 14:33:01 2023

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.


FORMAT:
=======
  wrc [user/password[@server]] [MODE=mode-value] KEYWORD=value

Examples:
=========
  wrc  REPLAYDIR=.
  wrc  scott/tiger@myserver REPLAYDIR=.
  wrc  MODE=calibrate REPLAYDIR=./capture
The default privileged user is: system

Mode:
=====
wrc can work in different modes to provide additional functionalities.
The default MODE is REPLAY.
-- wrc 可以在不同的模式Mode下工作以提供额外的功能。默认模式是重放

Mode        Description
----------------------------------------------------------------
REPLAY          Default mode that replays the workload in REPLAYDIR // 在 REPLAYDIR 中重放工作负载的默认模式
VERSION         Print the wrc version
CALIBRATE       Estimate the number of replay clients and CPUs // 估计在 REPLAYDIR 中重放工作负载所需的重放客户端和 CPU 的数量
                needed to replay the workload in REPLAYDIR
LIST_HOSTS      List all the hosts that participated in the capture or replay // 列出所有参与捕获或重放的主机
GET_TABLES      List all objects referenced by captured SQL statements // 列出捕获的 SQL 语句引用的所有对象

Options (listed by mode):
=========================

MODE=REPLAY (default)
---------------------

Keyword     Description
----------------------------------------------------------------
USERID      username
PASSWORD    password
SERVER      server connection identifier (Default: empty string)
REPLAYDIR   replay directory (Default:.)
WORKDIR     directory for trace files
DEBUG       ON, OFF (Default: OFF)
CONNECTION_OVERRIDE  TRUE, FALSE (Default: FALSE)
            TRUE   All replay threads will be connecting to the database // 所有重放线程都将使用 SERVER 参数连接到数据库;DBA_WORKLOAD_CONNECTION_MAP 中的设置将被忽略
                   using the SERVER parameter; the settings in
                   DBA_WORKLOAD_CONNECTION_MAP will be ignored
            FALSE  Use the settings in DBA_WORKLOAD_CONNECTION_MAP // 使用 DBA_WORKLOAD_CONNECTION_MAP 中的设置
SERIALIZE_CONNECTS  TRUE, FALSE (Default: TRUE)
            TRUE   Replay threads will be connecting to the database in a // 重放线程将以串行方式一个接一个地连接到数据库。当重放客户端使用遗留协议与数据库服务器通信时,建议使用此设置
                   serial fashion one after another. This setting is
                   recommended when the replay clients use the bequeath
                   protocol to communicate to the database server.
            FALSE  Replay threads will be connecting to the database in a // 重放线程将以模仿原始捕获行为的并发方式连接到数据库
                   concurrent fashion mimicking the original capture behavior.
DSCN_OFF    TRUE, FALSE (Default: FALSE)
            TRUE   Ignore all dependencies due to block contention during // 同步回放时忽略捕获期间由于块争用而导致的所有依赖关系
                   capture when synchronizing the replay.
            FALSE  Honor all captured dependencies. // 尊重所有捕获的依赖项
REPLACE_LITERALS   TRUE, FALSE (Default: FALSE)
            TRUE   The client will replace all captured literal binds in a // 客户端将用它们的实际值替换调用中所有捕获的文字绑定,以避免使用 CURSOR_SHARING=FORCE 捕获的工作负载出现 SQL 编译错误
                   call with their actual values to avoid SQL compilation
                   errors for workloads captured with CURSOR_SHARING=FORCE
            FALSE  Treat literal binds as regular binds // 将文字绑定视为常规绑定
CLOB_CS     overriding character set for CLOBs: // CLOB 的覆盖字符集:AL16UTF16、AL16UTF16LE、UTF16 或正数;没有默认值
            AL16UTF16, AL16UTF16LE, UTF16, or a positive number; no default.
BACKUP_CONNECTION_STRING  The fallback connection to use if during replay a // 如果在重放期间连接尝试失败,则使用回退连接;没有默认值
            connection attempt fails; no default.
WALLETDIR   single sign-on (SSO) wallet directory. (Default: empty string) // 单点登录 (SSO) 钱包目录。(默认值:空字符串)


MODE=VERSION
------------
Print the wrc version


MODE=CALIBRATE
--------------
Provide an estimate of the number of replay clients needed // 提供所需重放客户端数量的估计值

Keyword     Description
----------------------------------------------------------------
REPLAYDIR   replay directory (Default:.)

Advanced parameters:
PROCESSES_PER_CPU     Maximum number of client processes than can be run // 每个 CPU 可以运行的最大客户端进程数(默认值:4)
                      per CPU (Default: 4)
THREADS_PER_PROCESS   Maximum number of threads than can be run within // 客户端进程中可以运行的最大线程数(默认值:100)
                      a client process (Default: 100)


MODE=LIST_HOSTS
---------------
Display all host names involved in the capture // 显示所有参与抓包的主机名

Keyword     Description
----------------------------------------------------------------
REPLAYDIR   the workload directory (Default:.)


MODE=GET_TABLES
---------------
List all objects referenced by captured SQL statements // 列出捕获的 SQL 语句引用的所有对象

Keyword     Description
----------------------------------------------------------------
REPLAYDIR   the workload directory (Default:.)

Default trace path: /home/oracle/oracle19c/diag/clients/user_oracle/host_2882156376_110/trace

[oracle@dbserver bin]$

以下部分描述了您在运行 wrc 可执行文件时可以选择的模式:

校准重放客户端

由于一个重放客户端可以启动与数据库的多个会话,因此没有必要为每个捕获的会话启动一个重放客户端。需要启动的重放客户端数量取决于工作负载流的数量、主机数量以及每个主机的重放客户端数量。

要估计重放特定工作负载所需的重放客户端和主机的数量,请在校准模式下运行 wrc 可执行文件。

在校准模式下,wrc 可执行文件接受以下关键字:

  • replaydir 指定包含要重放的预处理工作负载捕获的目录。如果未指定,则默认为当前目录
  • process_per_cpu 指定每个 CPU 可以运行的最大客户端进程数。默认值为 4
  • threads_per_process 指定可以在客户端进程中运行的最大线程数。默认值为 50

以下示例显示了如何在校准模式下运行 wrc 可执行文件:

%> wrc mode=calibrate replaydir=./replay

在此示例中,执行 wrc 可执行文件以估计重放存储在当前目录下名为 replay 的子目录中的工作负载捕获所需的重放客户端和主机的数量。在以下示例输出中,建议使用至少 1 个重放客户端,分配给 1 个 CPU:

-- 注意:这个是在 DBMS_WORKLOAD_REPLAY.process_capture 之后进行的

[oracle@dbserver bin]$ wrc mode=calibrate replaydir=/home/oracle/db_replay_capture

Workload Replay Client: Release 19.3.0.0.0 - Production on Mon Apr 3 15:25:26 2023

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.


Report for Workload in: /home/oracle/db_replay_capture
-----------------------

Recommendation:
Consider using at least 1 clients divided among 1 CPU(s)
You will need at least 3 MB of memory per client process.
If your machine(s) cannot match that number, consider using more clients.

Workload Characteristics:
- max concurrency: 1 sessions
- total number of sessions: 3

Assumptions:
- 1 client process per 100 concurrent sessions
- 4 client processes per CPU
- 256 KB of memory cache per concurrent session
- think time scale = 100
- connect time scale = 100
- synchronization = TRUE

[oracle@dbserver bin]$ 

启动重放客户端

确定重放工作负载所需的重放客户端数量后,您需要通过在安装它们的主机上以重放模式运行 wrc 可执行文件来启动重放客户端。一旦启动,每个重放客户端将启动一个或多个与数据库的会话以驱动工作负载重放。

在回放模式下,wrc 可执行文件接受以下关键字:

  1. useridpassword 指定replay 客户端的replay 用户的用户ID 和密码。 如果未指定,这些值默认为system 用户
  2. server 指定用于连接到重放系统的连接字符串。如果未指定,则该值默认为空字符串
  3. replaydir 指定包含要重放的预处理工作负载捕获的目录。如果未指定,则默认为当前目录
  4. workdir 指定将写入客户端日志的目录。此参数仅与调试参数一起用于调试目的
  5. debug 指定是否创建调试数据。可能的值包括:
  1. connection_override 指定是否覆盖存储在 DBA_WORKLOAD_CONNECTION_MAP 视图中的连接映射。如果设置为 TRUE,将忽略存储在 DBA_WORKLOAD_CONNECTION_MAP 视图中的连接重新映射,并使用使用服务器参数指定的连接字符串。如果设置为 FALSE,所有重放线程将使用存储在 DBA_WORKLOAD_CONNECTION_MAP 视图中的连接重新映射进行连接。这是默认设置
  2. walletdir 指向自动登录软件密钥库目录的位置。默认值为空字符串。walletdir 在重放加密的工作负载捕获期间是必需的。对于非加密捕获,不得设置 walletdir,它默认为空字符串
rm -rf keystore_location 
mkdir keystore_location 
mkstore -wrl keystore_location -create 
mkstore -wrl keystore_location -createEntry 'oracle.rat.database_replay.encryption' secret_key 
mkstore -wrl keystore_location -createSSO 

-- secret_key 必须与在工作负载捕获加密期间创建的服务器端软件密钥库中使用的 secret_key 相匹配

在所有重放客户端连接后,数据库将自动在所有可用的重放客户端之间分配工作负载捕获流,然后工作负载重放就可以开始了。您可以使用 V$WORKLOAD_REPLAY_THREAD 视图监视重放客户端的状态。回放结束后,所有回放客户端将自动断开连接。

示例1如下:在重放模式下运行 wrc 可执行文件以进行非加密捕获

-- 以下示例显示了如何在重放模式下运行 wrc 可执行文件:

%> wrc system/password@test mode=replay replaydir=./replay

在此示例中,wrc 可执行文件启动重放客户端以重放存储在当前目录下名为 replay 的子目录中的工作负载捕获。

如下:(在DBMS_WORKLOAD_REPLAY.prepare_replay之后) 开始进行回放,如下:

SQL> select * from V$WORKLOAD_REPLAY_THREAD;

     CLOCK NEXT_TICKER	      SID    SERIAL# SPID		      LOGON_USER														       LOGON_TIM EVENT								    EVENT_ID	 EVENT# P1TEXT									 P1 P2TEXT								     P2 P3TEXT									 P3 WAIT_FOR_SCN    FILE_ID CALL_COUNTER DEPENDENT_SCN STATEMENT_SCN COMMIT_WAIT_SCN POST_COMMIT_SCN ACTION_TYPE SESSION_TYPE	   WRC_ID SCHEDULE_CAP_ID FILE_NAME					      S D     DBTIME NETWORK_TIME THINK_TIME  TIME_GAIN  TIME_LOSS USER_CALLS PLSQL_CALLS PLSQL_SUBCALLS PLSQL_DBTIME CLIENT_OS_USER  CLIENT_HOST						       CLIENT_PID		PROGRAM 					 CAPTURE_ELAPSED_TIME REPLAY_ELAPSED_TIME     CON_ID
---------- ----------- ---------- ---------- ------------------------ -------------------------------------------------------------------------------------------------------------------------------- --------- ---------------------------------------------------------------- ---------- ---------- ---------------------------------------------------------------- ---------- ---------------------------------------------------------------- ---------- ---------------------------------------------------------------- ---------- ------------ ---------- ------------ ------------- ------------- --------------- --------------- ----------- ------------- ---------- --------------- --------------------------------------------------- - - ---------- ------------ ---------- ---------- ---------- ---------- ----------- -------------- ------------ --------------- ---------------------------------------------------------------- ------------------------ ------------------------------------------------ -------------------- ------------------- ----------
	 0	     0	      134      11792 6930		      SYSTEM															       03-APR-23 WCR: replay client notify					   277762365	    508 who am I								  1									      0 									  0	       0	  0	       0	     0		   0		   0		   0	       0 LOGON	       4294967295		0						      N 	   0		0	   0	      0 	 0	    0		0	       0	    0 oracle	      dbserver							       6929			wrc@dbserver (TNS V1-V3)					    0			0	   0

SQL>

Oracle的学习心得和知识总结(十七)|Oracle数据库Real Application Testing之重放客户端wrc工具-LMLPHP


SQL> exec DBMS_WORKLOAD_REPLAY.START_REPLAY ();

PL/SQL procedure successfully completed.

SQL> select * from V$WORKLOAD_REPLAY_THREAD;

     CLOCK NEXT_TICKER	      SID    SERIAL# SPID		      LOGON_USER														       LOGON_TIM EVENT								    EVENT_ID	 EVENT# P1TEXT									 P1 P2TEXT								     P2 P3TEXT									 P3 WAIT_FOR_SCN    FILE_ID CALL_COUNTER DEPENDENT_SCN STATEMENT_SCN COMMIT_WAIT_SCN POST_COMMIT_SCN ACTION_TYPE SESSION_TYPE	   WRC_ID SCHEDULE_CAP_ID FILE_NAME					      S D     DBTIME NETWORK_TIME THINK_TIME  TIME_GAIN  TIME_LOSS USER_CALLS PLSQL_CALLS PLSQL_SUBCALLS PLSQL_DBTIME CLIENT_OS_USER  CLIENT_HOST						       CLIENT_PID		PROGRAM 					 CAPTURE_ELAPSED_TIME REPLAY_ELAPSED_TIME     CON_ID
---------- ----------- ---------- ---------- ------------------------ -------------------------------------------------------------------------------------------------------------------------------- --------- ---------------------------------------------------------------- ---------- ---------- ---------------------------------------------------------------- ---------- ---------------------------------------------------------------- ---------- ---------------------------------------------------------------- ---------- ------------ ---------- ------------ ------------- ------------- --------------- --------------- ----------- ------------- ---------- --------------- --------------------------------------------------- - - ---------- ------------ ---------- ---------- ---------- ---------- ----------- -------------- ------------ --------------- ---------------------------------------------------------------- ------------------------ ------------------------------------------------ -------------------- ------------------- ----------
	 0	     0	      134      57494 7054		      SYSTEM															       03-APR-23 SQL*Net message from client					  1421975091	    445 driver id							 1650815232 #bytes								      1 									  0	       0	  0	       0	     0		   0		   0		   0	       0 DISPATCHER		1		0						      N       493815		0	   0	      0 	 0	    0		0	       0	    0 oracle	      dbserver							       6929			wrc@dbserver (TNS V1-V3)					    0			0	   0
	 0	     0	      252      51893 7052		      SYSTEM															       03-APR-23 WCR: replay client notify					   277762365	    508 who am I								  2									      0 									  0	       0	  0	       0	     0		   0		   0		   0	       0 ADMIN			1		0						      N        31829		0	   0	      0 	 0	    0		0	       0	    0 oracle	      dbserver							       6929			wrc@dbserver (TNS V1-V3)					    0			0	   0
1.8447E+19  1.8447E+19	      379      12078 7056		      SYS															       03-APR-23 SQL*Net message from client					  1421975091	    445 driver id							 1650815232 #bytes								      1 									  0	       0 3.0891E+18	       6	     0		   0		   0		   0	       0 REPLAY 		1		0 wcr_2prn6h0000000.rec 			      N        68666	    47796	   0	      0     151894	    6		0	       0	    0 oracle	      dbserver							       6929			wrc@dbserver (TNS V1-V3)					    0			0	   0

SQL> 
SQL> 
SQL> select * from V$WORKLOAD_REPLAY_THREAD;

     CLOCK NEXT_TICKER	      SID    SERIAL# SPID		      LOGON_USER														       LOGON_TIM EVENT								    EVENT_ID	 EVENT# P1TEXT									 P1 P2TEXT								     P2 P3TEXT									 P3 WAIT_FOR_SCN    FILE_ID CALL_COUNTER DEPENDENT_SCN STATEMENT_SCN COMMIT_WAIT_SCN POST_COMMIT_SCN ACTION_TYPE SESSION_TYPE	   WRC_ID SCHEDULE_CAP_ID FILE_NAME					      S D     DBTIME NETWORK_TIME THINK_TIME  TIME_GAIN  TIME_LOSS USER_CALLS PLSQL_CALLS PLSQL_SUBCALLS PLSQL_DBTIME CLIENT_OS_USER  CLIENT_HOST						       CLIENT_PID		PROGRAM 					 CAPTURE_ELAPSED_TIME REPLAY_ELAPSED_TIME     CON_ID
---------- ----------- ---------- ---------- ------------------------ -------------------------------------------------------------------------------------------------------------------------------- --------- ---------------------------------------------------------------- ---------- ---------- ---------------------------------------------------------------- ---------- ---------------------------------------------------------------- ---------- ---------------------------------------------------------------- ---------- ------------ ---------- ------------ ------------- ------------- --------------- --------------- ----------- ------------- ---------- --------------- --------------------------------------------------- - - ---------- ------------ ---------- ---------- ---------- ---------- ----------- -------------- ------------ --------------- ---------------------------------------------------------------- ------------------------ ------------------------------------------------ -------------------- ------------------- ----------
1.8447E+19  1.8447E+19	      133      42873 7076		      C##SPA123 														       03-APR-23 SQL*Net message from client					  1421975091	    445 driver id							 1650815232 #bytes								      1 									  0	       0 3.0891E+18	      10	     0	     7893043		   0		   0	       4 REPLAY 		1		0 wcr_2prnnh0000001.rec 			      N        61743	    41259	   0	      0       3805	   10		1	       0	  322 oracle	      dbserver							       6929			wrc@dbserver (TNS V1-V3)					   14		       14	   0
1.8447E+19  1.8447E+19	      134      57494 7054		      SYSTEM															       03-APR-23 SQL*Net message from client					  1421975091	    445 driver id							 1650815232 #bytes								      1 									  0	       0	  0	       0	     0		   0		   0		   0	       0 DISPATCHER		1		0						      N       791708		0	   0	      0 	 0	    0		0	       0	    0 oracle	      dbserver							       6929			wrc@dbserver (TNS V1-V3)					    0			0	   0
1.8447E+19  1.8447E+19	      252      51893 7052		      SYSTEM															       03-APR-23 WCR: replay client notify					   277762365	    508 who am I								  2									      0 									  0	       0	  0	       0	     0		   0		   0		   0	       0 ADMIN			1		0						      N        31829		0	   0	      0 	 0	    0		0	       0	    0 oracle	      dbserver							       6929			wrc@dbserver (TNS V1-V3)					    0			0	   0

SQL> 
SQL> 
SQL> select * from V$WORKLOAD_REPLAY_THREAD;

     CLOCK NEXT_TICKER	      SID    SERIAL# SPID		      LOGON_USER														       LOGON_TIM EVENT								    EVENT_ID	 EVENT# P1TEXT									 P1 P2TEXT								     P2 P3TEXT									 P3 WAIT_FOR_SCN    FILE_ID CALL_COUNTER DEPENDENT_SCN STATEMENT_SCN COMMIT_WAIT_SCN POST_COMMIT_SCN ACTION_TYPE SESSION_TYPE	   WRC_ID SCHEDULE_CAP_ID FILE_NAME					      S D     DBTIME NETWORK_TIME THINK_TIME  TIME_GAIN  TIME_LOSS USER_CALLS PLSQL_CALLS PLSQL_SUBCALLS PLSQL_DBTIME CLIENT_OS_USER  CLIENT_HOST						       CLIENT_PID		PROGRAM 					 CAPTURE_ELAPSED_TIME REPLAY_ELAPSED_TIME     CON_ID
---------- ----------- ---------- ---------- ------------------------ -------------------------------------------------------------------------------------------------------------------------------- --------- ---------------------------------------------------------------- ---------- ---------- ---------------------------------------------------------------- ---------- ---------------------------------------------------------------- ---------- ---------------------------------------------------------------- ---------- ------------ ---------- ------------ ------------- ------------- --------------- --------------- ----------- ------------- ---------- --------------- --------------------------------------------------- - - ---------- ------------ ---------- ---------- ---------- ---------- ----------- -------------- ------------ --------------- ---------------------------------------------------------------- ------------------------ ------------------------------------------------ -------------------- ------------------- ----------
1.8447E+19  1.8447E+19	      133      42873 7076		      C##SPA123 														       03-APR-23 SQL*Net message from client					  1421975091	    445 driver id							 1650815232 #bytes								      1 									  0	       0 3.0891E+18	      14	     0	     7893052	     7896173		   0	       4 REPLAY 		1		0 wcr_2prnnh0000001.rec 			      N      1155601	    41392	   0	      0       3638	   14		2	       0      1094180 oracle	      dbserver							       6929			wrc@dbserver (TNS V1-V3)					   46		       52	   0
1.8447E+19  1.8447E+19	      134      57494 7054		      SYSTEM															       03-APR-23 SQL*Net message from client					  1421975091	    445 driver id							 1650815232 #bytes								      1 									  0	       0	  0	       0	     0		   0		   0		   0	       0 DISPATCHER		1		0						      N      1561052		0	   0	      0 	 0	    0		0	       0	    0 oracle	      dbserver							       6929			wrc@dbserver (TNS V1-V3)					    0			0	   0
1.8447E+19  1.8447E+19	      252      51893 7052		      SYSTEM															       03-APR-23 WCR: replay client notify					   277762365	    508 who am I								  2									      0 									  0	       0	  0	       0	     0		   0		   0		   0	       0 ADMIN			1		0						      N        31829		0	   0	      0 	 0	    0		0	       0	    0 oracle	      dbserver							       6929			wrc@dbserver (TNS V1-V3)					    0			0	   0

SQL> ...
-- 回放结束

SQL> select * from V$WORKLOAD_REPLAY_THREAD;

no rows selected

SQL> 

示例2如下:在重放模式下运行 wrc 可执行文件以进行加密捕获

-- 以下示例显示了如何在重放模式下运行 wrc 可执行文件以捕获加密的工作负载:

%> wrc system/password@test mode=replay replaydir=./replay walletdir=/tmp/replay_encrypt_cwallet

在此示例中,wrc 可执行文件启动重放客户端以重放存储在当前目录下名为 replay 的子目录中的工作负载捕获。walletdir 指向自动登录软件密钥库目录的位置。


显示主机的信息

您可以通过在 list_hosts 模式下运行 wrc 可执行文件来显示参与工作负载捕获和工作负载重放的主机。

在 list_hosts 模式下,wrc 可执行文件接受关键字 replaydir,它指定包含要重放的预处理工作负载捕获的目录。 如果未指定,则默认为当前目录。

以下示例显示了如何在 list_hosts 模式下运行 wrc 可执行文件:

%> wrc mode=list_hosts replaydir=./replay

在此示例中,执行 wrc 可执行文件以列出所有参与捕获或重放存储在当前目录下名为 replay 的子目录中的工作负载捕获的主机。 在以下示例输出中,显示了参与工作负载捕获和一个后续重放的主机:

[oracle@dbserver bin]$ wrc mode=list_hosts replaydir=/home/oracle/db_replay_capture

Workload Replay Client: Release 19.3.0.0.0 - Production on Mon Apr 3 15:57:18 2023

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.


Hosts found:
Capture: test_capture_1
	dbserver
Replay 475403902: test_capture_1
	dbserver
[oracle@dbserver bin]$

列出引用的对象

列出捕获SQL引用的对象,如下:

-- wrc system/123456  mode=get_tables replaydir=/home/oracle/db_replay_capture 也行

[oracle@dbserver db_replay_capture]$ wrc mode=get_tables replaydir=/home/oracle/db_replay_capture

Workload Replay Client: Release 19.3.0.0.0 - Production on Mon Apr 3 16:58:18 2023

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.


Username: c##spa123
Password: 
List of objects referenced by the captured statements:
------------------------------------------------------
TABLE             : C##SPA123.TEST
TABLE             : SYS.DUAL

List of captured statements that cannot be resolved to objects:
---------------------------------------------------------------

--> User C##SPA123
--> SQL ID 12184731934851362426
--> ORA-16953: Type of SQL statement not supported
--> declare
  l_stmt varchar2(2000);
begin
  for ctr in 1..1000 loop
     l_stmt := 'insert into test values ('||
        test_id_seq.nextval||','||
        ''''||dbms_random.string('U',20)||''','||
        'sysdate - '||
        round(dbms_random.value(1,365))||','||
        round(dbms_random.value(1,999999),2)||','||
        round(dbms_random.value(1,99))||')';
     dbms_output.put_line(l_stmt);
     execute immediate l_stmt;
     commit;
  end loop;
end;

--> User C##SPA123
--> SQL ID 17471948817008696716
--> ORA-16953: Type of SQL statement not supported
--> BEGIN DBMS_APPLICATION_INFO.SET_MODULE(:1,NULL); END;
[oracle@dbserver db_replay_capture]$
04-04 10:14