系统:CentOS7.9

环境:oracle 19.14 + rac

说明:1-9步骤两个节点均需执行

1、备份目录

[root@hisdb1 ~]# tar -zcvPf oraclebase.tar.gz /u01/app/oracle >/dev/null

[root@hisdb1 ~]# tar -zcvPf oraInventory.tar.gz /u01/app/oraInventory >/dev/null

[root@hisdb1 ~]# tar -zcvPf gridbase.tar.gz /u01/app/grid >/dev/null

[root@hisdb1 ~]# tar -zcvPf gridhome.tar.gz /u01/app/11.2.0/grid >/dev/null

2、安装OPatch

说明:19.15 DB的RU编号是:33806152,GI的RU编号是:33803476,OPatch版本至少为12.2.0.1.29

sftp> cd /tmp

sftp> lcd F:\installmedium\19c\19.15

sftp> put p6880880_190000_Linux-x86-64.zip

[grid@hisdb1:/tmp]$ unzip -q -o p6880880_190000_Linux-x86-64.zip -d $ORACLE_HOME

[oracle@hisdb1:/tmp]$ unzip -q -o p6880880_190000_Linux-x86-64.zip -d $ORACLE_HOME

[grid@hisdb1 tmp]$ opatch version

OPatch Version: 12.2.0.1.30

OPatch succeeded.

[oracle@hisdb1 tmp]$ opatch version

OPatch Version: 12.2.0.1.30

OPatch succeeded.

3、验证Oracle Inventory

检查DB Home和Grid Home的补丁列表里补丁的一致性.

[grid@hisdb1:/home/grid]$ $ORACLE_HOME/OPatch/opatch lsinventory -detail -oh $ORACLE_HOME

[oracle@hisdb1:/home/oracle]$ $ORACLE_HOME/OPatch/opatch lsinventory -detail -oh $ORACLE_HOME

4、下载及解压Patch

[root@hisdb1 /]# mkdir /upgrade

[root@hisdb1 /]# chown -R grid:oinstall /upgrade

sftp> lcd F:\installmedium\19c\19.15

sftp> cd /home/grid

sftp> put p33803476_190000_Linux-x86-64.zip

[grid@hisdb1 ~]$ unzip -q p33803476_190000_Linux-x86-64.zip -d /upgrade

5、运行opatch冲突检查

确定当前安装的一次性修补程序是否与此修补程序33803476冲突

grid用户:

% $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /upgrade/33803476/33806152

% $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /upgrade/33803476/33815596

% $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /upgrade/33803476/33815607

% $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /upgrade/33803476/33911149

% $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /upgrade/33803476/33575402

oracle用户:

% $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /upgrade/33803476/33806152

% $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /upgrade/33803476/33815596

6、运行OPatch检查系统空间

检查ORACLE_HOME文件系统是否有足够的可用空间,以便应用补丁程序:

6.1、grid用户

[grid@hisdb1:/home/grid]$ vi /tmp/patch_lists_gihome.txt

/upgrade/33803476/33806152

/upgrade/33803476/33815596

/upgrade/33803476/33815607

/upgrade/33803476/33911149

/upgrade/33803476/33575402

运行以下命令检查Grid Infrastructure home是否有足够空间.

[grid@hisdb1:/home/grid]$ $ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /tmp/patch_lists_gihome.txt

6.2、oracle用户

[oracle@hisdb1:/home/oracle]$ vi /tmp/patch_lists_dbhome.txt

/upgrade/33803476/33806152

/upgrade/33803476/33815596

运行以下命令检查oracle home是否有足够空间.

[oracle@hisdb1:/home/oracle]$ $ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /tmp/patch_list_dbhome.txt  

7、一次性补丁冲突检测和解决

[root@hisdb1 ~]# /u01/app/19.3.0/grid/OPatch/opatchauto apply /upgrade/33803476 -analyze

[root@hisdb1 ~]# /u01/app/19.3.0/grid/OPatch/opatchauto rollback /upgrade/33803476 -analyze

8、自动补丁安装

[root@hisdb1 ~]# export PATH=$PATH:/u01/app/19.3.0/grid/OPatch  (说明:/u01/app/19.3.0/grid为GRID_HOME)

[root@hisdb1 ~]# opatchauto apply /upgrade/33803476  

OPatchauto session is initiated at Sun May 22 11:16:54 2022

System initialization log file is /u01/app/19.3.0/grid/cfgtoollogs/opatchautodb/systemconfig2022-05-22_11-16-57AM.log.

