1.所需文件
p6880880_122010_Linux-x86-64.zip
p32126842_190000_Linux-x86-64.zip
2.查看OPatch版本
/u01/app/19.3.0.0/OPatch[root@rac1 OPatch]# ./opatchauto versionOracle OPatchAuto Version 13.9.4.2.0Copyright (c) 2016, Oracle Corporation. All rights reserved.1. OPatchAuto version 13.9.4.2.02. OpatchautoDB version 12.2.0.1.17
3.保存并替换OPatch文件
tar -zcvf /setup/u01_app.tar.gz /u01/appcp -r OPatch OPatch_BAkrm -rf /u01/app/19.3.0.0/OPatchcd /setupunzip p6880880_122010_Linux-x86-64.zipcp -r OPatch /u01/app/19.3.0.0chown grid:oinstall /u01/app/19.3.0.0/OPatch -Rmv /u01/app/oracle/product/19.3.0.0/dbhome_1/OPatch /u01/app/oracle/product/19.3.0.0/dbhome_1/OPatch_BAKcp -r /setup/OPatch /u01/app/oracle/product/19.3.0.0/dbhome_1/chown oracle:oinstall /u01/app/oracle/product/19.3.0.0/dbhome_1/OPatch -R其他节点rm -rf /u01/app/19.3.0.0/OPatchrm -rf /u01/app/oracle/product/19.3.0.0/dbhome_1/OPatchcd /setupunzip p6880880_122010_Linux-x86-64.zip -d /u01/app/19.3.0.0/unzip p6880880_122010_Linux-x86-64.zip -d /u01/app/oracle/product/19.3.0.0/dbhome_1/chown grid:oinstall /u01/app/19.3.0.0/OPatch -Rchown oracle:oinstall /u01/app/oracle/product/19.3.0.0/dbhome_1/OPatch -R
4.oracle inventory 验证
su - grid./opatch lspatches #查看验证现有补丁或者使用./opatch lsinventory -detail -oh /u01/app/19.3.0.0/
5.检查空间

su - gridvi /tmp/patch_list_gihome.txt/setup/32126842/32226239/32218454/setup/32126842/32226239/32222571/setup/32126842/32226239/32218663/setup/32126842/32226239/29340594/setup/32126842/32226239/32240590$ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /tmp/patch_list_gihome.txt[grid@rac1 32126842]$ $ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /tmp/patch_list_gihome.txtOracle Interim Patch Installer version 12.2.0.1.24Copyright (c) 2021, Oracle Corporation. All rights reserved.PREREQ sessionOracle Home : /u01/app/19.3.0.0Central Inventory : /u01/app/oraInventoryfrom : /u01/app/19.3.0.0/oraInst.locOPatch version : 12.2.0.1.24OUI version : 12.2.0.7.0Log file location : /u01/app/19.3.0.0/cfgtoollogs/opatch/opatch2021-08-27_02-28-09AM_1.logInvoking prereq "checksystemspace"Prereq "checkSystemSpace" passed.OPatch succeeded.su - oraclevi /tmp/patch_list_dbhome.txt/setup/32126842/32226239/32218454/setup/32126842/32226239/32222571$ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /tmp/patch_list_dbhome.txtOracle Interim Patch Installer version 12.2.0.1.24Copyright (c) 2021, Oracle Corporation. All rights reserved.PREREQ sessionOracle Home : /u01/app/oracle/product/19.3.0.0/dbhome_1Central Inventory : /u01/app/oraInventoryfrom : /u01/app/oracle/product/19.3.0.0/dbhome_1/oraInst.locOPatch version : 12.2.0.1.24OUI version : 12.2.0.7.0Log file location : /u01/app/oracle/product/19.3.0.0/dbhome_1/cfgtoollogs/opatch/opatch2021-08-27_02-32-11AM_1.logInvoking prereq "checksystemspace"Prereq "checkSystemSpace" passed.OPatch succeeded.
6.冲突检测

