环境描述
- 系 统:Redhat
- 数据库:Oracle 19c RAC(19.3.0.0)
问题描述
在数据库打 PSU 时会遇到异常:
==Following patches FAILED in apply: Patch: /u01/30899722/30869156 Log: /u01/app/19.3.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2020-08-11_08-15-00AM_1.log Reason: Failed during Patching: oracle.opatch.opatchsdk.OPatchException: ApplySession failed in system modification phase... 'ApplySession::apply failed: java.io.IOException: oracle.sysman.oui.patch.PatchException: java.io.FileNotFoundException: /u01/app/oraInventory/ContentsXML/oui-patch.xml (Permission denied)' After fixing the cause of failure Run opatchauto resume
查看权限不对后
chmod 660 /u01/app/oraInventory/ContentsXML/oui-patch.xml opatchauto resume
再次出现以下异常
==Following patches FAILED in apply: Patch: /u01/30899722/30869156 Log: Reason: Failed during Patching: oracle.opatch.opatchsdk.OPatchException: Unable to create patchObject Possible causes are: ORACLE_HOME/inventory/oneoffs/30869156 is corrupted. PatchObject constructor: Input file "/u01/app/19.3.0/grid/inventory/oneoffs/30869156/etc/config/actions" or "/u01/app/19.3.0/grid/inventory/oneoffs/30869156/etc/config/inventory" does not exist.
问题信息获取
根据输出日志,进行整体排查后发现如下相关内容
vi /u01/app/19.3.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2020-08-11_08-15-00AM_1.log [Aug 11, 2020 8:21:54 AM] [INFO] Finish invoking 'patchgen' at Tue Aug 11 08:21:54 CST 2020 [Aug 11, 2020 8:21:54 AM] [INFO] ApplySession adding interim patch '30869156' to inventory [Aug 11, 2020 8:21:54 AM] [INFO] [OPSR-TIME] Saving patch 30869156 to inventory [Aug 11, 2020 8:21:54 AM] [WARNING] OUI-67124:ApplySession failed in system modification phase... 'ApplySession::apply failed: java.io.IOException: oracle.sysman.oui.patch.PatchException: java.io.FileNotFoundException: /u01/app/oraInventory/ContentsXML/oui-patch.xml (Permission denied)' [Aug 11, 2020 8:21:54 AM] [INFO] Restoring "/u01/app/19.3.0/grid" to the state prior to running NApply... [Aug 11, 2020 8:21:54 AM] [INFO] Restoring files: copy recurse from /u01/app/19.3.0/grid/.patch_storage/NApply/2020-08-11_08-16-28AM/backup to /u01/app/19.3.0/grid
原因分析
[Aug 11, 2020 8:21:54 AM] [INFO] [OPSR-TIME] Saving patch 30869156 to inventory
该原因为保存 inventory 时报错
从而造成了后面的第二个异常
Possible causes are: ORACLE_HOME/inventory/oneoffs/30869156 is corrupted.
而第一个异常的原因是
Reason: Failed during Patching: oracle.opatch.opatchsdk.OPatchException: ApplySession failed in system modification phase... 'ApplySession::apply failed: java.io.IOException: oracle.sysman.oui.patch.PatchException: java.io.FileNotFoundException: /u01/app/oraInventory/ContentsXML/oui-patch.xml (Permission denied)'
文件I/O异常,文件权限导致的
异常发生过程
-
当我们安装完成数据库时,一节点有oui-patch.xml,而二节点没有oui-patch.xml
-
当我们使用 opatchauto 打 patch 时,一节点成功率为百分百
-
二节点先打oracle的patch时,将oui-patch.xml从一节点scp至二节点,由于umask,造成权限改变
-rw-r--r-- 1 oracle oinstall 174 May 31 02:21 oui-patch.xml
-
由于oracle自己有读写权限,所以oracle打patch成功
-
当grid打patch时,由于oinstall属组权限为只读,所以报如下异常
Reason: Failed during Patching: oracle.opatch.opatchsdk.OPatchException: ApplySession failed in system modification phase... 'ApplySession::apply failed: java.io.IOException: oracle.sysman.oui.patch.PatchException: java.io.FileNotFoundException: /u01/app/oraInventory/ContentsXML/oui-patch.xml (Permission denied)'
而此时执行的程序,将会对 ORACLE_HOME/inventory/oneoffs/30869156 文件夹造成破坏,所以产生了后面的异常
Possible causes are: ORACLE_HOME/inventory/oneoffs/30869156 is corrupted
解决方案
在打patch过程中,不建议先赋权 660,再将一节点的 30869156 拷贝到二节点,因为通过回滚发现,二节点的 30869156 的 patch 是回滚失败的,唯一的解决方案如下:
-
在打 patch 前,将一节点的 oui-patch.xml 传至二节点
scp /u01/app/oraInventory/ContentsXML/oui-patch.xml grid@node2:/u01/app/oraInventory/ContentsXML/
-
在第二节点给文件赋权
chmod 660 /u01/app/oraInventory/ContentsXML/oui-patch.xml
MOS Patch 解决方案
该 PATCH 核心内容如上图所示,与上述方案进行对比后发现整体思路一致,该patch 已于 7月25日发布更新
参考
- opatchauto apply Results java.io.FileNotFoundException: \
/ContentsXML/oui-patch.xml (Permission denied) Error in Non-OUI Nodes (Doc ID 2582139.1)