Session log file is /u01/app/19.3.0/grid/cfgtoollogs/opatchauto/opatchauto2022-05-22_11-17-18AM.log

The id for this session is Y26L

Executing OPatch prereq operations to verify patch applicability on home /u01/app/oracle/product/19.3.0/db

Executing OPatch prereq operations to verify patch applicability on home /u01/app/19.3.0/grid

Patch applicability verified successfully on home /u01/app/19.3.0/grid

Patch applicability verified successfully on home /u01/app/oracle/product/19.3.0/db

Executing patch validation checks on home /u01/app/19.3.0/grid

Patch validation checks successfully completed on home /u01/app/19.3.0/grid

Executing patch validation checks on home /u01/app/oracle/product/19.3.0/db

Patch validation checks successfully completed on home /u01/app/oracle/product/19.3.0/db

Verifying SQL patch applicability on home /u01/app/oracle/product/19.3.0/db

SQL patch applicability verified successfully on home /u01/app/oracle/product/19.3.0/db

Preparing to bring down database service on home /u01/app/oracle/product/19.3.0/db

Successfully prepared home /u01/app/oracle/product/19.3.0/db to bring down database service

Performing prepatch operations on CRS - bringing down CRS service on home /u01/app/19.3.0/grid

Prepatch operation log file location: /u01/app/grid/crsdata/hisdb1/crsconfig/crs_prepatch_apply_inplace_hisdb1_2022-05-22_11-19-59AM.log

CRS service brought down successfully on home /u01/app/19.3.0/grid

Performing prepatch operation on home /u01/app/oracle/product/19.3.0/db

Perpatch operation completed successfully on home /u01/app/oracle/product/19.3.0/db

Start applying binary patch on home /u01/app/oracle/product/19.3.0/db

Binary patch applied successfully on home /u01/app/oracle/product/19.3.0/db

Performing postpatch operation on home /u01/app/oracle/product/19.3.0/db

Postpatch operation completed successfully on home /u01/app/oracle/product/19.3.0/db

Start applying binary patch on home /u01/app/19.3.0/grid

Binary patch applied successfully on home /u01/app/19.3.0/grid

Performing postpatch operations on CRS - starting CRS service on home /u01/app/19.3.0/grid

Postpatch operation log file location: /u01/app/grid/crsdata/hisdb1/crsconfig/crs_postpatch_apply_inplace_hisdb1_2022-05-22_11-33-47AM.log

CRS service started successfully on home /u01/app/19.3.0/grid

Preparing home /u01/app/oracle/product/19.3.0/db after database service restarted

No step execution required.........


Trying to apply SQL patch on home /u01/app/oracle/product/19.3.0/db

SQL patch applied successfully on home /u01/app/oracle/product/19.3.0/db

OPatchAuto successful.

--------------------------------Summary--------------------------------

Patching is completed successfully. Please find the summary as follows:

Host:hisdb1

RAC Home:/u01/app/oracle/product/19.3.0/db

Version:19.0.0.0.0

Summary:

==Following patches were SKIPPED:

Patch: /upgrade/33803476/33815607

Reason: This patch is not applicable to this specified target type - "rac_database"

Patch: /upgrade/33803476/33575402

Reason: This patch is not applicable to this specified target type - "rac_database"

Patch: /upgrade/33803476/33911149

Reason: This patch is not applicable to this specified target type - "rac_database"

==Following patches were SUCCESSFULLY applied:

Patch: /upgrade/33803476/33806152

Log: /u01/app/oracle/product/19.3.0/db/cfgtoollogs/opatchauto/core/opatch/opatch2022-05-22_11-20-48AM_1.log

Patch: /upgrade/33803476/33815596

Log: /u01/app/oracle/product/19.3.0/db/cfgtoollogs/opatchauto/core/opatch/opatch2022-05-22_11-20-48AM_1.log

Host:hisdb1

CRS Home:/u01/app/19.3.0/grid

Version:19.0.0.0.0

Summary:

==Following patches were SKIPPED:

Patch: /upgrade/33803476/33575402

Log: /u01/app/19.3.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2022-05-22_11-17-45AM_1.log

Reason: /upgrade/33803476/33575402 is not required to be applied to oracle home /u01/app/19.3.0/grid

==Following patches were SUCCESSFULLY applied:

Patch: /upgrade/33803476/33806152

Log: /u01/app/19.3.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2022-05-22_11-27-03AM_1.log

Patch: /upgrade/33803476/33815596

