Windows Opatch Prerequisite check "CheckActiveFilesAndExecutables" failed
Auf Unix Betriebssystemen ist ein in der Regel ganz einfach. Stoppe den/die Listener sowie die Datenbank Instanzen aus dem ORACLE_HOME und schon kann man ohne Probleme mittels OPatch aktualisieren.
Windows ist hier anders....
Eigenheiten von Oracle Datenbanken unter Windows
Der gravierendste Unterschied ist, dass bei Windows ein genutztes Files (Programm, Shared Library (DLL), JAR File,... ) gegen Zugriffe geschützt ist. Was bei Log und Tracefiles unangenehm genug ist, weil man diese zuerst kopieren muss, bevor man diese in einem Texteditor ansehen kann, führt beim Patchen zu teilweise massiven Problemen. Nutzt man auch noch mehrere ORACLE_HOMES (verschiedene Datenbank Versionen bzw. Datenbank und Client Homes) kann einem die Einstellung von PATH ebenfalls Probleme bereiten.
Wie geht man jetzt am besten vor, wenn man unter Windows einen Patch mittels OPatch einspielen muss?
OPatch im Oracle Home aktualisieren
Den aktuellen OPatch für die benutzte Oracle Release für Windows (x86_64) von https://updates.oracle.com/download/6880880.html herunter laden und in das ORACLE_HOME entpacken. Das vorhandene OPatch Verzeichnis muss dabei überschrieben werden.
Stoppen aller Oracle Services
Zumindest aus dem ORACLE_HOME, dass man Patchen möchte.
Sofern man nur eine Oracle Datenbank Software nutzt, ist das recht einfach, indem man in einem CMD.exe als SYSDBA die entsprechenden Services stoppt.
Oracle Windows Services identifizieren und stoppen
net start |findstr Oracle
Alle diese Services müssen gestoppt werden
Danach muss man zumindest den Microsoft Distributed Transaction Service stoppen
net stop msdtc
Wenn man ODBC Connections oder ähnliche konfiguriert hat, muss man möglicherweise weitere Services stoppen. Einen Hinweis, welche Prozesse/Services noch laufen, kann man mit folgendem Befehl erhalten:
tasklist /M ora*
Bevor man weiter macht, sind mehrere Punkte sicher zu stellen
- im PATH befindet sich kein anderes ORACLE_HOME - idealerweise überhaupt keines
- ORACLE_HOME muss explizit gesetzt werden
set ORACLE_HOME=d:\app\oracle\product\19.0.0\dbhome_1
Danach empfiehlt sich ein Check ob der Patch erfolgreich eingespielt werden kann. Hier ein Beispiel für den Critical Patch Update 19.15.
%ORACLE_HOME%\OPatch\opatch prereq CheckConflictAgainstOHWithDetail -ph D:\stage\p33829175_190000_MSWIN-x86-64\33829175
Sollten noch Programme oder DLLs aus dem ORACLE_HOME genutzt werden, erhält man folgende Meldung:
OUI-67073:UtilSession failed: Prerequisite check "CheckActiveFilesAndExecutables" failed.
Finishing UtilSession at Mon Jun 20 18:08:35 CEST 2022
Log file location: d:\app\oracle\product\19.0.0\dbhome_1\cfgtoollogs\opatch\opatch2022-06-20_18-08-14PM_1.log
Stack Description: java.lang.RuntimeException: Prerequisite check "CheckActiveFilesAndExecutables" failed.
Im Logfile findet man dann, welche Files betroffen sind - hier ein Beispiel:
[Jun 20, 2022 6:08:35 PM] [INFO] Prerequisite check "CheckActiveFilesAndExecutables" failed.
The details are:
Following active files/executables/libs are used by ORACLE_HOME :d:\app\oracle\product\19.0.0\dbhome_1
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraocrutl19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraocrb19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraocr19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orahasgen19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraons.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraclsce19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraocr19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraocrutl19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraocrb19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orahasgen19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orannzsbb19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraldapclnt19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraztkg19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orazt19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oracore19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraasmclnt19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraclient19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oracommon19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orageneric19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraplc19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraplp19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orapls19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oravsn19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orawsec19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oci.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\sqlplus.exe
d:\app\oracle\product\19.0.0\dbhome_1\bin\orasql19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oran19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orancds19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orangsmshd19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oranhost19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oranl19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oranldap19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oranro19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orantcp19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orantns19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\orancrypt19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraons.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oranls19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraasmclnt19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oracell19.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraons.dll
d:\app\oracle\product\19.0.0\dbhome_1\bin\oraxml19.dll
Startet des Patching mittels OPatch
%ORACLE_HOME%\OPatch\opatch apply -ph D:\stage\p33829175_190000_MSWIN-x86-64\33829175
kann es auch während des Patchings noch Probleme mit offenen Files geben, wenn in der Zwischenzeit etwas gestartet wird, dass Oracle Programme oder DLLs nutzt (zb: Backups,...).
Hier ein Beispiel wie so ein Output aussieht:
Backing up files...
Applying interim patch '33829175' to OH 'd:\app\oracle\product\19.0.0\dbhome_1'
ApplySession: Optional component(s) [ oracle.tomcat.crs, 19.0.0.0.0 ] , [ oracle.has.deconfig, 19.0.0.0.0 ] ,
[ oracle.swd.oui.core.min, 19.0.0.0.0 ] , [ oracle.has.cfs, 19.0.0.0.0 ] , [ oracle.rdbms.tg4msql, 19.0.0.0.0 ] ,
[ oracle.rdbms.ic, 19.0.0.0.0 ] , [ oracle.rdbms.tg4ifmx, 19.0.0.0.0 ] , [ oracle.network.cman, 19.0.0.0.0 ] ,
[ oracle.network.gsm, 19.0.0.0.0 ] , [ oracle.assistants.asm, 19.0.0.0.0 ] , [ oracle.has.cvu, 19.0.0.0.0 ] ,
[ oracle.tfa, 19.0.0.0.0 ] , [ oracle.rdbms.tg4sybs, 19.0.0.0.0 ] , [ oracle.usm, 19.0.0.0.0 ] ,
[ oracle.rdbms.tg4tera, 19.0.0.0.0 ] , [ oracle.ons.daemon, 19.0.0.0.0 ] , [ oracle.options.olap, 19.0.0.0.0 ] ,
[ oracle.swd.oui, 19.0.0.0.0 ] , [ oracle.assistants.usm, 19.0.0.0.0 ] , [ oracle.rdbms.tg4db2, 19.0.0.0.0 ] ,
[ oracle.options.olap.awm, 19.0.0.0.0 ] , [ oracle.has.crs, 19.0.0.0.0 ]
not present in the Oracle Home or a higher version is found.
Patching component oracle.has.common.cvu, 19.0.0.0.0...
Patching component oracle.has.rsf, 19.0.0.0.0...
Copy failed from 'D:\stage\p33829175_190000_MSWIN-x86-64\33829175\files\bin\oraocrutl19.dll' to
'd:\app\oracle\product\19.0.0\dbhome_1\bin\oraocrutl19.dll'...
Please verify all applications associated with the Oracle Home 'd:\app\oracle\product\19.0.0\dbhome_1' are shut down. If this is AIX,
please perform solution documented in Note 739963.1 on https://myoraclesupport.oracle.com.
Do you want to retry copying the file? [y|n]
Could not recognize input. Please re-enter.
y
User Responded with: Y
Retry copying the file to 'd:\app\oracle\product\19.0.0\dbhome_1\bin\oraocrutl19.dll'.
...
In so einem Fall hilft nur die Analyse wer das entsprechende Programm/Dll geöffnet hat.
tasklist /M ora*
Dieses Programm kann man dann im TastManager im Details Reiter suchen und terminieren.
Beispieloutput von tasklist.
Image Name PID Modules
========================= ======== ============================================
sqlplus.exe 4720 OraClient19.Dll, oracore19.dll,
oranls19.dll, oraunls19.dll, oravsn19.dll,
oracommon19.dll, orauts.dll, orasnls19.dll,
orageneric19.dll, oraasmclnt19.dll,
oraxml19.dll, oran19.dll, orannzsbb19.dll,
oranl19.dll, orapls19.dll, oracell19.dll,
orahasgen19.dll, oraons.dll,
oraldapclnt19.dll, orangsmshd19.dll,
oranro19.dll, orasql19.dll, orawsec19.dll,
oraocr19.dll, orazt19.dll, oraztkg19.dll,
orancrypt19.dll, oranldap19.dll,
oranhost19.dll, orancds19.dll,
orantns19.dll, orantcp19.dll,
oraslax19.dll, oraplp19.dll,
oraclsce19.dll, oraocrutl19.dll,
oraocrb19.dll, OraPlc19.Dll
Sobald man den entsprechenden Prozess im Tast Manager terminiert hat, kann man das Patching weiter fortsetzen.
Post-Patching
Nach dem Patching mit Opatch macht ein Reboot des Windows (Reboot Check) Sinn. Das hat den Vorteil, dass die Services wieder alle laufen. Sofort nach dem Restart gehören die Datenbanken mit datapatch aktualisiert.
- im PATH befindet sich kein anderes ORACLE_HOME - idealerweise überhaupt keines
- ORACLE_HOME muss explizit gesetzt werden
set ORACLE_HOME=d:\app\oracle\product\19.0.0\dbhome_1
- ORACLE_SID muss für datapatch ebenfalls gesetzt werden.
set ORACLE_SID=MYDB
Datapatch pro Datenbank durchführen
cd /d %ORACLE_HOME%
datapatch -verbose