How to install a release patch on database 12.1 or 12.2

The installation of oracle database patches is an operation not to be taken for granted. Unlike other systems or subsystems it is necessary to perform a series of steps manually.

Below there is the complete list of commands and an example for apply a patch called “release” (that includes the correction of many bugs without introducing substantial changes in performance) on a 12.2 database in an Oracle Linux 7.5 environment

Here’s how to install a release patch on 12.1 or 12.2 database:

#STEP1: Download patches 
 https://support.oracle.com
 - How To Download And Install The Latest OPatch(6880880) Version (Doc ID 274526.1) 
    (https://updates.oracle.com/download/6880880.html)
 - Oracle Database (RDBMS) Releases Support Status Summary (Doc ID 161818.1)

#STEP2: Setting envs 
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export ORACLE_SID=orcl

#STEP3: Close database
lsnrctl stop
sqlplus -s / as sysdba <<EOF
shutdown immediate
exit
EOF

#STEP4: Backup 
mkdir /oracle/backup/

## Backup $ORACLE_HOME 
tar -czvf /oracle/backup/oracle_home.tar.gz $ORACLE_HOME > /oracle/backup/oracle_home.tar.log

## Backup Database 
rman target / <<EOF 
startup mount;
run {
backup database format '/oracle/backup/rman_db_%t_set%s_piece%p_dbid%I';
backup current controlfile format '/oracle/backup/rman_cntl_%t_set%s_piece%p_dbid%I';
backup spfile format '/oracle/backup/rman_spf_%t_set%s_piece%p_dbid%I';
}
shutdown immediate;
exit
EOF

#STEP5: Update OPatch
cd $ORACLE_HOME
mv OPatch OPatch.old
unzip /oracle/software/p6880880_180000_Linux-x86-64.zip -d $ORACLE_HOME
opatch version 
opatch lsinv

#STEP6: Update $ORACLE_HOME
unzip /oracle/software/p27674384_122010_Linux-x86-64.zip -d /oracle/software/
cd /oracle/software/27674384
opatch prereq CheckApplicable -oh $ORACLE_HOME -ph /oracle/software/27674384
opatch apply
opatch lspatches

#STEP7: Open database
lsnrctl start
sqlplus -s / as sysdba <<EOF
startup
exit
EOF
 
#STEP8: Post Patches
$ORACLE_HOME/OPatch/datapatch -prereq
$ORACLE_HOME/OPatch/datapatch -verbose
sqlplus -s / as sysdba << EOF
@$ORACLE_HOME/rdbms/admin/utlrp.sql 
exit
EOF
sqlplus -s / as sysdba << EOF
SET LINESIZE 160
COLUMN action_time FORMAT A20
COLUMN action FORMAT A10
COLUMN status FORMAT A10
COLUMN description FORMAT A60
COLUMN version FORMAT A10
COLUMN bundle_series FORMAT A10
SELECT TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') AS action_time,
 action,
 status,
 description,
 version,
 patch_id,
 bundle_series
FROM dba_registry_sqlpatch
ORDER by action_time;
EOF

Practical example output:

#STEP1
Download 
 https://updates.oracle.com/download/6880880.html
 https://updates.oracle.com/download/27674384.html
Copiare i file scaricati in: 
 /oracle/software/p27674384_122010_Linux-x86-64.zip
 /oracle/software/p6880880_180000_Linux-x86-64.zip

#STEP2
ssh oracle@ol7
[oracle@ol7 ~]$ export ORACLE_BASE=/oracle
[oracle@ol7 ~]$ export ORACLE_HOME=$ORACLE_BASE/product/12.2
[oracle@ol7 ~]$ export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
[oracle@ol7 ~]$ export ORACLE_SID=orcl

#STEP3
[oracle@ol7 ~]$ lsnrctl stop

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 01-MAG-2018 13:34:23

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Connessione a (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ol7)(PORT=1521)))
Il comando è stato eseguito

[oracle@ol7 ~]$ sqlplus -s / as sysdba <<EOF
> shutdown immediate
> exit
> EOF

Database chiuso.
NOMOUNT del database eseguito.
Istanza ORACLE chiusa.

#STEP4
[oracle@ol7 ~]$ mkdir /oracle/backup/

