ORACLE 打补丁时遇到.patch_storage权限不足
Oracle环境:Oracle19c
OS 环境:redhat7.6
报错如下:
[oracle@localhost 32067171]$ /u01/app/oracle/product/19.0.0/dbhome_1/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.24
Copyright (c) 2021, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/19.0.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.0.0/dbhome_1/oraInst.loc
OPatch version : 12.2.0.1.24
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2021-05-11_17-01-26PM_1.log
OPatch failed to lock and get an Inventory Session for the given Oracle Home /u01/app/oracle/product/19.0.0/dbhome_1
Possible causes are:
No read or write permission to $ORACLE_HOME, cannot create $ORACLE_HOME/.patch_storage
No read or write permission to $ORACLE_HOME/.patch_storage
OPatch cannot proceed further because system will not be able to backup files, or read the backup area for rollback/restore.
OPatchSession cannot load inventory for the given Oracle Home /u01/app/oracle/product/19.0.0/dbhome_1. Possible causes are:
No read or write permission to ORACLE_HOME/.patch_storage
Central Inventory is locked by another OUI instance
No read permission to Central Inventory
The lock file exists in ORACLE_HOME/.patch_storage
The Oracle Home does not exist in Central Inventory
UtilSession failed: IPMRWServices::verifyPatchStorageDirectory() cannot read or write to /u01/app/oracle/product/19.0.0/dbhome_1/.patch_storage
Log file location: /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2021-05-11_17-01-26PM_1.log
根据报错信息和log日志,是说无法写入ORACLE_HOME/.patch_storage,首先想到是权限不足,进入到HOME目录发现,果然是权限不足,打补丁用的是oracle用户,而.patch_storage的属主是root
[root@localhost ~]$ cd /u01/app/oracle/product/19.0.0/dbhome_1
[root@localhost dbhome_1]$ ls -la
drwxr-xr-x. 9 oracle oinstall 98 Apr 17 2019 md
drwxr-xr-x. 4 oracle oinstall 31 Apr 17 2019 mgw
drwxr-xr-x. 10 oracle oinstall 106 Apr 17 2019 network
drwxr-xr-x. 5 oracle oinstall 46 Apr 17 2019 nls
drwxr-xr-x. 8 oracle oinstall 101 Apr 17 2019 odbc
drwxr-xr-x. 5 oracle oinstall 42 Apr 17 2019 olap
drwxr-x---. 15 oracle oinstall 4096 Feb 1 18:47 OPatch
drwxr-xr-x. 3 root root 28 Apr 18 2019 .opatchauto_storage
drwxr-x---. 14 oracle oinstall 4096 May 11 00:28 OPatch_bak
drwxr-xr-x. 7 oracle oinstall 65 Apr 17 2019 opmn
drwxr-xr-x. 4 oracle oinstall 34 Apr 17 2019 oracore
-rw-r-----. 1 oracle oinstall 56 May 11 00:27 oraInst.loc
drwxr-xr-x. 6 oracle oinstall 52 Apr 17 2019 ord
drwxr-xr-x. 4 oracle oinstall 66 Apr 17 2019 ords
drwxr-xr-x. 3 oracle oinstall 19 Apr 17 2019 oss
drwxr-xr-x. 8 oracle oinstall 226 May 11 00:28 oui
drwxr-xr-x. 4 oracle oinstall 33 Apr 17 2019 owm
drwxr-xr-x. 5 root root 188 Apr 18 2019 .patch_storage
drwxr-xr-x. 5 oracle oinstall 39 Apr 17 2019 perl
drwxr-xr-x. 6 oracle oinstall 78 Apr 17 2019 plsql
drwxr-xr-x. 6 oracle oinstall 56 Apr 18 2019 precomp
drwxr-xr-x. 2 oracle oinstall 26 Apr 17 2019 QOpatch
drwxr-xr-x. 5 oracle oinstall 52 Apr 17 2019 R
drwxr-xr-x. 4 oracle oinstall 29 Apr 17 2019 racg
drwxr-xr-x. 13 oracle oinstall 140 Apr 18 2019 rdbms
drwxr-xr-x. 3 oracle oinstall 21 Apr 17 2019 relnotes
修改目录属主数组:
chown -R oracle:oinstall .patch_storage
重新apply 补丁
[oracle@localhost 32067171]$ /u01/app/oracle/product/19.0.0/dbhome_1/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.24
Copyright (c) 2021, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/19.0.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.0.0/dbhome_1/oraInst.loc
OPatch version : 12.2.0.1.24
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2021-05-11_17-12-43PM_1.log
Verifying environment and performing prerequisite checks...
OPatch continues with these patches: 32067171
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/dbhome_1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '32067171' to OH '/u01/app/oracle/product/19.0.0/dbhome_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...
Patching component oracle.javavm.client, 19.0.0.0.0...
Patch 32067171 successfully applied.
Log file location: /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2021-05-11_17-12-43PM_1.log
OPatch succeeded.
补丁应用成功!!!!!!
补充说明.patch_storage的作用:
每次在打补丁的时候,会对库文件和模块做一些改变;变动之前,opatch会在$ORACLE_HOME/.patch_storage/<patch-id_timestamp> 目录中创建一个snapshot。有时候会出现需要回滚补丁的时候,这个目录下面会有一个rollback.sh脚本,这个脚本可以remove之前做过的changes。