备份oracle目录
cd /u01/install/
mkdir backup
cd /u01/app/oracle/product/19.0.0
nohup tar -cvf /u01/install/backup/db_1.tar db_1/ &
更新OPATCH工具
[oracle@dg19c1 opatch]$ cd $ORACLE_HOME
[oracle@dg19c1 db_1]$ mv OPatch/ OPatch.bak
[oracle@dg19c1 db_1]$ unzip /u01/install/opatch/p6880880_190000_Linux-x86-64.zip -d $ORACLE_HOME
[oracle@dg19c1 db_1]$ OPatch/opatch version
OPatch Version: 12.2.0.1.21
OPatch succeeded.
解压补丁集
[oracle@dg19c1 db_1]$ cd /u01/install/opatch/
[oracle@dg19c1 opatch]$ unzip p31326362_190000_Linux-x86-64.zip
补丁冲突验证
[oracle@dg19c1 31281355]$ /u01/app/oracle/product/19.0.0/db_1/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph /u01/install/opatch/31326362/31281355/
make ar ld nm 先决条件验证
[oracle@dg19c1 31281355]$ which make ar ld nm
/usr/bin/make
/usr/bin/ar
/usr/bin/ld
/usr/bin/nm
补丁安装
注意:安装补丁前必须关闭所有资源,包含监听、数据库
[oracle@dg19c1 31281355]$ pwd
/u01/install/opatch/31326362/31281355
[oracle@dg19c1 31281355]$ /u01/app/oracle/product/19.0.0/db_1/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.21
Copyright (c) 2020, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/19.0.0/db_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.0.0/db_1/oraInst.loc
OPatch version : 12.2.0.1.21
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2020-07-20_22-26-48PM_1.log
Verifying environment and performing prerequisite checks...
OPatch continues with these patches: 31281355
Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/19.0.0/db_1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '31281355' to OH '/u01/app/oracle/product/19.0.0/db_1'
ApplySession: Optional component(s) [ oracle.network.gsm, 19.0.0.0.0 ] , [ oracle.rdbms.ic, 19.0.0.0.0 ] , [ oracle.rdbms.tg4db2, 19.0.0.0.0 ] , [ oracle.tfa, 19.0.0.0.0 ] , [ oracle.oraolap.mgmt, 19.0.0.0.0 ] , [ oracle.xdk.parser.java.jaxb2, 19.0.0.0.0 ] , [ oracle.options.olap.awm, 19.0.0.0.0 ] , [ oracle.net.cman, 19.0.0.0.0 ] , [ oracle.assistants.asm, 19.0.0.0.0 ] , [ oracle.network.cman, 19.0.0.0.0 ] , [ oracle.sqlj, 19.0.0.0.0 ] , [ oracle.assistants.usm, 19.0.0.0.0 ] , [ oracle.options.olap, 19.0.0.0.0 ] , [ oracle.jdk, 1.8.0.191.0 ] not present in the Oracle Home or a higher version is found.
Patching component oracle.rdbms, 19.0.0.0.0...
Patching component oracle.rdbms.util, 19.0.0.0.0...
Patching component oracle.rdbms.rsf, 19.0.0.0.0...
Patching component oracle.assistants.acf, 19.0.0.0.0...
............................................
Patch 31281355 successfully applied.
Sub-set patch [29517242] has become inactive due to the application of a super-set patch [31281355].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2020-07-20_22-26-48PM_1.log
OPatch succeeded.
安装结束后sql升级没有错误告警既升级成功
[oracle@dg19c1 31281355]$ sqlplus / as sysdba
SQL> startup
SQL> exit
[oracle@dg19c1 31281355]$ cd $ORACLE_HOME
[oracle@dg19c1 db_1]$ cd OPatch
[oracle@dg19c1 OPatch]$ ./datapatch -verbose
升级ojvm补丁
安装前置条件,停止所有数据库资源,监听、数据库
补丁冲突验证
[oracle@dg19c1 OPatch]$ cd /u01/install/opatch/31326362/31219897/
[oracle@dg19c1 31219897]$ /u01/app/oracle/product/19.0.0/db_1/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph /u01/install/opatch/31326362/31219897/
[oracle@dg19c1 31219897]$ /u01/app/oracle/product/19.0.0/db_1/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.21
Copyright (c) 2020, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/19.0.0/db_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.0.0/db_1/oraInst.loc
OPatch version : 12.2.0.1.21
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2020-07-20_22-50-31PM_1.log
Verifying environment and performing prerequisite checks...
OPatch continues with these patches: 31219897
Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/19.0.0/db_1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '31219897' to OH '/u01/app/oracle/product/19.0.0/db_1'
Patching component oracle.javavm.server, 19.0.0.0.0...
Patching component oracle.javavm.server.core, 19.0.0.0.0...
Patching component oracle.rdbms.dbscripts, 19.0.0.0.0...
Patching component oracle.rdbms, 19.0.0.0.0...
Patch 31219897 successfully applied.
Log file location: /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2020-07-20_22-50-31PM_1.log
OPatch succeeded.
补丁升级成功过后sql升级
[oracle@dg19c1 31219897]$ sqlplus / as sysdba
SQL> startup upgrade
SQL> exit
[oracle@dg19c1 31219897]$ cd $ORACLE_HOME
[oracle@dg19c1 db_1]$ cd OPatch
[oracle@dg19c1 OPatch]$ ./datapatch -verbose
[oracle@dg19c1 OPatch]$ sqlplus / as sysdba
SQL> shut immediate
SQL> startup
SQL> exit
启动监听
[oracle@dg19c1 OPatch]$ lsnrctl start
编译无效推向
[oracle@dg19c1 OPatch]$ cd $ORACLE_HOME/rdbms/admin/
[oracle@dg19c1 admin]$ sqlplus / as sysdba
SQL> @utlrp.sql
SQL> exit
补丁是否成功验证
[oracle@dg19c1 admin]$ sqlplus / as sysdba
SQL> set line 300
SQL> select patch_id,action,status,action_time,description from dba_registry_sqlpatch;
PATCH_ID ACTION STATUS ACTION_TIME DESCRIPTION