## Backup $ORACLE_HOME
[oracle@ol7 ~]$ tar -czvf /oracle/backup/oracle_home.tar.gz $ORACLE_HOME > /oracle/backup/oracle_home.tar.log
tar: Rimozione di "/" iniziale dai nomi dei membri
[oracle@ol7 ~]$

## Backup Database 
[oracle@ol7 ~]$ rman target / <<EOF
> startup mount;
> run {
> backup database format '/oracle/backup/rman_db_%t_set%s_piece%p_dbid%I';
> backup current controlfile format '/oracle/backup/rman_cntl_%t_set%s_piece%p_dbid%I';
> backup spfile format '/oracle/backup/rman_spf_%t_set%s_piece%p_dbid%I';
> }
> shutdown immediate;
> exit
> EOF

Recovery Manager : Release 12.2.0.1.0 - Production on Mar Mag 1 12:58:46 2018

Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.

connesso al database di destinazione: ORCL (DBID=1471481377, non aperto)

RMAN>
il database è già avviato

RMAN> 2> 3> 4> 5>
Avvio di backup su 01-MAG-18
uso del control file del database di destinazione invece del recovery catalog
canale allocato: ORA_DISK_1
canale ORA_DISK_1: SID=141, tipo di dispositivo=DISK
canale ORA_DISK_1: avvio backup set completo dei file di dati
canale ORA_DISK_1: specifica file di dati nel backup set
numero file di dati di input=00002, nome=/oracle/oradata/orcl/sysaux01.dbf
numero file di dati di input=00001, nome=/oracle/oradata/orcl/system01.dbf
numero file di dati di input=00003, nome=/oracle/oradata/orcl/undotbs01.dbf
....
....
canale ORA_DISK_1: avvio piece 1 in 01-MAG-18
canale ORA_DISK_1: piece 1 terminato in 01-MAG-18
handle piece=/oracle/backup/rman_db_974984329_set73_piece1_dbid1471481377, tag=TAG20180501T125849, commento=NONE
canale ORA_DISK_1: backup set completato, tempo trascorso: 00:00:15
backup completato su 01-MAG-18

Avvio di backup su 01-MAG-18
uso del canale ORA_DISK_1
canale ORA_DISK_1: avvio backup set completo dei file di dati
canale ORA_DISK_1: specifica file di dati nel backup set
inclusione control file corrente nel backup set
canale ORA_DISK_1: avvio piece 1 in 01-MAG-18
canale ORA_DISK_1: piece 1 terminato in 01-MAG-18
handle piece=/oracle/backup/rman_cntl_974984344_set74_piece1_dbid1471481377, tag=TAG20180501T125904, commento=NONE
canale ORA_DISK_1: backup set completato, tempo trascorso: 00:00:01
backup completato su 01-MAG-18

Avvio di backup su 01-MAG-18
uso del canale ORA_DISK_1
canale ORA_DISK_1: avvio backup set completo dei file di dati
canale ORA_DISK_1: specifica file di dati nel backup set
inclusione SPFILE corrente nel backup set
canale ORA_DISK_1: avvio piece 1 in 01-MAG-18
canale ORA_DISK_1: piece 1 terminato in 01-MAG-18
handle piece=/oracle/backup/rman_spf_974984346_set75_piece1_dbid1471481377, tag=TAG20180501T125906, commento=NONE
canale ORA_DISK_1: backup set completato, tempo trascorso: 00:00:01
backup completato su 01-MAG-18

Avvio di Control File and SPFILE Autobackup su 01-MAG-18
handle piece=/oracle/product/12.2/dbs/c-1471481377-20180501-02, commento=NONE
Control File and SPFILE Autobackup completato su 01-MAG-18

RMAN>
NOMOUNT del database eseguito
istanza Oracle chiusa

RMAN>

Recovery Manager ha terminato.

#STEP5
[oracle@ol7 12.2]$ cd $ORACLE_HOME
[oracle@ol7 12.2]$ mv OPatch OPatch.old
[oracle@ol7 12.2]$ unzip /oracle/software/p6880880_180000_Linux-x86-64.zip -d $ORACLE_HOME
Archive: /oracle/software/p6880880_180000_Linux-x86-64.zip
 creating: /oracle/product/12.2/OPatch/
 creating: /oracle/product/12.2/OPatch/oracle_common/
 creating: /oracle/product/12.2/OPatch/oracle_common/modules/
 inflating: /oracle/product/12.2/OPatch/oracle_common/modules/com.oracle.glcm.common-logging_1.6.4.0.jar
 ....
 ....
 extracting: /oracle/product/12.2/OPatch/config/opatch.properties
 
