Wednesday, May 31, 2023

Upgrade from 19c to 21c Using Autoupgrade

This post shows the steps for upgrading a 19c database (CDB + PDB) with autoupgrade tool. There's an earlier post which shows upgrading PDB form 19c to 21 using unplug-plug-upgrade method.
If any privileges were reovked from public due to security reason (CIS standard recommendations) then grant those privileges back before starting the ugprade process. Once the upgrade is completed then those privilges could be revoked again.
Generate a sample upgrade config file with
java -jar autoupgrade.jar -create_sample_file config normalupgrade.cfg
and customize the "Full DB/CDB upgrade" section.
global.autoupg_log_dir=/home/oracle/autoupgrade

#
# Database number 1 - Full DB/CDB upgrade
#
upg1.log_dir=/home/oracle/autoupgrade/testcdb             # Path of the log directory for the upgrade job
upg1.sid=testcdb                                              # ORACLE_SID of the source DB/CDB
upg1.source_home=/opt/app/oracle/product/19.x.0/dbhome_2  # Path of the source ORACLE_HOME
upg1.target_home=/opt/app/oracle/product/21.x.0/dbhome_1  # Path of the target ORACLE_HOME
upg1.start_time=NOW                                       # Optional. [NOW | +XhYm (X hours, Y minutes after launch) | dd/mm/yyyy hh:mm:ss]
upg1.upgrade_node=ip-172-31-10-91.eu-west-1.compute.internal                                # Optional. To find out the name of your node, run the hostname utility. Default is 'localhost'
upg1.run_utlrp=yes                                  # Optional. Whether or not to run utlrp after upgrade
upg1.timezone_upg=yes                               # Optional. Whether or not to run the timezone upgrade
upg1.target_version=21                      # Oracle version of the target ORACLE_HOME.  Only required when the target Oracle database version is 12.2
The databae being upgraded is called testcdb. The source home is the 19c home and the target home is the 21c home. DB timezone is also upgraded the same time.
Run the autoupgrade mode in analyze mode to check the ugprade readiness of the database.
java -jar autoupgrade.jar -config normalupgrade.cfg -mode analyze
This will generate a status report (status.html) at the end. Cheeck for any pre-req work that need to be carried out manually before the upgrade.

Run autougprade in fixup mode to execute preupgrade fixes.
java -jar autoupgrade.jar -config normalupgrade.cfg -mode fixups

Finally run the autoupgrade in deploy mode to commence the upgrade.
java -jar autoupgrade.jar -config normalupgrade.cfg -mode deploy

If upgrade is successful then drop the GRP associated with it. It is important that GRP is dropped before increasing the compatibility.
To change the compatibility update the compatibility parameter and restart the database.
SQL> alter system set compatible='21.0.0' scope=spfile;
Following will be shown in the alert log.
ALERT: Compatibility of the database is changed from 19.0.0.0.0 to 21.0.0.0.0.
Increased the record size of controlfile section 15 to 104 bytes
Control file expanded from 1156 blocks to 1158 blocks
One of the postupgrade tasks is to run the $ORACLE_HOME/rdbms/admin/auditpostupgrade.sql script (mentioned in 2659172.1 as well). However, this script is not available in 21c home (checked on 21.7 and 21.8 the last RU at the time of this post). After raising an SR oracle support confirmed that script is there on 23c and at the moment not avialable on 21c. So for the time being to ignore the execution of auditpostupgrade.sql script.

Related Posts
Upgrading Oracle Restart from 19c to 21c on RHEL 7
Unplug-Plug-Upgrade from 19c to 21c Using Autoupgrade