Upgrade PDBs with RELOCATE – How does it work?

Today Roy and I received a question from a colleague about the RELOCATE feature in Multitenant. And I’d like to shed some light and this topic a bit more. Upgrade PDBs with RELOCATE – How does it work?

Upgrade PDBs with RELOCATE - How does it work?

Photo by Sebastian Pena Lambarri on Unsplash

RELOCATE and UPGRADE?

At first, it looks very promising to me. RELOCATE uses the HOT CLONE functionality of Multitenant but then relocates the PDB from one to another CDB. You need to fulfill a few important requirements, for instance:

  • Local Undo must be enabled in both CDBs
    • This limits the technique to at least Oracle 12.2.0.1 as a source CDB
  • Both CDBs need to operate in ARCHIVELOG mode
  • The source needs a lower or equal COMPATIBLE parameter than the destination CDB
    • I recommend to keep COMPATIBLE equal among your CDBs on the lowest common setting

If you’d like to learn more about the RELOCATE feature and its options, please see this documentation link:

How does it work [or not]?

Actually I use my previous blog post about patching and relocation as a blueprint example:

So let’s start with my typical Hands-On Lab setup with CDB1 as source in Oracle 12.2.0.1, CDB2 as target in Oracle 19.6.0.

Before I can start, I will need to prepare a few things:

CDB1 CDB2
Create a common user for the relocate operation and assign necessary privileges:

CREATE USER c##borg IDENTIFIED BY oracle DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp CONTAINER=ALL;
GRANT CREATE SESSION, CREATE PLUGGABLE DATABASE, SYSOPER TO c##borg CONTAINER = ALL;
Create the public database link for the relocate operation:

CREATE public DATABASE link clonemypdb CONNECT TO c##borg IDENTIFIED BY oracle USING 'CDB1';

Initiate the relocation:

CREATE PLUGGABLE DATABASE PDB3 FROM PDB3@clonemypdb RELOCATE AVAILABILITY MAX file_name_convert=('CDB1','CDB2');
CREATE PLUGGABLE DATABASE PDB3 FROM PDB3@clonemypdb RELOCATE AVAILABILITY MAX file_name_convert=('CDB1','CDB2')
*
ERROR at line 1:
ORA-65188: cannot relocate a PDB opened with warnings

Ouch!

What is going wrong here?

First of all, the error ORA-65188: cannot relocate a PDB opened with warnings does not really tell me what the problem is. In fact, it leads me into the wrong direction. It seems to be the case that the error happens as a result from trying to open the PDB3 in CDB2. But there is no PDB3 in CDB2 visible. And PDB3 in CDB1 is happy and alive, open unrestricted.

MOS may help. It does. I receive exactly one result with the error:

Somebody must have tried this already, and failed. The note gives an understandable explanation:

  • AVAILABILITY MAX means that we don’t want customer to get any downtime. Upgrade can be time consuming, and it is a manual action currently.
    So AVAILABILITY MAX will still be a downtime for customer application. Hence, we do not allow AVAILABILITY MAX during relocate from lower version to higher version

So my approach was wrong.

How to do it the right way

I repeat my case from above with one important difference.

Then I need to prepare a few things:

CDB1 CDB2
Create a common user for the relocate operation and assign necessary privileges:

CREATE USER c##borg IDENTIFIED BY oracle DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp CONTAINER=ALL;
GRANT CREATE SESSION, CREATE PLUGGABLE DATABASE, SYSOPER TO c##borg CONTAINER = ALL;
Create the public database link for the relocate operation:

CREATE public DATABASE link clonemypdb CONNECT TO c##borg IDENTIFIED BY oracle USING 'CDB1';

Initiate the relocation:

CREATE PLUGGABLE DATABASE PDB3 FROM PDB3@clonemypdb RELOCATE file_name_convert=('CDB1','CDB2');

Open the PDB:

ALTER PLUGGABLE DATABASE PDB3 OPEN UPGRADE;

The PDB needs to be opened in upgrade mode as it is a 12.2.0.1 PDB in a 19.6.0 CDB