[oracle@ol7 12.2]$ opatch version
OPatch Version: 12.2.0.1.13

OPatch succeeded.

[oracle@ol7 12.2]$ opatch lsinv

Oracle Installer di patch provvisorie versione 12.2.0.1.13
Copyright (c) 2018, Oracle Corporation. Tutti i diritti riservati.


Oracle Home : /oracle/product/12.2
Central Inventory : /oracle/oraInventory
 from : /oracle/product/12.2/oraInst.loc
OPatch version : 12.2.0.1.13
OUI version : 12.2.0.1.4
Log file location : /oracle/product/12.2/cfgtoollogs/opatch/opatch2018-05-01_13-26-24PM_1.log

Lsinventory Output file location : /oracle/product/12.2/cfgtoollogs/opatch/lsinv/lsinventory2018-05-01_13-26-24PM.txt

--------------------------------------------------------------------------------
Local Machine Information::
Hostname: ol7.fritz.box
ARU platform id: 226
ARU platform description:: Linux x86-64

Prodotti di livello superiore installati (1):

Oracle Database 12c 12.2.0.1.0
Ci sono 1 prodotti installati in questa Oracle home.


Non ci sono patch provvisorie installate in questa Oracle home.


--------------------------------------------------------------------------------

OPatch succeeded.

#STEP6
[oracle@ol7 ~]$ unzip /oracle/software/p27674384_122010_Linux-x86-64.zip -d /oracle/software/
Archive: /oracle/software/p27674384_122010_Linux-x86-64.zip
 creating: /oracle/software/27674384/
 inflating: /oracle/software/27674384/README.html
 extracting: /oracle/software/27674384/README.txt
 creating: /oracle/software/27674384/etc/
 creating: /oracle/software/27674384/etc/config/
 inflating: /oracle/software/27674384/etc/config/inventory.xml
 inflating: /oracle/software/27674384/etc/config/actions.xml
 creating: /oracle/software/27674384/files/
 creating: /oracle/software/27674384/files/bin/
....
....
 inflating: /oracle/software/27674384/files/rdbms/xml/em/orarep/exadata/exadataDiffHtml.xsl
 inflating: /oracle/software/PatchSearch.xml
 
[oracle@ol7 ~]$ cd /oracle/software/27674384
[oracle@ol7 27674384]$ opatch prereq CheckApplicable -oh $ORACLE_HOME -ph /oracle/software/27674384

Oracle Installer di patch provvisorie versione 12.2.0.1.13
Copyright (c) 2018, Oracle Corporation. Tutti i diritti riservati.

PREREQ session

Oracle Home : /oracle/product/12.2
Central Inventory : /oracle/oraInventory
 from : /oracle/product/12.2/oraInst.loc
OPatch version : 12.2.0.1.13
OUI version : 12.2.0.1.4
Log file location : /oracle/product/12.2/cfgtoollogs/opatch/opatch2018-05-01_13-37-50PM_1.log

Invoking prereq "checkapplicable"

Prereq "checkApplicable" for patch 27674384 passed.

OPatch succeeded.

[oracle@ol7 27674384]$ opatch apply

Oracle Installer di patch provvisorie versione 12.2.0.1.13
Copyright (c) 2018, Oracle Corporation. Tutti i diritti riservati.


Oracle Home : /oracle/product/12.2
Central Inventory : /oracle/oraInventory
 from : /oracle/product/12.2/oraInst.loc
OPatch version : 12.2.0.1.13
OUI version : 12.2.0.1.4
Log file location : /oracle/product/12.2/cfgtoollogs/opatch/opatch2018-05-01_13-38-13PM_1.log

Verifying environment and performing prerequisite checks...
OPatch continues with these patches: 27674384

Si desidera continuare? [y|n]
y
User Responded with: Y
All checks passed.

Chiudere le istanze Oracle in esecuzione da questa ORACLE_HOME sul sistema locale.
(Oracle home = '/oracle/product/12.2')


