26 Patching Primary and Standby Databases Configured with Oracle Data Guard

This chapter describes the following:

Overview of Patching Primary and Standby Databases

To patch the primary and standby databases that are configured with Oracle Data Guard, you can use the default database patching deployment procedures described in Part VI. 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.

Patching Primary and Standby Databases

To patch the primary and the standby database, follow these steps:

  1. Customize the database patching deployment procedure as described in Customizing 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 using the deployment procedure.

  4. Patch the primary database using the deployment procedure.

Customizing Patching Deployment Procedure

To automate the stopping and starting of log shipping, you must customize the patching deployment procedure to include two steps—one to stop the log shipping on the primary database and another to start the log shipping once the patching operation ends.

To do so, follow these steps:

  1. On the Deployment Procedure Manager page, select one of the following patching deployment procedure based on the target type you want to patch, and click Create Like.

    • Patch Oracle Database, for Oracle Database

    • Patch Oracle RAC Rolling, for the Oracle RAC Databases

  2. On the Create Like page, select the step Stop Database in Normal Mode, and insert a new step of the type Host Command. Ensure that you insert the new step before the step Shutdown Database.

  3. On the Create Host Command Step, in the Script textbox, copy the following lines:

    # 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 26-1 shows how the Script textbox will look after you copy the preceeding lines.

    Figure 26-1 Creating a New Host Command for Starting and Stopping the Log Shipping

    Surrounding text describes Figure 26-1 .
  4. On the Create Like page, select the step Apply Post SQL Script, and insert a new step of the type Host Command. Ensure that you insert the step after the step Apply post SQL script.

  5. On the Create Host Command Step, in the Script textbox, copy the following lines:

    # 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
    
  6. Save the customized deployment procedure with a unique name. For example, Patch Oracle Database in Physical Standby Configuration. Use this procedure for patching the primary and the standby databases.

Note:

You can customize the deployment procedure even further if you want. For more information on customizing deployment procedures, refer to Chapter 31.