DBA Hub

📋Steps in this guide1/7

Patching : Apply a Database Release Update (RU) to an Existing ORACLE_HOME

This article gives an example of applying a database Release Update (RU) to an existing ORACLE_HOME for a simple single-instance Oracle database.

oracle miscconfigurationintermediate
by OracleDba
13 views
1

Assumptions

This article makes some assumptions.
2

Environment

Set up the environment. This includes the OPatch and patch file names, and the paths. Notice how OPatch has been added to the environment variable.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export SOFTWARE_DIR=/u01/software

# 19c
export OPATCH_FILE="p6880880_190000_Linux-x86-64.zip"
export PATCH_FILE="p34133642_190000_Linux-x86-64.zip"
export PATCH_TOP=${SOFTWARE_DIR}/34133642

# 21c
export OPATCH_FILE="p6880880_210000_Linux-x86-64.zip"
export PATCH_FILE="p34160444_210000_Linux-x86-64.zip"
export PATCH_TOP=${SOFTWARE_DIR}/34160444

export PATH=${ORACLE_HOME}/OPatch:${PATH}

export ORACLE_SID=cdb1
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES
3

Apply the Patch

Keep a copy of the existing OPatch, and unzip the latest version of OPatch. Unzip the patch software. Shutdown the services run from the . Apply the patch. Start the listener. Start the database, making sure all pluggable databases are open. Run datapatch. Recompile any invalid objects.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
cd ${ORACLE_HOME}
mv OPatch OPatch.`date +"%Y"-"%m"-"%d"`
unzip -oq ${SOFTWARE_DIR}/${OPATCH_FILE}

cd ${SOFTWARE_DIR}
unzip -oq ${PATCH_FILE}

dbshut ${ORACLE_HOME}

cd ${PATCH_TOP}
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
opatch apply -silent

lsnrctl start

sqlplus / as sysdba <<EOF
startup;
alter pluggable database all open;
exit;
EOF

cd $ORACLE_HOME/OPatch
./datapatch -verbose

$ORACLE_HOME/perl/bin/perl \
    -I$ORACLE_HOME/perl/lib \
    -I$ORACLE_HOME/rdbms/admin \
    $ORACLE_HOME/rdbms/admin/catcon.pl \
    -l /tmp/ \
    -b postpatch_${ORACLE_SID}_recompile \
    -C 'PDB$SEED' \
    $ORACLE_HOME/rdbms/admin/utlrp.sql
4

Clean Up

Clean up the patch software.

Code/Command (click line numbers to comment):

1
2
3
4
5
cd ${SOFTWARE_DIR}
rm -Rf ${PATCH_TOP}
rm -Rf ${OPATCH_FILE}
rm -Rf ${PATCH_FILE}
rm -Rf PatchSearch.xml
5

Check the Patch History

We can check the patch history by running the following command.

Code/Command (click line numbers to comment):

1
opatch lsinventory
6

Rollback the Patch

Shutdown the services run from the . Rollback the patch. Start the listener. Start the database, making sure all pluggable databases are open. Run datapatch. Recompile any invalid objects.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
dbshut ${ORACLE_HOME}

# 19c
opatch rollback -id 34133642 -silent

# 21c
opatch rollback -id 34160444 -silent

lsnrctl start

sqlplus / as sysdba <<EOF
startup;
alter pluggable database all open;
exit;
EOF

cd $ORACLE_HOME/OPatch
./datapatch -verbose

$ORACLE_HOME/perl/bin/perl \
    -I$ORACLE_HOME/perl/lib \
    -I$ORACLE_HOME/rdbms/admin \
    $ORACLE_HOME/rdbms/admin/catcon.pl \
    -l /tmp/ \
    -b postpatch_${ORACLE_SID}_recompile \
    -C 'PDB$SEED' \
    $ORACLE_HOME/rdbms/admin/utlrp.sql
7

Pros and Cons

Pros: - We don't have an additional , so this reduces the space needed to complete the patching. - Since the isn't changing, we don't need to worry about altering any configuration files to point at the new home. Cons: - Patching the existing requires more downtime, as the services must be offline while the home is being patched. - If something goes wrong that can't be fixed by rolling back the patch, we may have to recover the from a backup to restore the original running instance. - All databases runing under the have to be patched at the same time. For more information see: - Critical Patch Updates, Security Alerts and Bulletins - Patching : Apply a Release Update (RU) to a New ORACLE_HOME Hope this helps. Regards Tim...

Comments (0)

Please to add comments

No comments yet. Be the first to comment!