On the command line simply issue:

$ dbupgrade -c "PDB3" -l /home/oracle

This will upgrade now PDB3 to 19.6.0, too.

Just in case you are interested, this is the output from the database upgrade:

$ dbupgrade -c "PDB3" -l /home/oracle

Argument list for [/u01/app/oracle/product/19/rdbms/admin/catctl.pl]
For Oracle internal use only A = 0
Run in                       c = PDB3
Do not run in                C = 0
Input Directory              d = 0
Echo OFF                     e = 1
Simulate                     E = 0
Forced cleanup               F = 0
Log Id                       i = 0
Child Process                I = 0
Log Dir                      l = /home/oracle
Priority List Name           L = 0
Upgrade Mode active          M = 0
SQL Process Count            n = 0
SQL PDB Process Count        N = 0
Open Mode Normal             o = 0
Start Phase                  p = 0
End Phase                    P = 0
Reverse Order                r = 0
AutoUpgrade Resume           R = 0
Script                       s = 0
Serial Run                   S = 0
RO User Tablespaces          T = 0
Display Phases               y = 0
Debug catcon.pm              z = 0
Debug catctl.pl              Z = 0

catctl.pl VERSION: [19.0.0.0.0]
           STATUS: [Production]
            BUILD: [RDBMS_19.6.0.0.0DBRU_LINUX.X64_191217]


/u01/app/oracle/product/19/rdbms/admin/orahome = [/u01/app/oracle/product/19]
/u01/app/oracle/product/19/bin/orabasehome = [/u01/app/oracle/product/19]
catctlGetOraBaseLogDir = [/u01/app/oracle/product/19]

Analyzing file /u01/app/oracle/product/19/rdbms/admin/catupgrd.sql

Log file directory = [/home/oracle]

catcon::set_log_file_base_path: ALL catcon-related output will be written to [/home/oracle/catupgrd_catcon_15691.lst]

catcon::set_log_file_base_path: catcon: See [/home/oracle/catupgrd*.log] files for output generated by scripts

catcon::set_log_file_base_path: catcon: See [/home/oracle/catupgrd_*.lst] files for spool files, if any


Number of Cpus        = 2
Database Name         = CDB2
DataBase Version      = 19.0.0.0.0
PDB Parallel SQL Process Count = [2] is higher or equal to CPU Count = [2]
Concurrent PDB Upgrades defaulting to CPU Count [2]
Parallel SQL Process Count (PDB)      = 2
Parallel SQL Process Count (CDB$ROOT) = 4
Concurrent PDB Upgrades               = 2
Generated PDB Inclusion:[PDB3]
CDB$ROOT  Open Mode = [OPEN]
Concurrent PDB Upgrades Reset           = 1

Start processing of PDBs (PDB3)
[/u01/app/oracle/product/19/perl/bin/perl /u01/app/oracle/product/19/rdbms/admin/catctl.pl -c 'PDB3' -l /home/oracle -I -i pdb3 -n 2 /u01/app/oracle/product/19/rdbms/admin/catupgrd.sql]

Argument list for [/u01/app/oracle/product/19/rdbms/admin/catctl.pl]
For Oracle internal use only A = 0
Run in                       c = PDB3
Do not run in                C = 0
Input Directory              d = 0
Echo OFF                     e = 1
Simulate                     E = 0
Forced cleanup               F = 0
Log Id                       i = pdb3
Child Process                I = 1
Log Dir                      l = /home/oracle
Priority List Name           L = 0
Upgrade Mode active          M = 0
SQL Process Count            n = 2
SQL PDB Process Count        N = 0
Open Mode Normal             o = 0
Start Phase                  p = 0
End Phase                    P = 0
Reverse Order                r = 0
AutoUpgrade Resume           R = 0
Script                       s = 0
Serial Run                   S = 0
RO User Tablespaces          T = 0
Display Phases               y = 0
Debug catcon.pm              z = 0
Debug catctl.pl              Z = 0

catctl.pl VERSION: [19.0.0.0.0]
           STATUS: [Production]
            BUILD: [RDBMS_19.6.0.0.0DBRU_LINUX.X64_191217]