Log: /u01/app/19.3.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2022-05-22_11-27-03AM_1.log

Patch: /upgrade/33803476/33815607

Log: /u01/app/19.3.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2022-05-22_11-27-03AM_1.log

Patch: /upgrade/33803476/33911149

Log: /u01/app/19.3.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2022-05-22_11-27-03AM_1.log

OPatchauto session completed at Sun May 22 11:39:54 2022

Time taken to complete the session 23 minutes, 0 second

9、检查 grid 补丁

[grid@hisdb1 ~]$ opatch lspatches

33911149;TOMCAT RELEASE UPDATE 19.0.0.0.0 (33911149)

33815607;ACFS RELEASE UPDATE 19.15.0.0.0 (33815607)

33815596;OCW RELEASE UPDATE 19.15.0.0.0 (33815596)

33806152;Database Release Update : 19.15.0.0.220419 (33806152)

33575402;DBWLM RELEASE UPDATE 19.0.0.0.0 (33575402)

OPatch succeeded.

[grid@hisdb1 ~]$ sqlplus -version

SQL*Plus: Release 19.0.0.0.0 - Production

Version 19.15.0.0.0

10、加载SQL

说明:此步骤为加载变化的SQL到数据库,RAC环境只需在节点1执行。

[oracle@hisdb1:/u01/app/oracle/product/19.3.0/db/OPatch]$ ./datapatch -verbose

SQL Patching tool version 19.15.0.0.0 Production on Sun May 22 12:38:38 2022

Copyright (c) 2012, 2022, Oracle.  All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_90196_2022_05_22_12_38_38/sqlpatch_invocation.log

Connecting to database...OK

Gathering database info...done

Bootstrapping registry and package to current versions...done

Determining current state...done

Current state of interim SQL patches:

 No interim patches found

Current state of release update SQL patches:

 Binary registry:

   19.15.0.0.0 Release_Update 220331125408: Installed

 SQL registry:

   Applied 19.15.0.0.0 Release_Update 220331125408 successfully on 22-MAY-22 12.32.02.272029 PM

Adding patches to installation queue and performing prereq checks...done

Installation queue:

 No interim patches need to be rolled back

 No release update patches need to be installed

 No interim patches need to be applied

SQL Patching tool complete on Sun May 22 12:39:07 2022

11、处理无效对象

因之前datapatch命令会加载SQL,此过程可能会产生无效对象,执行@utlrp.sql脚本处理无效对象

SQL> @?/rdbms/admin/utlrp.sql

12、查看版本变化

SQL> col status for a10

SQL> col action for a10

SQL> col action_time for a30  

SQL> col desctiption for a60

SQL> set line 200

SQL> select patch_id,patch_type,action,status,action_time,description from dba_registry_sqlpatch;

 PATCH_ID PATCH_TYPE ACTION     STATUS     ACTION_TIME                    DESCRIPTION

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

 29517242 RU         APPLY      SUCCESS    21-MAR-22 11.30.57.513467 AM   Database Release Update : 19.3.0.0.190416 (29517242)

 31771877 RU         APPLY      SUCCESS    02-APR-22 05.11.09.823188 PM   Database Release Update : 19.9.0.0.201020 (31771877)

 33515361 RU         APPLY      SUCCESS    02-APR-22 11.47.50.965595 PM   Database Release Update : 19.14.0.0.220118 (33515361)

 33806152 RU         APPLY      SUCCESS    22-MAY-22 12.32.02.272029 PM   Database Release Update : 19.15.0.0.220419 (33806152)

SQL> col version for a25

SQL> col comments for a80

SQL> select action_time,version,comments from dba_registry_history;

ACTION_TIME                    VERSION                   COMMENTS

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

                                      19                        RDBMS_19.15.0.0.0DBRU_LINUX.X64_220330

21-MAR-22 11.30.52.564764 AM   19.0.0.0.0                Patch applied on 19.3.0.0.0: Release_Update - 190410122720

02-APR-22 05.10.27.383267 PM   19.0.0.0.0                Patch applied from 19.3.0.0.0 to 19.9.0.0.0: Release_Update - 200930183249

02-APR-22 11.46.56.626133 PM   19.0.0.0.0                Patch applied from 19.9.0.0.0 to 19.14.0.0.0: Release_Update - 211225122123

22-MAY-22 12.31.14.605329 PM   19.0.0.0.0                Patch applied from 19.14.0.0.0 to 19.15.0.0.0: Release_Update - 220331125408