Recently there was a requirement to upgrade DBCS PDB from 19c to 23c. There might be other ways to do that but I found the best and easiest way is to create new 23c DBCS and then move 19c PDB using Refreshable clone method and then use Auto upgrade to upgrade it.
I will show you how to do that in this blog post.
Pre-requisite: I already have all the networking setup and have 2 DBCS, one 19c and one 23c.
Benefit of this approach :
1. We already have 23c DBCS with latest Grid/ASM software. so we just need to move the PDB to this DBCS and upgrade it. It will shorter the downtime.
2. Another thing is when we use refreshable clone method, there is no downtime when files copied over and rolls the copies of the data files forward with redo from source. Downtime only start at the time of upgrade.
3. Another benefit is rollback scenario, we already have our source 19c PDB, if anything wrong happen during the process you can just open and use the source PDB as rollback plan.
So let's start..
Source: 19c DBCS with CDB name DB122 and PDB name Db19c
Target: 23c DBCS with CDB name DB1229 and PDB name Db23c (This is existing PDB on 23c DBCS)
By Default every Oracle Home have the AutoUpgrade jar file. I copied the autoupgrade.jar from 23c DBCS home to 19c DBCS home.
To use auto upgrade I created a config file called upgrade.cfg, which I store on both DBCS systems.
[oracle@source admin]$ cat upgrade.cfg
global.autoupg_log_dir=/u01/app/oracle/cfgtoollogs/autoupgrade
global.keystore=/u01/app/oracle/cfgtoollogs/keystore
upg1.source_home=/u01/app/oracle/product/19.0.0.0/dbhome_1
upg1.target_home=/u01/app/oracle/product/23.0.0.0/dbhome_1
upg1.sid=DB122
upg1.pdbs=DB19C
upg1.target_cdb=DB1229
upg1.source_dblink.DB19C=CLONEPDB 600
upg1.target_pdb_copy_option.DB19C=file_name_convert=none
upg1.target_version=23
upg1.start_time=28/12/2023 22:00:00
[oracle@source admin]$
Where:
global.autoupg_log_dir = is the location where autoupgrade logs will collect
global.keystore = this is the autoupgrade keystore where we store TDE passwords for source and target PDBs
source and target homes where specify the source and target CDB homes
sid and PDB is the source CDB and source PDB respectively.
target_CDB is the target CDB name.
source_dblink has the name of db link (clonepdb) and rate at which redo transfer.
target_pdb_copy_option = I am using ASM and OMF
start_time : This is very important parameter to specify because this parameter decide when downtime starts. At this point, AutoUpgrade refreshes the PDB for the last time and then moves on with the upgrade.
start_time is optional , if you won't specify, it right away start upgrade after the refresh.
Now we have to create a dblink that we used in the above config file:
Connect to source DBCS PDB and create a user for Db link and grant privileges.
[oracle@source ~]$ . oraenv
ORACLE_SID = [DB122] ?
The Oracle base has been set to /u01/app/oracle
[oracle@source ~]$ echo $ORACLE_SID
DB122
[oracle@source ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Dec 28 20:28:52 2023
Version 19.20.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
Connected to:
Oracle Database 19c EE High Perf Release 19.0.0.0.0 - Production
Version 19.20.0.0.0
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 DB19C READ WRITE NO
SQL> alter session set container= DB19C;
Session altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 DB19C READ WRITE NO
SQL> create user test identified by XXXXXXXXXXXXXXX;
User created.
SQL> grant create session, create pluggable database, select_catalog_role to test;
Grant succeeded.
SQL> grant read on sys.enc$ to test;
Grant succeeded.
SQL>
Now connect to Target DBCS CDB and create a db link:
SQL> create database link clonepdb connect to test identified by XXXXXXXXXXX using 'DB19C';
Database link created.
SQL> select * from dual@clonepdb;
D
-
X
Now we can analyze and execute preupgrade fixups on source PDB
[oracle@source admin]$ java -jar autoupgrade.jar -config upgrade.cfg -mode analyze
and
[oracle@source admin]$ java -jar autoupgrade.jar -config upgrade.cfg -mode fixups
We will see below error when analyze and do prefixups
Error Message:The following checks have ERROR severity and no fixup is available or
the fixup failed to resolve the issue. Fix them manually before continuing:
DB19C TDE_PASSWORDS_REQUIRED
DB19C TARGET_CDB_AVAILABILITY
For now we can safely ignore these as we will fix these on target side.
On target DBCS:
Since our PDB is encrypted, we have to add source (db122) and target CDB(db1229) TDE password to Auto Upgrade keystore that we defined in config file.
[oracle@target admin]$ java -jar autoupgrade.jar -config upgrade.cfg -load_password
Processing config file ...
Starting AutoUpgrade Password Loader - Type help for available options
Creating new AutoUpgrade keystore - Password required
Enter password:
Enter password again:
AutoUpgrade keystore was successfully created
TDE> add DB122
Enter your secret/Password:
Re-enter your secret/Password:
TDE> add DB1229
Enter your secret/Password:
Re-enter your secret/Password:
TDE> save
Convert the AutoUpgrade keystore to auto-login [YES|NO] ? yes
TDE> exit
AutoUpgrade Password Loader finished - Exiting AutoUpgrade
[oracle@target admin]$
Now we are ready to start the Auto Upgrade in deploy mode.
[oracle@target admin]$ java -jar autoupgrade.jar -config upgrade.cfg -mode deploy
AutoUpgrade 23.3.230728 launched with default internal options
Processing config file ...
Loading AutoUpgrade keystore
AutoUpgrade keystore was successfully loaded
+--------------------------------+
| Starting AutoUpgrade execution |
+--------------------------------+
1 PDB(s) will be processed
Type 'help' to list console commands
upg> Copying remote database 'DB19C' as 'DB19C' for job 100
Remote database 'DB19C' created as PDB 'DB19C' for job 100
Job 100 completed
------------------- Final Summary --------------------
Number of databases [ 1 ]
Jobs finished [1]
Jobs failed [0]
Jobs restored [0]
Jobs pending [0]
Please check the summary report at:
/u01/app/oracle/cfgtoollogs/autoupgrade/cfgtoollogs/upgrade/auto/status/status.html
/u01/app/oracle/cfgtoollogs/autoupgrade/cfgtoollogs/upgrade/auto/status/status.log
[oracle@target admin]$
So what this deploy command will do:
1. Copies the datafiles to target DBCS over the DB link.
2. Refresh the datafiles using source redo.
3. As per the start_time parameter in config file, it will do the final refresh and disconnects the PDB from source, downtime starts here.
4. Upgrade the PDB
Now let's check the target CDB for our new PDB
[oracle@target postchecks]$ sqlplus / as sysdba
SQL*Plus: Release 23.0.0.0.0 - Production on Fri Dec 29 04:58:32 2023
Version 23.3.0.23.09
Copyright (c) 1982, 2023, Oracle. All rights reserved.
Connected to:
Oracle Database 23c Enterprise Edition Release 23.0.0.0.0 - Production
Version 23.3.0.23.09
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 DB23C READ WRITE NO
5 DB19C READ WRITE NO
SQL>
We can see that PDB is there in read write mode.
So Upgrade is done and now we have upgraded PDB on 23c DBCS :)
Last thing to check, do we have this PDB on OCI console in 23c DBCS CDB. let's check.
yes we have it, so all good!
No comments:
Post a Comment