Il sistema locale è pronto per l'esecuzione di patch? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '27674384' to OH '/oracle/product/12.2'
ApplySession: Componente/i opzionale/i [ oracle.has.crs, 12.2.0.1.0 ] , [ oracle.oid.client, 12.2.0.1.0 ] , [ oracle.ons.daemon, 12.2.0.1.0 ] , [ oracle.network.cman, 12.2.0.1.0 ] non presente/i nella Oracle home oppure è stata rilevata una versione successiva.

Applicazione patch al componente oracle.network.rsf, 12.2.0.1.0...

Applicazione patch al componente oracle.rdbms.deconfig, 12.2.0.1.0...

Applicazione patch al componente oracle.tfa, 12.2.0.1.0...

Applicazione patch al componente oracle.rdbms.dbscripts, 12.2.0.1.0...

Applicazione patch al componente oracle.assistants.server, 12.2.0.1.0...

Applicazione patch al componente oracle.has.deconfig, 12.2.0.1.0...

Applicazione patch al componente oracle.ctx.rsf, 12.2.0.1.0...

Applicazione patch al componente oracle.rdbms.dv, 12.2.0.1.0...

Applicazione patch al componente oracle.rdbms.oci, 12.2.0.1.0...

Applicazione patch al componente oracle.ldap.rsf, 12.2.0.1.0...

Applicazione patch al componente oracle.precomp.common, 12.2.0.1.0...

Applicazione patch al componente oracle.rdbms.crs, 12.2.0.1.0...

Applicazione patch al componente oracle.ctx, 12.2.0.1.0...

Applicazione patch al componente oracle.xdk, 12.2.0.1.0...

Applicazione patch al componente oracle.nlsrtl.rsf, 12.2.0.1.0...

Applicazione patch al componente oracle.rdbms.rsf, 12.2.0.1.0...

Applicazione patch al componente oracle.precomp.lang, 12.2.0.1.0...

Applicazione patch al componente oracle.ldap.client, 12.2.0.1.0...

Applicazione patch al componente oracle.rdbms.util, 12.2.0.1.0...

Applicazione patch al componente oracle.rdbms, 12.2.0.1.0...

Applicazione patch al componente oracle.xdk.parser.java, 12.2.0.1.0...

Applicazione patch al componente oracle.xdk.rsf, 12.2.0.1.0...

Applicazione patch al componente oracle.rdbms.rman, 12.2.0.1.0...

Applicazione patch al componente oracle.oracore.rsf, 12.2.0.1.0...

Applicazione patch al componente oracle.ldap.rsf.ic, 12.2.0.1.0...

Applicazione patch al componente oracle.ons, 12.2.0.1.0...

Applicazione patch al componente oracle.rdbms.lbac, 12.2.0.1.0...

Applicazione patch al componente oracle.rdbms.rsf.ic, 12.2.0.1.0...

Applicazione patch al componente oracle.sdo, 12.2.0.1.0...
Patch 27674384 successfully applied.
Log file location: /oracle/product/12.2/cfgtoollogs/opatch/opatch2018-05-01_13-38-13PM_1.log

OPatch succeeded.

[oracle@ol7 27674384]$ opatch lspatches
27674384;Database Apr 2018 Release Update : 12.2.0.1.180417 (27674384)

OPatch succeeded.

#STEP7
[oracle@ol7 27674384]$ lsnrctl start

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 01-MAG-2018 13:43:42

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Avvio di /oracle/product/12.2/bin/tnslsnr: attendere...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Il file dei parametri di sistema è /oracle/product/12.2/network/admin/listener.ora
Messaggi di log registrati in /oracle/diag/tnslsnr/ol7/listener/alert/log.xml
Ascolto su: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ol7.fritz.box)(PORT=1521)))
Ascolto su: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connessione a (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ol7)(PORT=1521)))
STATO del LISTENER
------------------------
Alias LISTENER
Versione TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Data di inizio 01-MAG-2018 13:43:42
Tempo di attività 0 giorni 0 ore 0 min. 0 sec.
Livello trace off
Sicurezza ON: Local OS Authentication
SNMP OFF
File di parametri listener/oracle/product/12.2/network/admin/listener.ora
File di log listener /oracle/diag/tnslsnr/ol7/listener/alert/log.xml
Summary table degli endpoint di ascolto...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ol7.fritz.box)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Il listener non supporta i servizi
Il comando è stato eseguito
[oracle@ol7 27674384]$ sqlplus -s / as sysdba <<EOF
> startup
> exit
> EOF
Istanza ORACLE avviata.

