“This is the 23rd day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021”

One, foreword

With the gradual maturity of Oracle ADG technology, most database environments use ADG as the disaster recovery and reporting database, which can be said to be standard.

So if the main database due to bugs or maintenance, need to update the patch, how to operate?

How do you apply a Patchset,PSU or CPU in a Data Guard Physical Standby Configuration (Doc ID 278641.1) **

Environment Preparation:

  The host name ip DB Version db_name db_unique_name
The main library orcl 192.168.56.120 11.2.0.4 orcl orcl
For the library orcl_stby 192.168.56.121 11.2.0.4 orcl orcl_stby

Notes: The ADG environment is set up in advance and the DG Broker is configured.

Second, the process

The main steps are as follows:

1. The primary library stops log transmission. 2. Shut down the standby database, apply patches to the standby database, mount the standby database, and do not enable the log application. 3. Close the active library and apply the patch to the active library. 4. Enable the primary database and log transmission. 5. Enable the log application for the standby database. 6. Check whether the patch is successfully installed.Copy the code

Detailed operation steps are as follows:

1. The primary library stops log transmission.

# if DG Broker has been configured
dgmgrl sys/oracle@orcl
edit database orcl set state='LOG-TRANSPORT-OFF';


## DG Broker is not configured
SQL> alter system set log_archive_dest_state_2=defer scope=both sid=The '*';
Copy the code

2. Shut down the standby database, apply patches to the standby database, mount the standby database, and do not enable the log application.

A. Close the standby database instance and listen

##Non-rac
shutdown immediate
lsnrctl stop
 
##rac
srvctl stop database -d orcl
srvctl stop listener
srvctl stop scan_listner
Copy the code

B. replace OPatch

cd/ u01 / app/oracle/product / 11.2.0 / db/mv OPatch/OPatch0421 unzip - q/soft/p6880880_112000_Linux - x86-64. The zip OPatch versionCopy the code

C. Apply patches (according to Readme)

unzip -q p31537677_112040_Linux-x86-64.zip
cd 31537677 
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
opatch apply
Copy the code

If Opatch Apply encounters a warning, please refer to ****11204 Warning: ins_emagent.mk ‘nmosudo’ when hitting PSU

D. Enable the standby database to mount

You need to set apply-off to prevent the logging application from automatically starting
edit database orcl_stby set state='APPLY-OFF';

##Non-rac
startup mount
lsnrctl start

##rac
srvctl start database -d orcl -o mount
srvctl start listener
srvctl start scan_listener

Copy the code

3. Close the active library and apply the patch to the active library.

Refer to the standby database patch application process, which is skipped here.

4. Enable the primary database and log transmission.

A. Enable the primary database and enable listening

B. Run the PSU upgrade script

For details about the catbundle script, see Introduction To Oracle Database catbundle. SQL (Doc ID 605795.1)

-- Execute the catBundle script
cd $ORACLE_HOME/rdbms/admin
sqlplus / as sysdba
@catbundle.sql psu apply

-- Compile invalid objects
@utlrp.sql

-- Execute the dbms_java_dev script
@dbmsjdev.sql
exec dbms_java_dev.disable
Copy the code

C. Enable log transmission

edit database orcl set state='ONLINE';
Copy the code

5. Enable the log application for the standby database.

This will make through catupgrade catbundle/catcpu script changes to the database has been applied to the case library.

Configure the DG Broker and enable apply-on
edit database orcl_stby set state='ONLINE';

Read only; enable ADG
alter database open;
Copy the code

6. Check whether the patch is successfully installed.

The main library:

opatch lspatches
select action_time,action,version,id,bundle_series,comments from dba_registry_history;
Copy the code

For library:

opatch lspatches
select action_time,action,version,id,bundle_series,comments from dba_registry_history;
Copy the code

Check ADG synchronization:

## DG Broker has been configured
show database orcl
show database orcl_stby

## DG Broker is not configured
select process,group#,thread#,sequence# from v$managed_standby;
select group#,thread#,sequence#,bytes/1024/1024,archived,status from v$standby_log;
Copy the code

Select * from test where id = 1;

Check whether the backup database is synchronized:

The standby database has been deleted in real time, and the ADG is properly synchronized.