{
  "date": "2016-11-19T21:01:36",
  "slug": "12cr2-upgrade-by-unplugplug-in-the-oracle-cloud-service",
  "link": "https://www.dbi-services.com/blog/12cr2-upgrade-by-unplugplug-in-the-oracle-cloud-service/",
  "title": {
    "rendered": "12cR2: Upgrade by unplug/plug in the Oracle Cloud Service"
  },
  "content": {
    "rendered": "<h2>By Franck Pachot</h2>\n<p>.</p>\n<ol>\n12.2 is available in the Oracle Public Cloud DBaaS. If you have a 12.1 DBaaS service, there&#8217;s no button to upgrade it. I&#8217;ll describe all the possible upgrade procedures and the first one, and the most simple, is to create a new DBaaS service in 12.2 and unplug/plug the PDBs to it.<br />\n<!--more--><br />\nHere is my DBaaS in 12.1</p>\n<pre><code>[oracle@HP121A ~]$ sqlplus / as sysdba\n&nbsp;\nSQL*Plus: Release 12.1.0.2.0 Production on Sat Nov 19 14:47:04 2016\n&nbsp;\nCopyright (c) 1982, 2014, Oracle.  All rights reserved.\n&nbsp;\n&nbsp;\nConnected to:\nOracle Database 12c EE High Perf Release 12.1.0.2.0 - 64bit Production\nWith the Partitioning, Oracle Label Security, OLAP, Advanced Analytics\nand Real Application Testing options\n&nbsp;\nSQL&gt; show pdbs\n&nbsp;\n    CON_ID CON_NAME                       OPEN MODE  RESTRICTED\n---------- ------------------------------ ---------- ----------\n         2 PDB$SEED                       READ ONLY  NO\n         3 PDB1                           READ WRITE NO</code></pre>\n<h3>Unplug</h3>\n<p>I close the PDB1 and unplug it.</p>\n<pre><code>SQL&gt; alter pluggable database PDB1 close;\n&nbsp;\nPluggable database altered.\n&nbsp;\nSQL&gt; alter pluggable database PDB1 unplug into '/tmp/PDB1.xml';\n&nbsp;\nPluggable database altered.</code></pre>\n<h3>Copy files</h3>\n<p>I&#8217;ve opened ssh between the two VMs and copy the xml file</p>\n<pre><code>[oracle@HP122A tmp]$ scp 141.144.32.166:/tmp/PDB1.xml .\nThe authenticity of host '141.144.32.168 (141.144.32.168)' can't be established.\nRSA key fingerprint is 84:e4:e3:db:67:20:e8:e2:f7:ff:a6:4d:9e:ee:a4:08.\nAre you sure you want to continue connecting (yes/no)? yes\nWarning: Permanently added '141.144.32.168' (RSA) to the list of known hosts.\nPDB1.xml                                                                                           100% 6118     6.0KB/s   00:00</code></pre>\n<p>From the xml file I see which files are referenced:</p>\n<pre><code>[oracle@HP121A ~]$ grep path /tmp/PDB1.xml\n      &lt;path&gt;/u02/app/oracle/oradata/HP121A/41A8A48F54195236E0534EC5C40A569E/datafile/o1_mf_system_d30owr5v_.dbf&lt;/path&gt;\n      &lt;path&gt;/u02/app/oracle/oradata/HP121A/41A8A48F54195236E0534EC5C40A569E/datafile/o1_mf_sysaux_d30owr69_.dbf&lt;/path&gt;\n      &lt;path&gt;/u02/app/oracle/oradata/HP121A/41A8A48F54195236E0534EC5C40A569E/datafile/o1_mf_temp_d30owr6h_.dbf&lt;/path&gt;</code></pre>\n<p>and copy them</p>\n<pre><code>[oracle@HP122A tmp]$ scp -r 141.144.32.168:/u02/app/oracle/oradata/HP121A/41A8A48F54195236E0534EC5C40A569E /u02/app/oracle/oradata/HP121A\no1_mf_temp_d30owr6h_.dbf                                                                           100%   20MB  20.0MB/s   00:00\no1_mf_system_d30owr5v_.dbf                                                                         100%  270MB 135.0MB/s   00:02\no1_mf_sysaux_d30owr69_.dbf                                                                         100%  570MB 114.0MB/s   00:05</code></pre>\n<h3>Plug</h3>\n<p>It&#8217;s only one command to plug it into the 12.2 CDB:</p>\n<pre><code>[oracle@HP122A tmp]$ sqlplus / as sysdba\n&nbsp;\nSQL*Plus: Release 12.2.0.1.0 Production on Sat Nov 19 14:50:26 2016\n&nbsp;\nCopyright (c) 1982, 2016, Oracle.  All rights reserved.\n&nbsp;\nConnected to:\nOracle Database 12c EE High Perf Release 12.2.0.1.0 - 64bit Production\n&nbsp;\nSQL&gt; show pdbs\n&nbsp;\n    CON_ID CON_NAME                       OPEN MODE  RESTRICTED\n---------- ------------------------------ ---------- ----------\n         2 PDB$SEED                       READ ONLY  NO\n&nbsp;\nSQL&gt; create pluggable database PDB1 using '/tmp/PDB1.xml';\nPluggable database created.</code></pre>\n<p>At that time, you can drop it from the source but probably you will remove the service once you are sure the migration is ok.</p>\n<h3>Upgrade</h3>\n<p>That was easy, but that was only the transportation of the PDB to another CDB, but it cannot be opened so easily on a newer version CDB. When we open the PDB we get a warning:</p>\n<pre><code>SQL&gt; alter pluggable database PDB1 open;\n&nbsp;\nWarning: PDB altered with errors.</code></pre>\n<p>and have to look at the PDB_PLUG_IN_VIOLATIONS</p>\n<pre><code>SQL&gt; select MESSAGE from pdb_plug_in_violations order by time\n&nbsp;\nMESSAGE\n-----------------------------------------------------------------------------------------------------------\nAPEX mismatch: PDB installed version NULL CDB installed version 5.0.4.00.12\nCDB is using local undo, but no undo tablespace found in the PDB.\nCDB parameter compatible mismatch: Previous '12.1.0.2.0' Current '12.2.0'\nDatabase option APS mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option CATALOG mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option CATJAVA mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option CATPROC mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option CONTEXT mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option DV mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option JAVAVM mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option OLS mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option ORDIM mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option OWM mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option SDO mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option XDB mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option XML mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nDatabase option XOQ mismatch: PDB installed version 12.1.0.2.0. CDB installed version 12.2.0.1.0.\nPDB's version does not match CDB's version: PDB's version 12.1.0.2.0. CDB's version 12.2.0.1.0.</code></pre>\n<p>Each component report a newer version. We have to upgrade them running catupgrd.sql.<br />\nIn 12.2 we have a new script that calls the catctl.pl and catupgrd.sql to make this easier. It is a shell script located in ORACLE_HOME/bin and is <b>dbupgrade</b>. As with catcon.pl we have the &#8216;-c&#8217; argument to run it on PDB1:</p>\n<pre><code>[oracle@HP122A tmp]$ $ORACLE_HOME/bin/dbupgrade -c PDB1</code></pre>\n<p>How long does it take? Documentation says that:<br />\n<em>It is easier to apply a patch to one CDB than to multiple non-CDBs and to upgrade one CDB than to upgrade several non-CDBs.</em><br />\nSo this supposes that upgrade work is mostly done at CDB level. PDBs have only metadata links to them. It&#8217;s only a virtual dictionary.</p>\n<p>More than 3 years after the multitenant architecture was released, there are big doubts about the time it takes to upgrade a PDB plugged from a previous version:</p>\n<blockquote class=\"twitter-tweet\" data-width=\"500\" data-dnt=\"true\">\n<p lang=\"en\" dir=\"ltr\"><a href=\"https://twitter.com/hashtag/dbupgrade?src=hash&amp;ref_src=twsrc%5Etfw\">#dbupgrade</a> <a href=\"https://twitter.com/OracleDatabase?ref_src=twsrc%5Etfw\">@OracleDatabase</a><br />Guess how many minutes to catupgrd a 12.1 PDB plugged into an empty 12.2 CDB?<br />[ doc says <a href=\"https://t.co/hQTknmKl1y\">https://t.co/hQTknmKl1y</a></p>\n<p>&mdash; Franck Pachot (@FranckPachot) <a href=\"https://twitter.com/FranckPachot/status/799996397965561856?ref_src=twsrc%5Etfw\">November 19, 2016</a></p></blockquote>\n<p><script async src=\"https://platform.twitter.com/widgets.js\" charset=\"utf-8\"></script></p>\n<p>So I keep the answer for the <a href=\"http://dbi-services.com/blog/12cr2-how-long-to-upgrade-a-pdb/\" target=\"_blank\" rel=\"noopener noreferrer\">next blog post</a>.</p>\n",
    "protected": false
  }
}
