2.1 Practice 12 Apply Patch Set Using DBMS - ROLLING
2.1 Practice 12 Apply Patch Set Using DBMS - ROLLING
Purpose In this practice we will use DBMS_ROLLING package to apply patch set
number 22646084 on a Data Guard environment.
Hardware About 125 GB is required for the appliances used in this practice.
Downloading Opatch
Observe the options selected to download the Opatch from support.oracle.com in the following
screenshot:
1. Make a copy of the appliances that your created in the “Practice 3 Configure the Broker”. Give the
new folder the name “Practice 12 Rolling Upgrade”.
# on srv2
tail -f /u01/app/oracle/diag/rdbms/oradb_s2/ORADB_S2/trace/alert_ORADB_S2.log
8. Login to Oracle Support site (support.oracle.com) and download the patch set number 22646084 for
Linux x86-64. It is about 1.27 GB size.
This patch set will be applied on both the GI home and Oracle database home.
9. Make directory in both servers to copy the patch set file to it.
# srv1 and srv2
su - grid
mkdir ~/patches
10. To each host, copy the Opatch upgrade zip file (p6880880_121010_Linux-x86-64) and the Patch Set
zip file (p22646084_121020_Linux-x86-64.zip) to the directory /home/grid/patches using the WinScp
utility.
11. In each host, make the grid user the owner of the newly created directory.
su -
chown -R grid:oinstall /home/grid/patches/
12. We have already configured all the prerequisites in those machines in practice number 3. Refer to the
previous lecture to obtain the list of the prerequisites. In our case, no action is actually needed at this
stage.
13. EDS functionality requires enabling Supplemental Logging in the primary database. Run the following
command in each database.
su - oracle
14. Check which objects have datatypes unsupported by the logical standby database:
Our demo database has more than 100 unsupported tables. In a production database, you need to put on
a plan to handle all of them. Refer to the lecture “Managing Logical Standby Database” for more
information. In this practice, for demo purposes, we will implement EDS on a single table (CUSTOMERS).
conn sys/oracle@oradb as sysdba
16. Make note of the tables to be added to the EDS. You will add them when the LGM is converted to a
transient logical standby database.
18. Set the VALID_FOR attribute in both databases. This is required for the switchover to the logical
standby database to succeed. Refer to the lecture “Creating a Logical Standby Database” for further
details.
# in the primary database (oradb):
# create the destination of the archived redo log files of the standby redo log files:
su - grid
asmcmd
cd FRA/ORADB/ARCHIVELOG
mkdir ARCHREDOLOG
# in oradb_s2:
su - grid
asmcmd
cd FRA/ORADB_S2/ARCHIVELOG
mkdir ARCHREDOLOG
su - oracle
sqlplus sys/oracle@oradb_s2 as sysdba
show parameter LOG_ARCHIVE_DEST_1
ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(
ONLINE_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ORADB_S2' scope=both;
# this parameter must be manually set in the standby database because it has been
# reset by the Broker when it was disabled:
show parameter LOG_ARCHIVE_DEST_2
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2= 'SERVICE=ORADB ASYNC NOAFFIRM delay=0 reopen=300
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORADB' SCOPE=BOTH ;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;
19. Initialize the rolling upgrade plan with defining which standby database will be the Transient Logical
standby database.
conn sys/oracle@oradb as sysdba
exec DBMS_ROLLING.INIT_PLAN(FUTURE_PRIMARY=>'ORADB_S2');
# the status should be READY
SELECT REVISION, STATUS, PHASE FROM DBA_ROLLING_STATUS;
22. Build the Upgrade Plan. Any issue reported by this procedure must be resolved before you proceed
with the rolling upgrade plan.
exec DBMS_ROLLING.BUILD_PLAN;
# View the Current Upgrade Plan:
set linesize 180
set pagesize 50
col TARGET for a10
col PHASE for a10
col DESCRIPTION for a65
SELECT INSTID, TARGET, PHASE, DESCRIPTION FROM DBA_ROLLING_PLAN ORDER BY 1;
Troubleshooting Tool
While implementing the rest of the practice, if you an error is reported by any DBMS_ROLLING procedure,
to dig into the issue, first query DBA_ROLLING_EVENTS to know which step in the plan failed:
SELECT EVENTID, EVENT_TIME, TYPE, MESSAGE, STATUS, INSTID
FROM DBA_ROLLING_EVENTS ORDER BY EVENT_TIME DESC
Obtain Instruction ID “INSTID” from the query above. You can then obtain further details about that
instruction by using the following query:
SELECT INSTID, TARGET, PHASE, DESCRIPTION FROM DBA_ROLLING_PLAN WHERE INSTID=<INSTID>;
Furthermore, when doing the rolling upgrade, always keep eye on the Alert log files. In almost all the
rolling upgrade cases, they provide useful details to diagnose the issues.
23. Configure the LGM database. This basically takes actions required to convert the standby database
into transient logical standby database. A GRP will also be created. It takes a few minutes to finish.
exec DBMS_ROLLING.START_PLAN;
# check the status of the plan and databases:
SELECT REVISION, STATUS, PHASE FROM DBA_ROLLING_STATUS;
SELECT DBUN, ROLE, ENGINE_STATUS,UPDATE_PROGRESS FROM DBA_ROLLING_DATABASES;
27. Install the downloaded version of the Opatch in GI and DB homes. The PSU that you are applying
requires the Opatch utility of version 12.1.0.1.7 or later.
At the time of this writing, the latest version was 12.1.0.1.12. You have made a copy of the patch zip
file in /home/grid/patches in both servers.
# install the Opatch in the GI home
# in srv2 as grid:
# check the current version:
$ORACLE_HOME/OPatch/opatch version
rm -rf /u01/app/oracle/product/12.1.0/db_1/OPatch/*
mkdir /home/oracle/patches
mv /home/grid/patches/p6880880_121010_Linux-x86-64.zip /home/oracle/patches/
chown -R oracle:oinstall /home/oracle/patches/
su - oracle
cd ~/patches
unzip p6880880_121010_Linux-x86-64.zip -d /u01/app/oracle/product/12.1.0/db_1
$ORACLE_HOME/OPatch/opatch version
rm p6880880_121010_Linux-x86-64.zip
Note: do not use opatchauto utility. It does not support patching in Data Guard environments.
Note: do not apply the SQL installation part of the patch. This step will be performed only after software
homes of the primary and all the standby databases have been patched.
Note: Our PSU installation reference document is Doc ID 1591616.1, section 5: “Manual Steps for
Apply/Rollback Patch”
# in srv2
su - grid
# validate Oracle inventory
$ORACLE_HOME/OPatch/opatch lsinventory -oh $ORACLE_HOME
# as root
su -
/u01/app/12.1.0/grid/crs/install/roothas.pl -prepatch
# as root, run the post script (it will eventually startup the has resources):
su -
/u01/app/12.1.0/grid/crs/install/roothas.pl -postpatch
# verify, as grid:
su - grid
$ORACLE_HOME/OPatch/opatch lsinventory -detail
srvctl status asm
su - oracle
# validate Oracle inventory
$ORACLE_HOME/OPatch/opatch lsinventory -oh $ORACLE_HOME
# verify:
opatch lsinventory -detail
31. Start the SQL Apply process in SQL*Plus (remember the Broker is disabled at this stage).
sqlplus sys/oracle@oradb_s2 as sysdba
ALTER DATABASE START LOGICAL STANDBY APPLY NODELAY;
32. In srv2, run the SQL installation part of the PSU in the database oradb_s2. When this step is done,
you consider the database oradb_s2 upgrade is finished. Changes done in this step will automatically
be applied later in the other databases by the redo recovery.
# srv2:
su - oracle
export PATH=$PATH:/u01/app/oracle/product/12.1.0/db_1/OPatch
cd $ORACLE_HOME/OPatch
./datapatch -verbose
# in srv1 as root:
su -
rm -rf /u01/app/oracle/product/12.1.0/db_1/OPatch/*
mkdir /home/oracle/patches
mv /home/grid/patches/p6880880_121010_Linux-x86-64.zip /home/oracle/patches/
chown -R oracle:oinstall /home/oracle/patches/
su - oracle
cd ~/patches
unzip p6880880_121010_Linux-x86-64.zip -d /u01/app/oracle/product/12.1.0/db_1 >/dev/null
# make sure the new Opatch has been installed:
$ORACLE_HOME/OPatch/opatch version
rm p6880880_121010_Linux-x86-64.zip
# as root
su -
/u01/app/12.1.0/grid/crs/install/roothas.pl -prepatch
# as root, run the post script (the has resources will take a few seconds after running the
# command to finish startup):
su -
/u01/app/12.1.0/grid/crs/install/roothas.pl -postpatch
# verify, as grid:
su - grid
$ORACLE_HOME/OPatch/opatch lsinventory -detail
srvctl status asm
su - oracle
# validate Oracle inventory
$ORACLE_HOME/OPatch/opatch lsinventory -oh $ORACLE_HOME
# verify:
opatch lsinventory
FINISH_PLAN flashes back the database to GRP DBMSRU_INITIAL and converts it from logical into physical
standby database. It must be run from the current primary database. It takes some time to finish.
conn sys/oracle@oradb_s2 as sysdba
# have a look at the alert log file after running the command:
execute DBMS_ROLLING.FINISH_PLAN;
# from the alert log file, observe the media recovery operations after the switchover is finished
42. Check on the StaticConnectIdentifier database property for the databases in the Broker
configuration. Make sure it is pointing to the right host.
SHOW DATABASE ORADB StaticConnectIdentifier
SHOW DATABASE ORADB_S2 StaticConnectIdentifier
EDIT DATABASE ORADB_S2 RESET PROPERTY StaticConnectIdentifier ;