Thursday, January 2, 2025

Step By Step Oracle Database 19c Release Update (DB+OJVM) for Single Instance (19.24 to 19.25)

 

Step By Step Oracle Database 19c Release Update   (DB+OJVM) for Single Instance (19.24 to 19.25)


Step by Step Document  how to perform Oracle Database 19c Release Update (DB+OJVM) for Single Instance (19.24 to 19.25). I hope it will be useful for those who need it!

High Level Steps

1-Prerequisites

2-Download Patches

3- Copy Patches to Servers

4- Check & Update OPATCH Utility

5- Verify the Database Current Version

6-Take Necessary Backups

7-Pre Patch Steps

8-Patch Steps

9-Post Patch Steps

10-Patch Deinstallation Steps (If Needed)

Low Level Steps

1-Prerequisites

2-Download Patches

3-Copy Patches to Servers

I have copied patches to /u01/software/ directory.

4-Check & Update OPATCH Utility

You must use the OPatch utility version 12.2.0.1.43 or later to apply this patch.

Check OPATCH version

Check Version

sudo su -
su - oracle
. oraenv
cd $ORACLE_HOME/OPatch
./opatch version

# Sample Output
[oracle@oraclelinux810-test OPatch]$ ./opatch version
OPatch Version: 12.2.0.1.44
OPatch succeeded.
[oracle@oraclelinux810-test OPatch]$

Backup Current OPatch (Skip if you have the latest version of OPatch)

cd $ORACLE_HOME
mv OPatch OPatch_12.2.0.1.43

Upgrade OPATCH (Skip if you have the latest version of OPatch)

cd /u01/software/
unzip /u01/software/p6880880_190000_Linux-x86-64 -d $ORACLE_HOME/

Check Version

cd $ORACLE_HOME/OPatch
./opatch version

5-Verify the Database Current Version

Using the below command verify the current version details and some other information related to the database.

sqlplus / as sysdba

select BANNER_FULL from v$version;

BANNER_FULL
--------------------------------------------------------------------------------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0
col comp_id for a10
col version for a11
col status for a10
col comp_name for a37
select comp_id,comp_name,version,status from dba_registry;

COMP_ID    COMP_NAME                             VERSION     STATUS
---------- ------------------------------------- ----------- ----------
CATALOG    Oracle Database Catalog Views         19.0.0.0.0  VALID
CATPROC    Oracle Database Packages and Types    19.0.0.0.0  VALID
RAC        Oracle Real Application Clusters      19.0.0.0.0  OPTION OFF
JAVAVM     JServer JAVA Virtual Machine          19.0.0.0.0  VALID
XML        Oracle XDK                            19.0.0.0.0  VALID
CATJAVA    Oracle Database Java Packages         19.0.0.0.0  VALID
APS        OLAP Analytic Workspace               19.0.0.0.0  VALID
XDB        Oracle XML Database                   19.0.0.0.0  VALID
OWM        Oracle Workspace Manager              19.0.0.0.0  VALID
CONTEXT    Oracle Text                           19.0.0.0.0  VALID
ORDIM      Oracle Multimedia                     19.0.0.0.0  VALID
SDO        Spatial                               19.0.0.0.0  VALID
XOQ        Oracle OLAP API                       19.0.0.0.0  VALID
OLS        Oracle Label Security                 19.0.0.0.0  VALID
DV         Oracle Database Vault                 19.0.0.0.0  VALID

15 rows selected.

6-Take Necessary Backups

Due to any type of error if patching got failed, then you must have a backup plan.

  • Take Oracle Home Backup
  • Take Central Inventory Backup
  • Create Guaranteed Restore Point

Take Oracle Home Backup (if you have enough disk space)

How to Perform ORACLE_HOME Backup? (Doc ID 565017.1)

# Backup
# (Suggested but not mandatory) Shutdown databases, listeners, or any other processes related to the ORACLE_HOME which you are taking backup.
# Make sure there is enough free disk space before doing the backup.
cd /u01/app/oracle/product/<version>/
tar -pcvf /u01/backup/oracle_home_bkup_DDMMYYYY.tar <dbhomename>


