windows平台打补丁,报错OPatch failed with error code = 74

oracle是windows 32位11.1.0.7

打个21104029的补丁,总是报出如下错误:

C:\21104029>C:\app\Administrator\product\11.1.0\db_1\OPatch\opatch apply
Invoking OPatch 11.1.0.6.2

Oracle 中间补丁程序安装程序版本 11.1.0.6.2
版权所有 (c) 2007, Oracle Corporation。保留所有权利。

Oracle 主目录       : C:\app\Administrator\product\11.1.0\db_1
主产品清单: C:\Program Files\Oracle\Inventory
   从           : n/a
OPatch 版本    : 11.1.0.6.2
OUI 版本       : 11.1.0.7.0
OUI 位置      : C:\app\Administrator\product\11.1.0\db_1\oui
日志文件位置 : C:\app\Administrator\product\11.1.0\db_1\cfgtoollogs\opatch\opatch2015-10-08_13-46-57下午.log

ApplySession 将中间补丁程序 '21104029' 应用到 OH 'C:\app\Administrator\product\11.1.0\db_1'

Running prerequisite checks...
Prerequisite check "CheckActiveFilesAndExecutables" failed.
The details are:

Following files are active :
C:\app\Administrator\product\11.1.0\db_1\bin\oci.dll
在先决条件检查期间 ApplySession 失败: Prerequisite check "CheckActiveFilesAndExecutables" failed.
系统无任何变化, OPatch 不会尝试还原系统

OPatch failed with error code = 74

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

可以看出,是由于oci.dll一直被其他程序占用导致

Following files are active :
C:\app\Administrator\product\11.1.0\db_1\bin\oci.dll

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

于是我查看是哪个进程占用了oci.dll

C:\21104029>tasklist /m oci.dll

输出结果是SVCHOST.EXE

于是根据进程号杀它,杀完又出来一个SVCHOST,一直如此,杀到最后系统都明显不正常了。

问题已经明了了,由于oci.dll被其他进程占用着,导致opatch apply失败,现在要解决的问题就是如何避免oci.dll被其他进程使用。

在metalink 上的讨论组里面,看到一个老外哥们(也可能是国人)的一段话,深以为然!

This is why I HATE running Oracle on Windows!!!!!!!!!!!!!!!!!!!!!!
When patching, you shutdown all Oracle software, end all Oracle services. Yet MS Windows in its infinite wisdom still maintains a lock on these DLL files so OPatch fails. When I apply my CPU or other patches on Windows systems, I take the list of files above and fire up Explorer and navigate to %ORACLE_HOME%/bin. I find all of these files. You can't delete them. But you can rename them. I change the file extension from .DDL to .OLD or .BAK or something like that. Then I run OPatch again and your patch install will not fail for this reason. You can't overwrite these files and you can't delete them. But you can rename them and the patch will add "new" files with the old names. 

I will say that this is much improved from the old OPatch days. Before, you would get the error for just orageneric11.dll (as an example). Rename that file, Then run OPatch again and this time get the error for the next file, maybe oraclient11.dll. Repeat ad-nauseum until you finally got Opatch to run. At least now, OPatch provides the entire list of files. I'd write a batch program to do the renames, but each patch has a different list of files. 

By the way...did I tell you that I absolutely HATE running Oracle on Windows for this very reason!!!!

> One of the workaround i know is to rename ORACLE_HOME/bin to binx -->restart the windows server --> rename ORACLE_HOME/binx to original name  and apply the patch so that the active dll's are free for patching.

You can also disable the services so they do not autostart and reboot the box. Then apply the patch, startup the services and set them back to autostart. I hate the idea of rebooting just to be able to apply a patch. 

这哥们看起来对windows上跑oracle是深恶痛绝了,其实我也是,嘿嘿。

有次一个客户的监听出现问题了,windows平台,服务启动不了,总是报未知错误,删了重建监听也不行,最后实在没办法了,连实例都删了重建,我去,好了。

幸亏该库不是很重要,但就这样也把我搞的死去活来,以后见到windows上出问题都颤抖。。。

言归正传,该哥们提供了两种针对windows 上ddl文件被占用的解决方案,一种是将被占用的ddl重命名,另外一种是将ORACLE_HOME下的bin目录重命名,这个我没有尝试,我是直接将oci.dll重命名,opatch apply可以正常执行了。

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

这次是不是该说,珍爱生命,远离开发,远离windows 

你可能感兴趣的:(windows平台打补丁,报错OPatch failed with error code = 74)