{
  "date": "2015-12-20T16:08:53",
  "slug": "ocm-12c-preparation-rat-in-multitenant",
  "link": "https://www.dbi-services.com/blog/ocm-12c-preparation-rat-in-multitenant/",
  "title": {
    "rendered": "OCM 12c preparation: RAT in multitenant"
  },
  "content": {
    "rendered": "<h2>By Franck Pachot</h2>\n<p>.<br />\nI have several customers that have cases where Real Application Testing can be interesting, but they don&#8217;t use it because it&#8217;s an expensive option. Which is why it&#8217;s probably the topic listed for OCM 12c exam where I&#8217;ve the less experience. And I don&#8217;t even know at which level (CDB or PDB) it has to be run in multitenant. So I&#8217;ve tested it and came to a surprise.<br />\n<!--more--><br />\nIn Enterprise Manager, when you select Database Replay from a PDB:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplay002.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplay002.jpg\" alt=\"CaptureReplay002\" width=\"308\" height=\"357\" class=\"alignnone size-full wp-image-6176\" /></a></p>\n<p>It seems that you go back at CDB level:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplay003.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplay003.jpg\" alt=\"CaptureReplay003\" width=\"531\" height=\"120\" class=\"alignnone size-full wp-image-6175\" /></a></p>\n<h3>Capture</h3>\n<p>From there I&#8217;ve run a small capture, using the most simple and the default settings from the OEM wizard, and got a capture that has no reference to the PDB:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplay004.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplay004.jpg\" alt=\"CaptureReplay004\" width=\"772\" height=\"328\" class=\"alignnone size-full wp-image-6174\" /></a></p>\n<p>Don&#8217;t hesitate to comment here because that looks strange for me that I cannot capture at PDB level.</p>\n<h3>Replay</h3>\n<p>So while the capture was running, I&#8217;ve created the SCOTT schema with utlsampl.sql and I&#8217;ve raised all salaries in EMP.<br />\nNow, to replay in the same state, I&#8217;ve re-created the SCOTT schema.</p>\n<p>And once again, using all defaults in OEM wizard. But the replay had 2 errors:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplayError.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplayError.jpg\" alt=\"CaptureReplayError\" width=\"736\" height=\"267\" class=\"alignnone size-full wp-image-6180\" /></a></p>\n<p>There&#8217;s probably a way to see the statements, but first I check the error messages:</p>\n<pre><code>\n[oracle@VM111 ~]$ oerr ora 01918\n01918, 00000, \"user '%s' does not exist\"\n// *Cause:  User does not exist in the system.\n// *Action: Verify the user name is correct.\n[oracle@VM111 ~]$ oerr ora 65049\n65049, 00000, \"creation of local user or role is not allowed in CDB$ROOT\"\n// *Cause:   An attempt was made to create a local user or role in CDB$ROOT.\n// *Action:  If trying to create a common user or role, specify CONTAINER=ALL.\n//\n</code></pre>\n<p>As I know that the capture, running utlsampl.sql, did DROP USER SCOTT and then CREATE USER SCOTT, I can imagine that the replay was running on the CDB$ROOT.</p>\n<p>I did the replay again, and the reason is clear. Because I&#8217;m at CDB level de defaut connection string for replay clients connects to the CDB$ROOT:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplayErrorCDB.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplayErrorCDB.jpg\" alt=\"CaptureReplayErrorCDB\" width=\"766\" height=\"511\" class=\"alignnone size-full wp-image-6179\" /></a></p>\n<p>Let&#8217;s change it to PDB service name:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplayErrorPDB.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureReplayErrorPDB.jpg\" alt=\"CaptureReplayErrorPDB\" width=\"765\" height=\"508\" class=\"alignnone size-full wp-image-6178\" /></a></p>\n<p>There I thought that the workload replay client had to connect to PDB but:</p>\n<pre><code>\noracle@VM111 ~]$ wrc system/oracle@//vm111/PDB replaydir=/tmp/replay\n&nbsp;\nWorkload Replay Client: Release 12.1.0.2.0 - Production on Sun Dec 20 14:55:02 2015\n&nbsp;\nCopyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.\n&nbsp;\n(wrc_main_6062.trc) ORA-15554: cannot start workload replay client because the database server is not in PREPARE mode\n</code></pre>\n<p>then I connect to the CDB$ROOT and everything is ok:</p>\n<pre><code>\n[oracle@VM111 ~]$ wrc system/oracle replaydir=/tmp/replay\n&nbsp;\nWorkload Replay Client: Release 12.1.0.2.0 - Production on Sun Dec 20 14:55:17 2015\n&nbsp;\nCopyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.\n&nbsp;\nWait for the replay to start (14:55:17)\nReplay client 1 started (14:55:39)\n</code></pre>\n<p>With this configuration, the replay had no errors: SCOTT recreated and salaries updated.</p>\n<h3>Conclusion</h3>\n<p>My conclusion here is that everything about RAT is done at CDB level (but you can filter to capture only what happens on one PDB).</p>\n",
    "protected": false
  }
}