# Restore
# (This step would be mandatory in the case of restore) Shutdown databases, listeners, or any other processes related to the ORACLE_HOME which you are restoring.
cd /u01/app/oracle/product/<version>/
mv <dbhomename> <dbhomename_DDMMYYYY>
tar -pxvf /u01/backup/oracle_home_bkup_DDMMYYYY.tar

Take Central Inventory Backup

# Backup
# (Suggested but not mandatory) Shutdown databases, listeners, or any other processes related to the ORACLE_HOME which you are taking backup.
more /etc/oraInst.loc
cd /u01/app/
tar -pcvf /u01/backup/oraInventoryBackup_DDMMYYYY.tar oraInventory

# Restore
# (This step would be mandatory in the case of restore) Shutdown databases, listeners, or any other processes related to the ORACLE_HOME which you are restoring.
cd /u01/app/
mv oraInventory oraInventory_DDMMYYYY
tar -pxvf /u01/backup/oraInventoryBackup_DDMMYYYY.tar

Create Guaranteed Restore Point

# Create Guaranteed Restore Point
1. $> su – oracle
2. $> sqlplus / as sysdba;
3. Find out if ARCHIVELOG is enabled
   SQL> select log_mode from v$database;
   If step 3 shows that ARCHIVELOG is not enabled then continue else skip to step 8 below.
4. SQL> shutdown immediate;
5. SQL> startup mount;
6. SQL> alter database archivelog;
7. SQL> alter database open;
8. SQL> create restore point before_upgrade guarantee flashback database;
   where CLEAN_DB is the name given to the guaranteed restore point.
9. Viewing the guaranteed restore point
   SQL> select * from v$restore_point;
   Verify the information about the newly created restore point. Also, note down the SCN# for
   reference and we will refer to it as "reference SCN#"

# Flashback to the Guaranteed Restore Point
1. $> su – oracle
2. $> sqlplus / as sysdba;
3. SQL> select current_scn from v$database;
4. SQL> shutdown immediate;
5. SQL> startup mount;
6. SQL> select * from v$restore_point;
7. SQL> flashback database to restore point before_upgrade;
8. SQL> alter database open resetlogs;
9. SQL> select current_scn from v$database;
Compare the SCN# from step 9 above to the reference SCN#.
NOTE: The SCN# from step 9 above may not necessarily be the exact SCN# as the reference SCN# but it will be close enough.

# Drop Guaranteed Restore Point
drop restore point before_upgrade;

7-Pre Patch Steps

Unzip the Patches

cd /u01/software/

unzip /u01/software/p36912597_190000_Linux-x86-64.zip -d /u01/software/

unzip /u01/software/p36878697_190000_Linux-x86-64.zip -d /u01/software/

Check Conflict

cd /u01/software/36912597

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./

cd /u01/software/36878697

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./

Stop All Database Services

Check how many instances & listener is running on the machine.

ps -ef|grep pmon

oracle      2124       1  0 Dec16 ?        00:00:01 ora_pmon_orcl

Check the Listener status.

ps -ef|grep tns

oracle      6524       1  0 00:48 ?        00:00:00 /u01/app/oracle/product/19.3/db_home/bin/tnslsnr LISTENER -inherit

On my machine, one instance and one listener are currently running, letting down both services.

lsnrctl stop LISTENER

Shutdown Database

sqlplus / as sysdba

shut immediate

8-Patch Steps

Make sure 7 GB of disk space is free in your binary location otherwise the patch will be failed.

Execute opatch apply

cd /u01/software/36912597

$ORACLE_HOME/OPatch/opatch apply

cd /u01/software/36878697

$ORACLE_HOME/OPatch/opatch apply

Start All Database Services

Once opatch apply successfully, then start all the database services.

Start Listener

lsnrctl start LISTENER

Start Database

sqlplus / as sysdba

startup

Check Database

select instance_name ||'  '||version||'  '||startup_time||'  '||database_status from gv$instance;