su - grid$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /setup/32126842/32226239/32218454$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /setup/32126842/32226239/32222571$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /setup/32126842/32226239/32218663$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /setup/32126842/32226239/29340594$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /setup/32126842/32226239/32240590su - oracle$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /setup/32126842/32226239/32218454$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /setup/32126842/32226239/32222571##########确认所有执行都是返回OPatch succeeded###############################
7.检查各个节点oui-patch.xml文件
没有则复制其他节点文件过去
cd /u01/app/oraInventory/ContentsXML[root@olrac1 ContentsXML]# lltotal 16-rwxrwxrwx 1 grid oinstall 300 Mar 18 2020 comps.xml-rwxrwxrwx 1 grid oinstall 623 Aug 22 2020 inventory.xml-rwxrwxrwx 1 grid oinstall 292 Mar 18 2020 libs.xml-rwxrwxrwx 1 grid oinstall 174 Mar 18 2020 oui-patch.xmlscp oui-patch.xml grid@192.168.5.132:/u01/app/oraInventory/ContentsXML/chmod 660 oui-patch.xml
8.补丁分析
su - root/u01/app/19.3.0.0/grid/OPatch/opatchauto apply /setup/32126842/32226239 -analyze
9.执行补丁安装
[root@olrac1 ~]# /u01/app/19.3.0.0/grid/OPatch/opatchauto apply /setup/32126842/32226239OPatchauto session is initiated at Sat Aug 28 03:20:34 2021System initialization log file is /u01/app/19.3.0.0/grid/cfgtoollogs/opatchautodb/systemconfig2021-08-28_03-20-42AM.log.Session log file is /u01/app/19.3.0.0/grid/cfgtoollogs/opatchauto/opatchauto2021-08-28_03-22-20AM.logThe id for this session is 25G2Executing OPatch prereq operations to verify patch applicability on home /u01/app/oracle/product/19.3.0.0/dbhome_1Executing OPatch prereq operations to verify patch applicability on home /u01/app/19.3.0.0/gridPatch applicability verified successfully on home /u01/app/oracle/product/19.3.0.0/dbhome_1Patch applicability verified successfully on home /u01/app/19.3.0.0/gridExecuting patch validation checks on home /u01/app/19.3.0.0/gridPatch validation checks successfully completed on home /u01/app/19.3.0.0/gridExecuting patch validation checks on home /u01/app/oracle/product/19.3.0.0/dbhome_1Patch validation checks successfully completed on home /u01/app/oracle/product/19.3.0.0/dbhome_1Verifying SQL patch applicability on home /u01/app/oracle/product/19.3.0.0/dbhome_1SQL patch applicability verified successfully on home /u01/app/oracle/product/19.3.0.0/dbhome_1Preparing to bring down database service on home /u01/app/oracle/product/19.3.0.0/dbhome_1Successfully prepared home /u01/app/oracle/product/19.3.0.0/dbhome_1 to bring down database servicePerforming prepatch operations on CRS - bringing down CRS service on home /u01/app/19.3.0.0/gridPrepatch operation log file location: /u01/app/grid/crsdata/olrac1/crsconfig/crs_prepatch_apply_inplace_olrac1_2021-08-28_03-25-00AM.logCRS service brought down successfully on home /u01/app/19.3.0.0/gridPerforming prepatch operation on home /u01/app/oracle/product/19.3.0.0/dbhome_1Perpatch operation completed successfully on home /u01/app/oracle/product/19.3.0.0/dbhome_1Start applying binary patch on home /u01/app/oracle/product/19.3.0.0/dbhome_1Binary patch applied successfully on home /u01/app/oracle/product/19.3.0.0/dbhome_1Performing postpatch operation on home /u01/app/oracle/product/19.3.0.0/dbhome_1Postpatch operation completed successfully on home /u01/app/oracle/product/19.3.0.0/dbhome_1Start applying binary patch on home /u01/app/19.3.0.0/gridBinary patch applied successfully on home /u01/app/19.3.0.0/gridPerforming postpatch operations on CRS - starting CRS service on home /u01/app/19.3.0.0/gridPostpatch operation log file location: /u01/app/grid/crsdata/olrac1/crsconfig/crs_postpatch_apply_inplace_olrac1_2021-08-28_03-55-00AM.logCRS service started successfully on home /u01/app/19.3.0.0/gridPreparing home /u01/app/oracle/product/19.3.0.0/dbhome_1 after database service restartedNo step execution required.........Trying to apply SQL patch on home /u01/app/oracle/product/19.3.0.0/dbhome_1SQL patch applied successfully on home /u01/app/oracle/product/19.3.0.0/dbhome_1OPatchAuto successful.--------------------------------Summary--------------------------------Patching is completed successfully. Please find the summary as follows:Host:olrac1RAC Home:/u01/app/oracle/product/19.3.0.0/dbhome_1Version:19.0.0.0.0Summary:==Following patches were SKIPPED:Patch: /setup/32126842/32226239/32218663Reason: This patch is not applicable to this specified target type - "rac_database"Patch: /setup/32126842/32226239/29340594Reason: This patch is not applicable to this specified target type - "rac_database"Patch: /setup/32126842/32226239/32240590Reason: This patch is not applicable to this specified target type - "rac_database"==Following patches were SUCCESSFULLY applied:Patch: /setup/32126842/32226239/32218454Log: /u01/app/oracle/product/19.3.0.0/dbhome_1/cfgtoollogs/opatchauto/core/opatch/opatch2021-08-28_03-31-29AM_1.logPatch: /setup/32126842/32226239/32222571Log: /u01/app/oracle/product/19.3.0.0/dbhome_1/cfgtoollogs/opatchauto/core/opatch/opatch2021-08-28_03-31-29AM_1.logHost:olrac1CRS Home:/u01/app/19.3.0.0/gridVersion:19.0.0.0.0Summary:==Following patches were SUCCESSFULLY applied:Patch: /setup/32126842/32226239/29340594Log: /u01/app/19.3.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2021-08-28_03-40-50AM_1.logPatch: /setup/32126842/32226239/32218454Log: /u01/app/19.3.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2021-08-28_03-40-50AM_1.logPatch: /setup/32126842/32226239/32218663Log: /u01/app/19.3.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2021-08-28_03-40-50AM_1.logPatch: /setup/32126842/32226239/32222571Log: /u01/app/19.3.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2021-08-28_03-40-50AM_1.logPatch: /setup/32126842/32226239/32240590Log: /u01/app/19.3.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2021-08-28_03-40-50AM_1.logOPatchauto session completed at Sat Aug 28 04:08:48 2021Time taken to complete the session 48 minutes, 15 seconds
/u01/app/oracle/product/19.3.0.0/dbhome_1/OPatch/opatchauto apply /setup/32126842/32226239 -oh /u01/app/oracle/product/19.3.0.0/dbhome_1//u01/app/19.3.0.0/OPatch/opatchauto rollback /setup/32126842/32226239rollback/u01/app/19.3.0.0/OPatch/opatchauto rollback /setup/32126842/32226239 -oh /u01/app/19.3.0.0/
异常处理:
缺失命令fuser
Patch: /u01/app/install/32126842/32226239/32218454
Log: /u01/app/oracle/product/19c/db_1/cfgtoollogs/opatchauto/core/opatch/opatch2022-06-24_11-04-45上午_1.log
Reason: Failed during Analysis: CheckSystemCommandsAvailable Failed, [ Prerequisite Status: FAILED, Prerequisite output:
The details are:
Missing command :fuser]
yum install -y psmisc
升级失败进程被占用
查看升级日志
[2022-6-24 11:25:00] [INFO] Following active executables are not used by opatch process :
Following active executables are used by opatch process :
/u01/app/19c/grid/lib/libclntsh.so.19.1
[2022-6-24 11:25:00] [INFO] Prerequisite check “CheckActiveFilesAndExecutables” failed.
The details are:
Following active executables are not used by opatch process :
Following active executables are used by opatch process :
/u01/app/19c/grid/lib/libclntsh.so.19.1
安装lsof 命令yum install lsof -ylsof /u01/app/19c/grid/lib/libclntsh.so.19.1[root@cesmon01 install]# lsof /u01/app/19c/grid/lib/libclntsh.so.19.1COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEjava 22303 grid mem REG 8,33 79942576 3019450 /u01/app/19c/grid/lib/libclntsh.so.19.1[root@cesmon01 install]# kill -9 22303重新运行升级脚本发现集群未启动不能升级手动逐个升级su - grid/u01/app/19c/grid/OPatch/opatch apply /u01/app/install/32126842/32226239/29340594 -oh /u01/app/19c/grid/u01/app/19c/grid/OPatch/opatch apply /u01/app/install/32126842/32226239/32218454 -oh /u01/app/19c/grid/u01/app/19c/grid/OPatch/opatch apply /u01/app/install/32126842/32226239/32218663 -oh /u01/app/19c/grid/u01/app/19c/grid/OPatch/opatch apply /u01/app/install/32126842/32226239/32222571 -oh /u01/app/19c/grid/u01/app/19c/grid/OPatch/opatch apply /u01/app/install/32126842/32226239/32240590 -oh /u01/app/19c/grid/u01/app/19c/grid/OPatch/opatch apply /u01/app/install/32126842/32067171 -oh /u01/app/19c/grid升级完启动集群报错[root@cesmon01 install]# /u01/app/19c/grid/bin/crsctl start hasCRS-6706: Oracle Clusterware Release patch level ('1944883066') does not match Software patch level ('724960844'). Oracle Clusterware cannot be started.CRS-4000: Command Start failed, or completed with errors./u01/app/19c/grid/bin/clscfg -localpatch/u01/app/19c/grid/crs/install/rootcrs.sh -lock[root@cesmon01 install]# /u01/app/19c/grid/bin/clscfg -localpatchclscfg: EXISTING configuration version 0 detected.Creating OCR keys for user 'root', privgrp 'root'..Operation successful.[root@cesmon01 install]# /u01/app/19c/grid/crs/install/rootcrs.sh -lockUsing configuration parameter file: /u01/app/19c/grid/crs/install/crsconfig_paramsThe log of current session can be found at:/u01/app/grid/crsdata/cesmon01/crsconfig/crslock_cesmon01_2022-06-24_12-34-11AM.log2022/06/24 12:34:14 CLSRSC-329: Replacing Clusterware entries in file 'oracle-ohasd.service'[root@cesmon01 install]# /u01/app/19c/grid/bin/crsctl start hasCRS-4123: Oracle High Availability Services has been started.升级数据库/u01/app/oracle/product/19c/db_1/OPatch/opatchauto apply /u01/app/install/32126842/32226239 -oh /u01/app/oracle/product/19c/db_1
