【Oracle】windows平台Oracle11g打patch,OPatch failed with error code = 74
windows平台Oracle11g打patch,一个朋友的事儿,帮忙弄一下。首先作者本人从来未在Windows平台为Oralce 11.2.0.1打patch。不过,无论打什么patch,都要严格的按照readme中所提示的整。本人也不例外,但是在打补丁的时候还是出现点儿小问题。
readme中步骤如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
3.3.2 Patch Installation Instructions for Single Instance Follow these steps: Cleanly shut down all processes running from the ORACLE_HOME. Set the ORACLE_HOME environment variable to the correct Oracle home that needs to be patched. > set ORACLE_HOME=<Oracle Home Path> Go to the directory where you downloaded the patch: > cd 10432044 Ensure that the directory containing the OPatch script appears in your PATH setting. Enter the following command to run OPatch: > opatch apply Inspect the opatch<timestamp>.log file generated in %ORACLE_HOME%\cfgtoollogs\opatch for any errors. |
看着readme中的提示做,大致步骤如下:
1:shutdown数据库,并设置环境变量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
## 数据库shutdown步骤略 ## 设置环境变量 C:\Users\Administrator>set ORACLE_HOME=C:\app\Administrator\product\11.2.0\dbhome_1 C:\Users\Administrator>set path=%ORACLE_HOME%\OPatch;%path% C:\Users\Administrator> C:\Users\Administrator>echo %ORACLE_HOME% C:\app\Administrator\product\11.2.0\dbhome_1 C:\Users\Administrator>echo %path% C:\app\Administrator\product\11.2.0\dbhome_1\OPatch;D:\Program Files\Java\jdk1.8 .0_121\bin;D:\Program Files\Java\jdk1.8.0_121\jre\bin;C:\Program Files\MySQL\MyS QL Server 5.5\bin;C:\app\Administrator\product\11.2.0\dbhome_1\bin;C:\Program Fi les (x86)\Common Files\NetSarang;C:\app\Administrator\product\11.2.0\client_1\bi n;D:\Program Files\Vim\vim73;D:\Program Files\Python\Python35-32\Scripts;D:\Prog ram Files\Python\Python35-32;C:\Windows\system32;C:\Windows;C:\Windows\System32\ Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\Anaconda3;C:\Pro gramData\Anaconda3\Scripts;C:\ProgramData\Anaconda3\Library\bin;D:\Program Files \TortoiseSVN\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Bin\;C:\Program Files\dotnet\;C:\Program Files (x86)\EasyFrom Inc\ C:\Users\Administrator> |
2:在windows,cmd命令行切换到解压缩后补丁的目录
1 2 3 |
C:\Users\Administrator>cd C:\p10432044_112010_WINNT\10432044 C:\p10432044_112010_WINNT\10432044> |
3:执行opatch lsinventory
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
## inventory数据结构列表显示 C:\p10432044_112010_WINNT\10432044>opatch lsinventory Invoking OPatch 11.1.0.6.6 Oracle 中间补丁程序安装程序版本 11.1.0.6.6 版权所有 (c) 2009, Oracle Corporation。保留所有权利。 Oracle 主目录 : C:\app\Administrator\product\11.2.0\dbhome_1 主产品清单: C:\Program Files (x86)\Oracle\Inventory 从 : n/a OPatch 版本 : 11.1.0.6.6 OUI 版本 : 11.2.0.1.0 OUI 位置 : C:\app\Administrator\product\11.2.0\dbhome_1\oui 日志文件位置 : C:\app\Administrator\product\11.2.0\dbhome_1\cfgtoollogs\opatch\o patch2018-01-03_13-44-23下午.log Patch history file: C:\app\Administrator\product\11.2.0\dbhome_1\cfgtoollogs\opa tch\opatch_history.txt Lsinventory Output file location : C:\app\Administrator\product\11.2.0\dbhome_1\ cfgtoollogs\opatch\lsinv\lsinventory2018-01-03_13-44-23下午.txt -------------------------------------------------------------------------------- 已安装的顶级产品 (1): Oracle Database 11g 11.2.0.1.0 此 Oracle 主目录中已安装 1 个产品。 ....... C:\p10432044_112010_WINNT\10432044> |
此时我会看到OPatch 版本 : 11.1.0.6.6,与readme中要求的不一致,readme中要求11.2.0.1.2 or later,最好是更新opatch为指定版本,当然了,本次打patch未升级opatch,也是可以正常打patch。
4:执行opatch 打patch
1 |
C:\p10432044_112010_WINNT\10432044> opatch apply |
5:问题,在执行第四步时,报如下错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
ApplySession 将中间补丁程序 '10432044' 应用到 OH 'C:\app\Administrator\product\11.2.0\dbhome_1' Running prerequisite checks... Prerequisite check "CheckActiveFilesAndExecutables" failed. The details are: Following files are active : C:\app\Administrator\product\11.2.0\dbhome_1\bin\oci.dll 在先决条件检查期间 ApplySession 失败: Prerequisite check "CheckActiveFilesAndExecutables" failed. 系统无任何变化, OPatch 不会尝试还原系统 OPatch failed with error code = 74 -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
从错误中我们可以看到oci.dll这个文件的状态是active,显然oci.dll这个文件影响了打patch,我甚至操作系统重启了,还是不行(有可能是我观察不细致造成的)
可以通过C:\p10432044_112010_WINNT\10432044>tasklist /m oci.dll 这个命令查看是哪个进程占用着这个程序,但据说就算找到,kill掉进程,还是会被守护进程拉起来。
最后实在没办法了,看见一个网友的解决方案是将oci.dll文件重命名(假设,这个文件确实是在使用中,那么该文件是无法重命名的。但是事实是,oci.dll这个文件在被占用的情况下也是可以重命名的),重命名后(随便改个名字),执行 opatch apply,就开始正常打patch了,这个重命名的oci.dll也无需理会,因为在打patch的时候,就包含这个文件,所以就不用管它了。
最后,我在回来的路上想这个问题,有可能是因为打patch的数据库是两个实例造成的。我在shutdown的时候,可能是没关彻底或是其他某个进程在用着什么。
总之,以后再在windows打patch,还是检查仔细且做好充分的测试为好。