/u01/app/oracle/product/19/rdbms/admin/orahome = [/u01/app/oracle/product/19]
/u01/app/oracle/product/19/bin/orabasehome = [/u01/app/oracle/product/19]
catctlGetOraBaseLogDir = [/u01/app/oracle/product/19]

Analyzing file /u01/app/oracle/product/19/rdbms/admin/catupgrd.sql

Log file directory = [/home/oracle]

catcon::set_log_file_base_path: ALL catcon-related output will be written to [/home/oracle/catupgrdpdb3_catcon_15957.lst]

catcon::set_log_file_base_path: catcon: See [/home/oracle/catupgrdpdb3*.log] files for output generated by scripts

catcon::set_log_file_base_path: catcon: See [/home/oracle/catupgrdpdb3_*.lst] files for spool files, if any


Number of Cpus        = 2
Database Name         = CDB2
DataBase Version      = 19.0.0.0.0
PDB3 Open Mode = [MIGRATE] 
Generated PDB Inclusion:[PDB3]
CDB$ROOT  Open Mode = [OPEN]
Components in [PDB3]
    Installed [CATALOG CATPROC OWM XDB]
Not Installed [APEX APS CATJAVA CONTEXT DV EM JAVAVM MGW ODM OLS ORDIM RAC SDO WK XML XOQ]