INSTANCE_NAME||''||VERSION||''||STARTUP_TIME||''||DATABASE_STATUS
---------------------------------------------------------------------------
orcl  19.0.0.0.0  2024-12-17:12:51:04  ACTIVE


select name, open_mode, database_role, log_mode from gv$database;

NAME      OPEN_MODE            DATABASE_ROLE    LOG_MODE
--------- -------------------- ---------------- ------------
ORCL      READ WRITE           PRIMARY          NOARCHIVELOG

9-Post Patch Steps

Now it’s time to run datapatch -verbose which updates the patch information at the database binary & dictionary level as well as binary files.

Run datapatch -verbose

Important Note: For each separate database running on the same shared Oracle home being patched, run the datapatch utility

. oraenv

cd $ORACLE_HOME/OPatch

./datapatch -sanity_checks (optional)

./datapatch -verbose

Execute utlrp.sql

Once datapatch -verbose is completed then execute the utlrp script to validate the invalid objects.

sqlplus / as sysdba

@?/rdbms/admin/utlrp.sql

Verify the Patch at OS Level

Check applied patch details using lsinventory command.

cd $ORACLE_HOME/OPatch

./opatch lsinventory | grep 36912597

./opatch lsinventory | grep 36878697

Verify the Patch at DB Level

sqlplus / as sysdba

col action for a8
col status for a10
col action_time for a28
col description for a60
set line 999 pages 999
select patch_uid,patch_id,SOURCE_VERSION, TARGET_VERSION, action, status,action_time,description from dba_registry_sqlpatch order by action_time desc;

Check Invalid Objects

COLUMN object_name FORMAT A30
SELECT owner,object_type,object_name,status FROM dba_objects
WHERE status = 'INVALID'
ORDER BY owner, object_type, object_name;

no rows selected

Check DBA_REGISTRY

col comp_id for a10
col version for a11
col status for a10
col comp_name for a37
select comp_id,comp_name,version,status from dba_registry;

COMP_ID    COMP_NAME                             VERSION     STATUS
---------- ------------------------------------- ----------- ----------
CATALOG    Oracle Database Catalog Views         19.0.0.0.0  VALID
CATPROC    Oracle Database Packages and Types    19.0.0.0.0  VALID
RAC        Oracle Real Application Clusters      19.0.0.0.0  OPTION OFF
JAVAVM     JServer JAVA Virtual Machine          19.0.0.0.0  VALID
XML        Oracle XDK                            19.0.0.0.0  VALID
CATJAVA    Oracle Database Java Packages         19.0.0.0.0  VALID
APS        OLAP Analytic Workspace               19.0.0.0.0  VALID
XDB        Oracle XML Database                   19.0.0.0.0  VALID
OWM        Oracle Workspace Manager              19.0.0.0.0  VALID
CONTEXT    Oracle Text                           19.0.0.0.0  VALID
ORDIM      Oracle Multimedia                     19.0.0.0.0  VALID
SDO        Spatial                               19.0.0.0.0  VALID
XOQ        Oracle OLAP API                       19.0.0.0.0  VALID
OLS        Oracle Label Security                 19.0.0.0.0  VALID
DV         Oracle Database Vault                 19.0.0.0.0  VALID
15 rows selected.

10-Patch Deinstallation Steps (If Needed)

Patch Deinstallation Instructions

Shut down all instances and listeners associated with the Oracle home that you are updating.

sudo su -
su - oracle
. oraenv
lsnrctl stop LISTENER
sqlplus / as sysdba
shut immediate
quit
cd $ORACLE_HOME/OPatch
opatch rollback -id 36912597
opatch rollback -id 36878697

Rollback SQL Changes from the the Database

Datapatch is run to complete the post-deinstall SQL deployment for the patch being deinstalled.

Important Note: For each separate database running on the same shared Oracle home being patched, run the datapatch utility.

lsnrctl start LISTENER
sqlplus / as sysdba
startup
quit
cd $ORACLE_HOME/OPatch
./datapatch -sanity_checks (optional)
./datapatch -verbose