Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Patching Primary and Standby Databases

Configured with Oracle Data Guard with


Enterprise Manager 12c
To patch the primary and standby databases that are configured with Oracle Data
Guard, you can use the standard patch plans and the deployment procedures. The databases that
act as primary or standby can be either a standalone database (single-instance) or an Oracle Real
Application Cluster (Oracle RAC) database running with or without a broker.

However, the following are the limitations with patching of primary and standby
databases:

■ There is no support for orchestrated patching between a primary database and its standby
database. Although the default database patching deployment procedures automatically identify
the primary and the standby databases, they do not recognize the association between them. As a
result, you must manually identify the primary database and its associated standby database, and
patch them separately in such a way that the standby database switches over to production
mode while the primary database is being patched.

■ There is no support automatically stopping and starting log shipping. You must manually
stop and start the log shipping either directly or via a broker. The deployment procedures do not
handle this by default. However, if you want, you can customize the deployment procedure to
include additional steps that will handle this issue.

■ There is no support for Oracle Data Guard in logical standby configuration.

To patch the primary and the standby database, follow these steps:
1. If you want to handle the Log shipping, customize the database patching deployment
procedure to include additional steps to handle stopping and starting of log shipping with or
without a broker.
2. Identify the primary and standby database.
3. Patch the standby database via the patch plan and select the procedure created in Step #1.
4. Patch the primary database via the patch plan and select the procedure created in Step #1.
Customization of Patching Deployment Procedure:

You require to customize the procedure to insert two steps, one to stop the log shipping on the
Primary and then other to start the log shipping back at the end of the patching process.

1) From the Enterprise Menu, select Procedure Library under Provisioning and Patching.

2) Select the Deployment Procedure based on the target type and the patching option. Either
“Patch Oracle Database”, “Clone and Patch Oracle Database” for Oracle Databases or
“Patch Oracle RAC Rolling” procedure for the Oracle RAC Databases.

3) Do ‘Create Like’ of the procedure and select the ‘Procedure Steps’. Note: The EM user
needs to have the role of a Patch Designer to perform this operation.

4) Select the steps ‘Pre-Shutdown Custom Host Command Step’ and ‘Post-Apply SQL
Custom Host Command Step’ and click “Enable”
5) Select and Edit the step ‘ Pre-Shutdown Custom Host Command Step’. Copy paste the
following script below into the step. Refer to the picture below for details.

# Script for Stopping Log Shipping on Primary Database, Insert before Shutdown Database step

echo ' Executing Stop Log Shipping command on Primary Database'

PRIMDB_LIST=${target.primaryDBSIDs}
DGMGRL_CMD=${target.oraHome}/bin/dgmgrl
STATE='LOG-TRANSPORT-OFF'

if [ -z $PRIMDB_LIST ]
then
echo " Selected Databases are not Primary Databases found. Step will be skipped"
exit 0
fi

PRIMDB_SPCSEP_LIST=`echo $PRIMDB_LIST | tr ',' ' '`


for EACH_PRIMDB in $PRIMDB_SPCSEP_LIST
do

echo Running $DGMGRL_CMD on $EACH_PRIMDB


export ORACLE_HOME=${target.oraHome}
export ORACLE_SID=$EACH_PRIMDB
$DGMGRL_CMD -silent / "edit database $EACH_PRIMDB SET STATE=$STATE"
$DGMGRL_CMD -silent / "show database $EACH_PRIMDB"
done
exit 0
Figure 1: Host Command Step with the Script to Start/Stop Log Shipping

6) Select and Edit the step ‘Post-Apply SQL Custom Host Command Step’. Copy paste the
following script below into the step. Refer to the picture below for details.
# Script for Starting Log Shipping on Primary Database, Insert after Apply Post SQL step

echo ' Executing Start Log Shipping command on Primary Database'

PRIMDB_LIST=${target.primaryDBSIDs}
DGMGRL_CMD=${target.oraHome}/bin/dgmgrl
STATE=' ONLINE '

if [ -z $PRIMDB_LIST ]
then
echo " Selected Databases are not Primary Databases found. Step will be skipped "
exit 0
fi

PRIMDB_SPCSEP_LIST=`echo $PRIMDB_LIST | tr ',' ' '`


for EACH_PRIMDB in $PRIMDB_SPCSEP_LIST
do
echo Running $DGMGRL_CMD on $EACH_PRIMDB
export ORACLE_HOME=${target.oraHome}
export ORACLE_SID=$EACH_PRIMDB
$DGMGRL_CMD -silent / "edit database $EACH_PRIMDB SET STATE=$STATE"
$DGMGRL_CMD -silent / "show database $EACH_PRIMDB"
done
exit 0

7) Save the procedure with the new name, say ‘Patch Oracle Database in Physical Standby
Configuration’.

8) While creating a Patch plan for patching the Primary and Standby Oracle Databases,
select the procedure under deployment options.

You might also like