------------------------------------------------------
Phases [0-107]         Start Time:[2020_01_28 22:28:40]
Container Lists Inclusion:[PDB3] Exclusion:[NONE]
------------------------------------------------------
***********   Executing Change Scripts   ***********
Serial   Phase #:0    [PDB3] Files:1    Time: 20s
***************   Catalog Core SQL   ***************
Serial   Phase #:1    [PDB3] Files:5    Time: 45s
Restart  Phase #:2    [PDB3] Files:1    Time: 2s
***********   Catalog Tables and Views   ***********
Parallel Phase #:3    [PDB3] Files:19   Time: 25s
Restart  Phase #:4    [PDB3] Files:1    Time: 2s
*************   Catalog Final Scripts   ************
Serial   Phase #:5    [PDB3] Files:7    Time: 19s
*****************   Catproc Start   ****************
Serial   Phase #:6    [PDB3] Files:1    Time: 14s
*****************   Catproc Types   ****************
Serial   Phase #:7    [PDB3] Files:2    Time: 13s
Restart  Phase #:8    [PDB3] Files:1    Time: 2s
****************   Catproc Tables   ****************
Parallel Phase #:9    [PDB3] Files:67   Time: 34s
Restart  Phase #:10   [PDB3] Files:1    Time: 2s
*************   Catproc Package Specs   ************
Serial   Phase #:11   [PDB3] Files:1    Time: 56s
Restart  Phase #:12   [PDB3] Files:1    Time: 2s
**************   Catproc Procedures   **************
Parallel Phase #:13   [PDB3] Files:94   Time: 11s
Restart  Phase #:14   [PDB3] Files:1    Time: 2s
Parallel Phase #:15   [PDB3] Files:121  Time: 15s
Restart  Phase #:16   [PDB3] Files:1    Time: 2s
Serial   Phase #:17   [PDB3] Files:22   Time: 8s
Restart  Phase #:18   [PDB3] Files:1    Time: 1s
*****************   Catproc Views   ****************
Parallel Phase #:19   [PDB3] Files:32   Time: 21s
Restart  Phase #:20   [PDB3] Files:1    Time: 1s
Serial   Phase #:21   [PDB3] Files:3    Time: 15s
Restart  Phase #:22   [PDB3] Files:1    Time: 2s
Parallel Phase #:23   [PDB3] Files:25   Time: 187s
Restart  Phase #:24   [PDB3] Files:1    Time: 0s
Parallel Phase #:25   [PDB3] Files:12   Time: 113s
Restart  Phase #:26   [PDB3] Files:1    Time: 2s
Serial   Phase #:27   [PDB3] Files:1    Time: 0s
Serial   Phase #:28   [PDB3] Files:3    Time: 8s
Serial   Phase #:29   [PDB3] Files:1    Time: 0s
Restart  Phase #:30   [PDB3] Files:1    Time: 1s
***************   Catproc CDB Views   **************
Serial   Phase #:31   [PDB3] Files:1    Time: 7s
Restart  Phase #:32   [PDB3] Files:1    Time: 1s
Serial   Phase #:34   [PDB3] Files:1    Time: 0s
*****************   Catproc PLBs   *****************
Serial   Phase #:35   [PDB3] Files:294  Time: 20s
Serial   Phase #:36   [PDB3] Files:1    Time: 0s
Restart  Phase #:37   [PDB3] Files:1    Time: 1s
Serial   Phase #:38   [PDB3] Files:6    Time: 8s
Restart  Phase #:39   [PDB3] Files:1    Time: 1s
***************   Catproc DataPump   ***************
Serial   Phase #:40   [PDB3] Files:3    Time: 46s
Restart  Phase #:41   [PDB3] Files:1    Time: 1s
******************   Catproc SQL   *****************
Parallel Phase #:42   [PDB3] Files:13   Time: 117s
Restart  Phase #:43   [PDB3] Files:1    Time: 2s
Parallel Phase #:44   [PDB3] Files:11   Time: 11s
Restart  Phase #:45   [PDB3] Files:1    Time: 0s
Parallel Phase #:46   [PDB3] Files:3    Time: 7s
Restart  Phase #:47   [PDB3] Files:1    Time: 1s
*************   Final Catproc scripts   ************
Serial   Phase #:48   [PDB3] Files:1    Time: 14s
Restart  Phase #:49   [PDB3] Files:1    Time: 1s
**************   Final RDBMS scripts   *************
Serial   Phase #:50   [PDB3] Files:1    Time: 8s
************   Upgrade Component Start   ***********
Serial   Phase #:51   [PDB3] Files:1    Time: 7s
Restart  Phase #:52   [PDB3] Files:1    Time: 1s
**********   Upgrading Java and non-Java   *********
Serial   Phase #:53   [PDB3] Files:2    Time: 21s
*****************   Upgrading XDB   ****************
Restart  Phase #:54   [PDB3] Files:1    Time: 0s
Serial   Phase #:56   [PDB3] Files:3    Time: 12s
Serial   Phase #:57   [PDB3] Files:3    Time: 9s
Parallel Phase #:58   [PDB3] Files:10   Time: 10s
Parallel Phase #:59   [PDB3] Files:25   Time: 11s
Serial   Phase #:60   [PDB3] Files:4    Time: 14s
Serial   Phase #:61   [PDB3] Files:1    Time: 0s
Serial   Phase #:62   [PDB3] Files:32   Time: 10s
Serial   Phase #:63   [PDB3] Files:1    Time: 0s
Parallel Phase #:64   [PDB3] Files:6    Time: 12s
Serial   Phase #:65   [PDB3] Files:2    Time: 20s
Serial   Phase #:66   [PDB3] Files:3    Time: 26s
****************   Upgrading ORDIM   ***************
Restart  Phase #:67   [PDB3] Files:1    Time: 1s
Serial   Phase #:69   [PDB3] Files:1    Time: 8s
Parallel Phase #:70   [PDB3] Files:2    Time: 10s
Restart  Phase #:71   [PDB3] Files:1    Time: 1s
Parallel Phase #:72   [PDB3] Files:2    Time: 9s
Serial   Phase #:73   [PDB3] Files:2    Time: 9s
*****************   Upgrading SDO   ****************
Restart  Phase #:74   [PDB3] Files:1    Time: 1s
Serial   Phase #:76   [PDB3] Files:1    Time: 8s
Serial   Phase #:77   [PDB3] Files:2    Time: 9s
Restart  Phase #:78   [PDB3] Files:1    Time: 1s
Serial   Phase #:79   [PDB3] Files:1    Time: 8s
Restart  Phase #:80   [PDB3] Files:1    Time: 2s
Parallel Phase #:81   [PDB3] Files:3    Time: 9s
Restart  Phase #:82   [PDB3] Files:1    Time: 2s
Serial   Phase #:83   [PDB3] Files:1    Time: 8s
Restart  Phase #:84   [PDB3] Files:1    Time: 2s
Serial   Phase #:85   [PDB3] Files:1    Time: 8s
Restart  Phase #:86   [PDB3] Files:1    Time: 2s
Parallel Phase #:87   [PDB3] Files:4    Time: 10s
Restart  Phase #:88   [PDB3] Files:1    Time: 1s
Serial   Phase #:89   [PDB3] Files:1    Time: 9s
Restart  Phase #:90   [PDB3] Files:1    Time: 0s
Serial   Phase #:91   [PDB3] Files:2    Time: 9s
Restart  Phase #:92   [PDB3] Files:1    Time: 1s
Serial   Phase #:93   [PDB3] Files:1    Time: 7s
Restart  Phase #:94   [PDB3] Files:1    Time: 0s
*******   Upgrading ODM, WK, EXF, RUL, XOQ   *******
Serial   Phase #:95   [PDB3] Files:1    Time: 7s
Restart  Phase #:96   [PDB3] Files:1    Time: 1s
***********   Final Component scripts    ***********
Serial   Phase #:97   [PDB3] Files:1    Time: 8s
*************   Final Upgrade scripts   ************
Serial   Phase #:98   [PDB3] Files:1    Time: 117s
*******************   Migration   ******************
Serial   Phase #:99   [PDB3] Files:1    Time: 6s
***   End PDB Application Upgrade Pre-Shutdown   ***
Serial   Phase #:100  [PDB3] Files:1    Time: 7s
Serial   Phase #:101  [PDB3] Files:1    Time: 5s
Serial   Phase #:102  [PDB3] Files:1    Time: 5s
*****************   Post Upgrade   *****************
Serial   Phase #:103  [PDB3] Files:1    Time: 16s
****************   Summary report   ****************
Serial   Phase #:104  [PDB3] Files:1    Time: 7s
***   End PDB Application Upgrade Post-Shutdown   **
Serial   Phase #:105  [PDB3] Files:1    Time: 6s
Serial   Phase #:106  [PDB3] Files:1    Time: 4s
Serial   Phase #:107  [PDB3] Files:1     Time: 0s