Total System Global Area 536870912 bytes
Fixed Size 8622776 bytes
Variable Size 406850888 bytes
Database Buffers 113246208 bytes
Redo Buffers 8151040 bytes
MOUNT del database eseguito.
Database aperto.

#STEP8
[oracle@ol7 ~]$ $ORACLE_HOME/OPatch/datapatch -prereq
SQL Patching tool version 12.2.0.1.0 Production on Tue May 1 14:46:51 2018
Copyright (c) 2012, 2018, Oracle. All rights reserved.

Connecting to database...OK
Determining current state...done
Adding patches to installation queue and performing prereq checks...done
Installation queue:
 Nothing to roll back
 The following patches will be applied:
 27674384 (DATABASE APR 2018 RELEASE UPDATE 12.2.0.1.180417)

SQL Patching tool complete on Tue May 1 14:47:10 2018
[oracle@ol7 ~]$ $ORACLE_HOME/OPatch/datapatch -verbose
SQL Patching tool version 12.2.0.1.0 Production on Tue May 1 14:47:39 2018
Copyright (c) 2012, 2018, Oracle. All rights reserved.

Log file for this invocation: /oracle/cfgtoollogs/sqlpatch/sqlpatch_18328_2018_05_01_14_47_39/sqlpatch_invocation.log

Connecting to database...OK
Bootstrapping registry and package to current versions...done
Determining current state...done

Current state of SQL patches:
Bundle series DBRU:
 ID 180417 in the binary registry and not installed in the SQL registry

Adding patches to installation queue and performing prereq checks...
Installation queue:
 Nothing to roll back
 The following patches will be applied:
 27674384 (DATABASE APR 2018 RELEASE UPDATE 12.2.0.1.180417)

Installing patches...

Patch installation complete. Total patches installed: 1

Validating logfiles...
Patch 27674384 apply: SUCCESS
 logfile: /oracle/cfgtoollogs/sqlpatch/27674384/22098633/27674384_apply_ORCL_2018Mag01_14_47_52.log (no errors)
SQL Patching tool complete on Tue May 1 14:50:51 2018

[oracle@ol7 12.2]$ sqlplus -s / as sysdba << EOF
> @$ORACLE_HOME/rdbms/admin/utlrp.sql
> exit
> EOF

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2018-05-01 14:59:32


Procedura PL/SQL completata correttamente.


TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2018-05-01 14:59:35


OBJECTS WITH ERRORS
-------------------
 0


ERRORS DURING RECOMPILATION
---------------------------
 0


Funzione creata.


Procedura PL/SQL completata correttamente.


Funzione eliminata.

...(14:59:41) Starting validate_apex for APEX_050100
...(14:59:43) Checking missing sys privileges
...(14:59:43) Recompiling
...(14:59:44) Checking for objects that are still invalid
...(14:59:44) Key object existence check
...(14:59:44) Setting DBMS Registry for APEX to valid
...(14:59:44) Exiting validate_apex

Procedura PL/SQL completata correttamente.

[oracle@ol7 ~]$ sqlplus -s / as sysdba << EOF
> SET LINESIZE 160
> COLUMN action_time FORMAT A20
> COLUMN action FORMAT A10
> COLUMN status FORMAT A10
> COLUMN description FORMAT A60
> COLUMN version FORMAT A10
> COLUMN bundle_series FORMAT A10
> SELECT TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') AS action_time,
> action,
> status,
> description,
> version,
> patch_id,
> bundle_series
> FROM dba_registry_sqlpatch
> ORDER by action_time;
> EOF

ACTION_TIME ACTION STATUS DESCRIPTION VERSION PATCH_ID BUNDLE_SER
-------------------- ---------- ---------- ------------------------------------------------------------ ---------- ---------- ----------
01-MAG-2018 14:50:51 APPLY SUCCESS DATABASE APR 2018 RELEASE UPDATE 12.2.0.1.180417 12.2.0.1 27674384 DBRU

PATCH APPLIED!

 

Leave a Comment