This guide shows a way, how a Gold Image can be created from an Oracle Home on Windows and how that can be used to patch other Oracle Homes. This worked for me, but is not meant to be the only, best or officially recommended Oracle way.
Prepare the image source home
Start with a fresh installed Oracle Home, in this case under D:\app\oracle\product\19.0.0\dbhome_1\.
There is no standard oraenv.sh under Windows, a minimal oraenv.cmd could look like that:
set ORACLE_BASE=C:\app\oracle set ORACLE_HOME=%ORACLE_BASE%\product\19.0.0\dbhome_1 set PATH=%ORACLE_HOME%\bin;%PATH% set PATH=%ORACLE_HOME%\perl\bin;%PATH% set PATH=%ORACLE_HOME%\OPatch\;%PATH%
Run your oraenv.cmd, unpack the software (you can use tar xfz under Windows for unzip) and run setup.bat, see the Database Installation Guide 19c for Microsoft Windows.
C:\app>mkdir c:\app\oracle\product\19.0.0\dbhome_1 C:\app>oraenv.cmd C:\app>cd %ORACLE_HOME% C:\app\oracle\product\19.0.0\dbhome_2>tar xfz z:\Install\Windows\WINDOWS.X64_193000_db_home.zip C:\app\oracle\product\19.0.0\dbhome_2>setup.bat
In this example, we use an existing user oracle instead of a virtual account, which would be the default from the oracle installer. This makes directory handling easier for out-of-place-patching. Also we only need to setup the software only and this is a single instance installation. Under Linux, we would just apply the RU and one-offs from the setup, but the options '-applyRU 'and '-applyOneOffs' are not available under Windows (see the comments on https://mikedietrichde.com/2022/05/17/simple-database-installation-with-applyru-and-applyoneoffs/, search for Windows).
Update opatch by following Doc ID 274526.1 from Oracle Support, in this case using opatch 12.2.0.1.41.
For the Gold Image, we will patch the 19.03 dbhome_1 up to 19.21 plus two one-off patches for the JVM. So download and unpack the patches to a given directory, in this example c:\app\oracle\patches. The patch numbers are 35638318, 35648110 and 35681552, these have to be applied manually by running opatch apply in every patch directory, starting with 35681552 which is the Bundle Patch 19.21.
Now the dbhome_1 is on 19.21 with two additional one-off patches and will serve as source for our Gold Image.
Create the Gold Image
Next, from the patched Oracle Home, we create a Gold Image following the documentation.
setup.exe -createGoldImage -destinationLocation c:\app\oracle\images
Wait for the installer to finish, then you should have the newly created image in the directory stated by -destinationLocation.
Create new Oracle Home and database
Next we create a new Oracle Home and a Database ORCL/ORCLPDB under dbhome_2. Create the new directory, change the ORACLE_HOME variable in oraenv.cmd to point to dbhome_2 and run it. Then unpack the 19.03 software to that directory the same way as dbhome_1 before.
C:\app>mkdir c:\app\oracle\product\19.0.0\dbhome_2 C:\app>oraenv.cmd C:\app>cd %ORACLE_HOME% C:\app\oracle\product\19.0.0\dbhome_2>tar xfz z:\Install\Windows\WINDOWS.X64_193000_db_home.zip C:\app\oracle\product\19.0.0\dbhome_2>setup.bat
Run setup.exe in dbhome_2 and this time also create a database ORCL with a PDB ORCLPDB.
So now we have a patched dbhome_1 as source for the Gold Image and an unpatched dbhome_2 running the database ORCL with the PDB ORCLPDB.Out-of-place patching using the Gold Image
For out-of-place patching, we need to create a new Oracle Home, where we unpack the Gold Image. Change the ORACLE_HOME in oraenv.cmd to dbhome_3 and run it.
C:\app>oraenv.cmd C:\app>mkdir c:\app\oracle\product\19.0.0\dbhome_3 C:\app>cd %ORACLE_HOME% C:\app\oracle\product\19.0.0\dbhome_3>tar xfz c:\app\oracle\images\db_home_2024-02-21_05-21-14PM.zip C:\app\oracle\product\19.0.0\dbhome_3>setup
set OLDORA_HOME=%ORACLE_BASE%\product\19.0.0\dbhome_2
rem --- stop all Oracle services first --- net stop OracleOraDB19Home2MTSRecoveryService net stop OracleOraDB19Home2TNSListener net stop OracleServiceORCL net stop OracleVssWriterORCL
rem --- Copy spfile and pwdfile to new ORACLE_HOME copy %OLDORA_HOME%\database\SPFILEORCL.ORA %ORACLE_HOME%\database copy %OLDORA_HOME%\database\PWDorcl.ora %ORACLE_HOME%\database
rem -- Delete old services %OLDORA_HOME%\bin\oramtsctl -delete sc delete OracleOraDB19Home2TNSListener
rem --- Point services to new ORACLE_HOME sc config OracleServiceORCL binPath="c:\app\oracle\product\19.0.0\dbhome_3\bin\ORACLE.EXE ORCL" sc config OracleJobSchedulerORCL binPath="c:\app\oracle\product\19.0.0\dbhome_3\bin\extjob.exe ORCL" sc config OracleVssWriterORCL binPath="c:\app\oracle\product\19.0.0\dbhome_3\bin\OraVSSW.exe ORCL"
rem --- create new services %ORACLE_HOME%\bin\oramtsctl -new %ORACLE_HOME%\bin\lsnrctl start sc config "OracleOraDB19Home3TNSListener" start= auto
rem --- start new services oradim -EDIT -SID ORCL -STARTMODE auto -SRVCSTART system net start OracleServiceORCL
rem --- start the database and run datapatch rem --- not needed with service auto start --- @echo startup | sqlplus / as sysdba @echo alter pluggable database all open | sqlplus / as sysdba @echo show pdbs | sqlplus / as sysdba %ORACLE_HOME%\OPatch\datapatch
rem --- apply optimizer fixes for every PDB @echo @?/rdbms/admin/dbmsoptim.sql | sqlplus / as sysdba @echo @?/rdbms/admin/prvtoptim.plb | sqlplus / as sysdba @echo execute dbms_optim_bundle.enable_optim_fixes('ON','BOTH', 'YES'); | sqlplus / as sysdba