DBA Hub

📋Steps in this guide1/8

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

This article gives an example of applying a database Release Update (RU) to a new 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 database software, OPatch and patch file names, and the paths.

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
export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_BASE=/u01/app/oracle
export SOFTWARE_DIR=/u01/software

# 19c
export OLD_ORACLE_HOME=${ORACLE_BASE}/product/19.0.0/dbhome_1
export NEW_ORACLE_HOME=${ORACLE_BASE}/product/19.16.0/dbhome_1
export DB_SOFTWARE="LINUX.X64_193000_db_home.zip"
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 OLD_ORACLE_HOME=${ORACLE_BASE}/product/21.0.0/dbhome_1
export NEW_ORACLE_HOME=${ORACLE_BASE}/product/21.7.0/dbhome_1
export DB_SOFTWARE="LINUX.X64_213000_db_home.zip"
export OPATCH_FILE="p6880880_210000_Linux-x86-64.zip"
export PATCH_FILE="p34160444_210000_Linux-x86-64.zip"
export PATCH_TOP=${SOFTWARE_DIR}/34160444
3

Create the New ORACLE_HOME

We create a new by doing a software-only install. Create the new and unzip the base software into it. Update OPatch in the new home. Unzip the release update. Install the Oracle software in the new home, applying the RU as part of the installation process. Notice we are referencing the location in the command, and we unset the variable, just to be on the safe side. Run the root scripts as instructed. We now have the newly patched home, so we are ready to patch the database.

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
mkdir -p ${NEW_ORACLE_HOME}
cd ${NEW_ORACLE_HOME}
unzip -oq ${SOFTWARE_DIR}/${DB_SOFTWARE}

cd ${NEW_ORACLE_HOME}
rm -Rf OPatch
unzip -oq ${SOFTWARE_DIR}/${OPATCH_FILE}

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

unset ORACLE_HOME
cd ${NEW_ORACLE_HOME}

${
NEW_ORACLE_HOME
}/runInstaller -ignorePrereq -waitforcompletion -silent       \
    -applyRU ${PATCH_TOP}                                                      \
    -responseFile ${
NEW_ORACLE_HOME
}/install/response/db_install.rsp           \
    oracle.install.option=INSTALL_DB_SWONLY                                    \
    ORACLE_HOSTNAME=${ORACLE_HOSTNAME}                                         \
    UNIX_GROUP_NAME=oinstall                                                   \
    INVENTORY_LOCATION=${ORA_INVENTORY}                                        \
    SELECTED_LANGUAGES=en,en_GB                                                \
    ORACLE_HOME=${
NEW_ORACLE_HOME
}                                             \
    ORACLE_BASE=${ORACLE_BASE}                                                 \
    oracle.install.db.InstallEdition=EE                                        \
    oracle.install.db.OSDBA_GROUP=dba                                          \
    oracle.install.db.OSBACKUPDBA_GROUP=dba                                    \
    oracle.install.db.OSDGDBA_GROUP=dba                                        \
    oracle.install.db.OSKMDBA_GROUP=dba                                        \
    oracle.install.db.OSRACDBA_GROUP=dba                                       \
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false                                 \
    DECLINE_SECURITY_UPDATES=true

# 19c
As a root user, execute the following script(s):
        1. /u01/app/oracle/product/19.16.0/dbhome_1/root.sh

# 21c
As a root user, execute the following script(s):
        1. /u01/app/oracle/product/21.7.0/dbhome_1/root.sh
4

Patch the Database

To patch the database we need to switch it to the new and run the datapatch utility in the normal way. Turn off all the services in the current . Edit the "/etc/oratab" file, setting the new home for the instance. In previous releases we would need to copy the following files between the homes, but in 21c onward this is not necessary, as we are using read-only homes, so all the configuration files are no longer stored in the same place as the binaries. - "ORACLE_HOME/dbs" : Copy password file, SPFILE and the instance init{ORACLE_SID}.ora file if it is present. - "ORACLE_HOME/network/admin" : Copy the network config files. Amend any paths referenced in the files. Make sure we are using the new . 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
export ORACLE_SID=cdb1
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

dbshut ${ORACLE_HOME}

# 19c
#cdb1:/u01/app/oracle/product/19.0.0/dbhome_1:Y
cdb1:/u01/app/oracle/product/19.16.0/dbhome_1:Y

# 21c
#cdb1:/u01/app/oracle/product/21.0.0/dbhome_1:Y
cdb1:/u01/app/oracle/product/21.7.0/dbhome_1:Y

# 19c
cp ${OLD_ORACLE_HOME}/dbs/*${ORACLE_SID}* ${NEW_ORACLE_HOME}/dbs/
cp ${OLD_ORACLE_HOME}/dbs/*${ORACLE_SID^^}* ${NEW_ORACLE_HOME}/dbs/

cp ${OLD_ORACLE_HOME}/network/admin/*.ora ${NEW_ORACLE_HOME}/network/admin/
sed -i -e "s|${OLD_ORACLE_HOME}|${NEW_ORACLE_HOME}|g" ${NEW_ORACLE_HOME}/network/admin/*.ora

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

echo ${ORACLE_HOME}
/u01/app/oracle/product/21.7.0/dbhome_1
$

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
5

Clean Up

If we have any additional environment files or scripts containing paths that include the , they will need to be adjusted. Clean up the patch software. At some point we will need to remove the old .

Code/Command (click line numbers to comment):

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

Check the Patch History

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

Code/Command (click line numbers to comment):

1
${ORACLE_HOME}/OPatch/opatch lsinventory
7

Rollback the Patch

To rollback the patch we need to switch it to the old and run the datapatch utility in the normal way. Shutdown the services run from the . Edit the "/etc/oratab" file, setting the original home for the instance. Make sure we are using the original . 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
33
34
35
36
37
38
dbshut ${ORACLE_HOME}

# 19c
cdb1:/u01/app/oracle/product/19.0.0/dbhome_1:Y
#cdb1:/u01/app/oracle/product/19.16.0/dbhome_1:Y

# 21c
cdb1:/u01/app/oracle/product/21.0.0/dbhome_1:Y
#cdb1:/u01/app/oracle/product/21.7.0/dbhome_1:Y

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

echo ${ORACLE_HOME}
/u01/app/oracle/product/21.0.0/dbhome_1
$

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
8

Pros and Cons

Pros: - Patching to a new is quicker, because the patches to the binaries are done while the database is still running in the original home. We only need downtime while we switch between homes, and run the datapatch utility. - We have the original , should we need to switch back. - If we have multiple instances sharing the same , we can patch them separately by being selective about which databases we turn off and on. Cons: - We need additional disk space for the new . - If we are not using a read-only , wee need to copy config files between homes during the switch. - If we have any additional environment files or scripts containing paths that include the , they will need to be adjusted. - We will need to clean up the old at some point. For more information see: - Critical Patch Updates, Security Alerts and Bulletins - Patching : Apply a Release Update (RU) to an Existing ORACLE_HOME Hope this helps. Regards Tim...

Comments (0)

Please to add comments

No comments yet. Be the first to comment!