29517242 APPLY SUCCESS 17-JUL-20 01.07.32.232118 AM Database Release Update : 19.3.0.0.190416 (29517242)
31281355 APPLY SUCCESS 20-JUL-20 10.44.11.546988 PM Database Release Update : 19.8.0.0.200714 (31281355)
31219897 APPLY SUCCESS 20-JUL-20 10.57.39.232862 PM OJVM RELEASE UPDATE: 19.8.0.0.200714 (31219897)
SQL> exit
补丁回滚
ojvm补丁回滚
先决条件停库、停监听
[oracle@dg19c1 ~]$ lsnrctl stop
[oracle@dg19c1 ~]$ sqlplus / as sysdba
SQL> shut immediate
SQL> exit
卸载ojvm补丁
[oracle@dg19c1 ~]$ /u01/app/oracle/product/19.0.0/db_1/OPatch/opatch rollback -id 31219897
Oracle Interim Patch Installer version 12.2.0.1.21
Copyright (c) 2020, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/19.0.0/db_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.0.0/db_1/oraInst.loc
OPatch version : 12.2.0.1.21
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2020-07-20_23-35-41PM_1.log
Patches will be rolled back in the following order:
31219897
The following patch(es) will be rolled back: 31219897
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/19.0.0/db_1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Rolling back patch 31219897...
RollbackSession rolling back interim patch '31219897' from OH '/u01/app/oracle/product/19.0.0/db_1'
Patching component oracle.javavm.server, 19.0.0.0.0...
Patching component oracle.javavm.server.core, 19.0.0.0.0...
Patching component oracle.rdbms.dbscripts, 19.0.0.0.0...
Patching component oracle.rdbms, 19.0.0.0.0...
RollbackSession removing interim patch '31219897' from inventory
Log file location: /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2020-07-20_23-35-41PM_1.log
OPatch succeeded.
执行卸载sql
[oracle@dg19c1 ~]$ sqlplus / as sysdba
SQL> startup upgrade
SQL> exit
[oracle@dg19c1 ~]$ cd $ORACLE_HOME/OPatch
[oracle@dg19c1 OPatch]$ ./datapatch -verbose
[oracle@dg19c1 OPatch]$ sqlplus / as sysdba
SQL> shut immediate
SQL> exit
数据库补丁回滚
DB补丁回滚
[oracle@dg19c1 OPatch]$ /u01/app/oracle/product/19.0.0/db_1/OPatch/opatch rollback -id 31281355
Oracle Interim Patch Installer version 12.2.0.1.21
Copyright (c) 2020, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/19.0.0/db_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.0.0/db_1/oraInst.loc
OPatch version : 12.2.0.1.21
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2020-07-20_23-57-49PM_1.log
Patches will be rolled back in the following order:
31281355
The following patch(es) will be rolled back: 31281355
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/19.0.0/db_1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Rolling back patch 31281355...
RollbackSession rolling back interim patch '31281355' from OH '/u01/app/oracle/product/19.0.0/db_1'
Patching component oracle.rdbms, 19.0.0.0.0...
Deleting "kpdbapx.o" from archive "/u01/app/oracle/product/19.0.0/db_1/lib/libserver19.a"
Deleting "kqro.o" from archive "/u01/app/oracle/product/19.0.0/db_1/lib/libserver19.a"
............................................
............................................
Patching component oracle.precomp.lang, 19.0.0.0.0...
Patching component oracle.jdk, 1.8.0.201.0...
RollbackSession removing interim patch '31281355' from inventory
Inactive sub-set patch [29517242] has become active due to the rolling back of a super-set patch [31281355].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2020-07-20_23-57-49PM_1.log
OPatch succeeded.
执行卸载后sql
[oracle@dg19c1 OPatch]$ sqlplus / as sysdba
SQL> startup
SQL> exit
[oracle@dg19c1 OPatch]$ cd $ORACLE_HOME
[oracle@dg19c1 db_1]$ cd OPatch
[oracle@dg19c1 OPatch]$ ./datapatch -verbose
查询卸载结果
[oracle@dg19c1 OPatch]$ sqlplus / as sysdba
SQL> set line 300
SQL> select patch_id,action,status,action_time,description from dba_registry_sqlpatch;
PATCH_ID ACTION STATUS ACTION_TIME DESCRIPTION


29517242 APPLY SUCCESS 17-JUL-20 01.07.32.232118 AM Database Release Update : 19.3.0.0.190416 (29517242)
31281355 APPLY SUCCESS 20-JUL-20 10.44.11.546988 PM Database Release Update : 19.8.0.0.200714 (31281355)
31219897 APPLY SUCCESS 20-JUL-20 10.57.39.232862 PM OJVM RELEASE UPDATE: 19.8.0.0.200714 (31219897)
31219897 ROLLBACK SUCCESS 20-JUL-20 11.40.05.114340 PM OJVM RELEASE UPDATE: 19.8.0.0.200714 (31219897)
31281355 ROLLBACK SUCCESS 21-JUL-20 12.18.36.291043 AM Database Release Update : 19.8.0.0.200714 (31281355)