------------------------------------------------------
Phases [0-107]         End Time:[2020_01_28 22:51:09]
Container Lists Inclusion:[PDB3] Exclusion:[NONE]
------------------------------------------------------

Grand Total Time: 1349s [PDB3]

 LOG FILES: (/home/oracle/catupgrdpdb3*.log)

Upgrade Summary Report Located in:
/home/oracle/upg_summary.log

     Time: 1423s For PDB(s)

Grand Total Time: 1423s 

 LOG FILES: (/home/oracle/catupgrd*.log)


Grand Total Upgrade Time:    [0d:0h:23m:43s]
 

What happened in the source?

I used the RELOCATE feature. But is this something you should do? And what is the actual benefit of it?

One thing is very straight forward: You don’t deal with an unplug/plug command anymore. The database does it all for you. Not bad actually. I like this idea.

But … well, there is another side to look at – the source CDB1. Let us compare BEFORE/AFTER:

  • Before:
    SQL> show pdbs
    
        CON_ID CON_NAME			  OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
    	 2 PDB$SEED			  READ ONLY  NO
    	 3 PDB3 			  READ WRITE NO
  • After:
    SQL> show pdbs
    
        CON_ID CON_NAME			  OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
    	 2 PDB$SEED			  READ ONLY  NO

So my PDB3 has disappeared from CDB1. Of course, it has – as otherwise this wouldn’t be RELOCATE.

Is this good or bad? I’m not 100% convinced yet but in my understanding, the feature used underneath is the CLONE operation. RELOCATE won’t drop the PDB from source as long as it appears in the destination CDB.

But if you have different ideas on how to break it, let me know. I tried several things but either the PDB stayed healthy in the source, or it appeared in the destination.

More Information and Links

–Mike

Share this: