Windows环境下给oracle打补丁详细教程

环境检查

1、检查oracle数据库版本,安装前检查:确保Oracle数据库安装与您正在应用此修补程序的版本相同。

C:\WINDOWS\system32>sqlplus -v
SQL*Plus: Release 11.2.0.1.0 Production

2、OPatch工具检查
OPatch工具包,在安装目录$ORACLE_HOME下,PSU安装升级,都是通过OPatch来完成的。PSU的升级安装对OPatch的版本有一定的要求,关于这一点,可以查看PSU的Readme文档。例如,要安装p21352635_112040_Linux-x86-64,则必须要11.2.0.3.6或更高版本的OPatch。确定当前系统的OPatch版本
先配置oracle环境变量
Windows环境下给oracle打补丁详细教程_第1张图片
Windows环境下给oracle打补丁详细教程_第2张图片
检查opatch版本

C:\WINDOWS\system32>opatch version
Invoking OPatch 11.1.0.6.6
OPatch Version: 11.1.0.6.6
OPatch succeeded.

检测当前数据补丁安装情况。

C:\WINDOWS\system32>opatch lsinventory
Invoking OPatch 11.1.0.6.6
Oracle 中间补丁程序安装程序版本 11.1.0.6.6
版权所有 (c) 2009, Oracle Corporation。保留所有权利。
Oracle 主目录       : F:\app\mr_fan\product\11.2.0\dbhome_1
主产品清单: C:\Program Files\Oracle\Inventory
   从           : n/a
OPatch 版本    : 11.1.0.6.6
OUI 版本       : 11.2.0.1.0
OUI 位置      : F:\app\mr_fan\product\11.2.0\dbhome_1\oui
日志文件位置 : F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\opatch2020-03-15_17-44-54下午.log
Patch history file: F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\opatch_history.txt
Lsinventory Output file location : F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\lsinv\lsinventory2020-03-15_17-44-54下午.txt
--------------------------------------------------------------------------------
已安装的顶级产品 (1):

Oracle Database 11g                                                  11.2.0.1.0
此 Oracle 主目录中已安装 1 个产品。
此 Oracle 主目录中未安装任何中间补丁程序。
--------------------------------------------------------------------------------

请用管理员权限运行如下命令,否则可能报错

产品清单加载失败... OPatch cannot load inventory for the given Oracle Home.
LsInventorySession 失败: LsInventory cannot create the log directory F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\lsinv\lsinventory2020-03-15_17-44-20下午.txt
java.lang.RuntimeException: LsInventory cannot create the log directory F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\lsinv\lsinventory2020-03-15_17-44-20下午.txt
        at oracle.opatch.LsInventorySession.init(LsInventorySession.java:220)
        at oracle.opatch.LsInventorySession.loadAndPrintInventory(LsInventorySession.java:376)
        at oracle.opatch.LsInventorySession.process(LsInventorySession.java:327)
        at oracle.opatch.OPatchSession.main(OPatchSession.java:1579)
        at oracle.opatch.OPatch.main(OPatch.java:630)
OPatch failed with error code = 73

3、关闭数据库相关的所有服务
Windows环境下给oracle打补丁详细教程_第3张图片
4、将下载的补丁进行解压,并在补丁根目录下执行 opatch apply命令进行补丁安装。

C:\WINDOWS\system32>e:

E:\>cd E:\13423278

E:\13423278>opatch apply

Invoking OPatch 11.1.0.6.6
Oracle 中间补丁程序安装程序版本 11.1.0.6.6
版权所有 (c) 2009, Oracle Corporation。保留所有权利。
Oracle 主目录       : F:\app\mr_fan\product\11.2.0\dbhome_1
主产品清单: C:\Program Files\Oracle\Inventory
   从           : n/a
OPatch 版本    : 11.1.0.6.6
OUI 版本       : 11.2.0.1.0
OUI 位置      : F:\app\mr_fan\product\11.2.0\dbhome_1\oui
日志文件位置 : F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\opatch2020-03-15_17-53-23下午.log
Patch history file: F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\opatch_history.txt
ApplySession 将中间补丁程序 '13423278' 应用到 OH 'F:\app\mr_fan\product\11.2.0\dbhome_1'
Running prerequisite checks...
Prerequisite check "CheckActiveFilesAndExecutables" failed.
The details are:
Following files are active :
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\orageneric11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\oraclient11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\orapls11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\oracommon11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\oraxml11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\oranhost11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\oran11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\oranro11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\orantcp11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\orazt11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\orahasgen11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\oci.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\orasql11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\oraldapclnt11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\oraztkg11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\orannzsbb11.dll
F:\app\mr_fan\product\11.2.0\dbhome_1\bin\orasnls11.dll
在先决条件检查期间 ApplySession 失败: Prerequisite check "CheckActiveFilesAndExecutables" failed.
系统无任何变化, OPatch 不会尝试还原系统
OPatch failed with error code = 74

执行过程中可能会出现如下错误,此时有些进程正在占用如上文件
可执行 Tasklist /name xxx.dll命令查询哪些进程在占用,关闭相关进程

E:\13423278>Tasklist /m orageneric11.dll
映像名称                       PID 模块
========================= ======== ============================================
emagent.exe                  10020 orageneric11.dll
E:\13423278>

结束进程
Windows环境下给oracle打补丁详细教程_第4张图片
再次执行打补丁命令

e:\13423278>opatch apply
Invoking OPatch 11.1.0.6.6
Oracle 中间补丁程序安装程序版本 11.1.0.6.6
版权所有 (c) 2009, Oracle Corporation。保留所有权利。
Oracle 主目录       : F:\app\mr_fan\product\11.2.0\dbhome_1
主产品清单: C:\Program Files\Oracle\Inventory
   从           : n/a
OPatch 版本    : 11.1.0.6.6
OUI 版本       : 11.2.0.1.0
OUI 位置      : F:\app\mr_fan\product\11.2.0\dbhome_1\oui
日志文件位置 : F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\opatch2020-03-15_18-24-31下午.log
Patch history file: F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\opatch_history.txt
ApplySession 将中间补丁程序 '13423278' 应用到 OH 'F:\app\mr_fan\product\11.2.0\dbhome_1'
Running prerequisite checks...
Patch 13423278: Optional component(s) missing : [ oracle.rdbms.ic, 11.2.0.1.0 ] , [ oracle.has.crs, 11.2.0.1.0 ] , [ oracle.usm, 11.2.0.1.0 ]
OPatch 从产品清单中检测到非集群 Oracle 主目录, 将仅对本地系统打补丁。
请关闭本地系统上在此 ORACLE_HOME 之外运行的 Oracle 实例。
(Oracle 主目录 = 'F:\app\mr_fan\product\11.2.0\dbhome_1')
本地系统是否已准备打补丁? [y|n]
本地系统是否已准备打补丁? [y|n]
y
User Responded with: Y
为 Oracle 主目录备份文件和产品清单 (不是用于自动回退)
正在备份受补丁程序 '13423278' 影响的文件以用于还原。此操作将需要一些时间...
正在备份受补丁程序 '13423278' 影响的文件以用于回退。此操作将需要一些时间...

等待补丁安装
Windows环境下给oracle打补丁详细教程_第5张图片
安装完成
Windows环境下给oracle打补丁详细教程_第6张图片
查看补丁清单列表

e:\13423278>yopatch lsinventory
'yopatch' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
e:\13423278>opatch lsinventory
Invoking OPatch 11.1.0.6.6
Oracle 中间补丁程序安装程序版本 11.1.0.6.6
版权所有 (c) 2009, Oracle Corporation。保留所有权利。
Oracle 主目录       : F:\app\mr_fan\product\11.2.0\dbhome_1
主产品清单: C:\Program Files\Oracle\Inventory
   从           : n/a
OPatch 版本    : 11.1.0.6.6
OUI 版本       : 11.2.0.1.0
OUI 位置      : F:\app\mr_fan\product\11.2.0\dbhome_1\oui
日志文件位置 : F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\opatch2020-03-15_18-44-42下午.log
Patch history file: F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\opatch_history.txt
Lsinventory Output file location : F:\app\mr_fan\product\11.2.0\dbhome_1\cfgtoollogs\opatch\lsinv\lsinventory2020-03-15_18-44-42下午.txt
--------------------------------------------------------------------------------
已安装的顶级产品 (1):
Oracle Database 11g                                                  11.2.0.1.0
此 Oracle 主目录中已安装 1 个产品。
中间补丁程序 (1) :
Patch  13423278     : applied on Sun Mar 15 18:40:10 CST 2020
Unique Patch ID:  14296670
   Created on 23 Nov 2011, 02:07:52 hrs PST8PDT
   Bugs fixed:
     13423278, 13329697, 12759946, 12672969, 8509848, 12345717, 9829397
     9654402, 12595606, 8794599, 12572417, 9885553, 11678127, 12794025
     10265545, 10189276, 10019194, 12731983, 12838161, 12400751, 10149919
     12591120, 9842573, 8711391, 12371955, 10093383, 11828358, 12655301
     8860207, 11694194, 10350832, 12541628, 12429529, 9554332, 12363485
     10625485, 9268192, 9935787, 10205230, 12412745, 12393432, 12341758
     10130392, 11853331, 6055658, 11723722, 11735927, 11772687, 9902590
     9871302, 10132870, 7365514, 10422748, 10180190, 9825461, 11731176
     9368502, 9705984, 10302581, 10130633, 8331063, 10237271, 10082277
     10054513, 9695366, 8889137, 10383833, 11076894, 10220194, 10401327
     9042035, 10235640, 9564886, 10104492, 9302054, 10374238, 9613016, 10432045
     8772524, 10357603, 9243068, 9448277, 8672862, 9725141, 9328390, 9275876
     9033671, 10154951, 9890701, 9628444, 10352692, 10086495, 10155684
     10156303, 10157313, 10201938, 10220033, 10278864, 8332021, 8771916
     8800514, 8874588, 8946311, 9003145, 9115829, 9131242, 9240305, 9398685
     9469117, 9569029, 9751158, 8446618, 10245351, 10052141, 10116578
     10134677, 10140809, 10157402, 10172454, 7662438, 8397251, 8499180
     8522654, 9090269, 9234660, 9255996, 9395237, 9461782, 9668086, 9703463
     9736701, 9795214, 9823660, 9826065, 9866728, 9916260, 9972680, 9524640
     8841699, 10216200, 10225758, 10155838, 10030675, 10080167, 10132342
     6866145, 8790561, 8984021, 9096076, 9137871, 9193873, 9277263, 9303326
     9457109, 9457492, 9472669, 9539440, 9659614, 9845644, 9903704, 9920616
     9930649, 10100101, 8780369, 8866808, 8883722, 9004242, 9021724, 9028780
     9049725, 9058865, 9212844, 9243912, 9306119, 9350527, 9387574, 9399991
     9413827, 9488247, 9498108, 9500147, 9532911, 9544104, 9548269, 9578533
     9593656, 9594372, 9706490, 9721013, 9734300, 9746699, 9764806, 9770451
     9778018, 9799342, 9828495, 9881328, 9932143, 10080735, 9901433, 9966926
     8574851, 8790837, 8802195, 8863249, 8981681, 8993052, 9198871, 9217088
     9300021, 9369183, 9442189, 9500046, 9648040, 9657283, 9685694, 9772171
     9847494, 9793452, 9888298, 9135679, 9495697, 9081430, 6855031, 8793567
     9286015, 9442015, 9504322, 9535951, 8684595, 9663844, 9539556, 7452759
     9196440, 8893949, 9011590, 9382101, 9775337, 9083671, 9324531, 8654177
     8569325, 8686932, 9271344, 8434467, 6086930, 9024737, 9047975, 9056912
     9069046, 9336476, 9355794, 9495669, 8467123, 8663644, 8855396, 8886819
     8951812, 8467825, 9187546, 9102860, 9109487, 8546356, 9170308, 8725282
     9308296, 9406607, 8720802, 9711859, 9531984, 9482399, 9471411, 9390484
     9362218, 9320786, 9320130, 9302343, 9290526, 9231605, 8554900, 9490054
     9389304, 8783690, 9577583, 9736229, 9259407, 8602840, 9469133, 8682102
     9693101, 9898160, 9669478, 9736865, 7327630, 8268775, 8505803, 8544696
     8565708, 8633358, 8664189, 8702535, 8755082, 8771556, 8783301, 8790767
     8799099, 8803762, 8839301, 8856478, 8865718, 8872096, 8909984, 8974548
     8981059, 8991997, 9023338, 9032717, 9057443, 9119194, 9145181, 9147830
     9165206, 9170608, 9216806, 9219338, 9227662, 9255542, 9275072, 9321701
     9341448, 9363145, 9363384, 9391025, 9399090, 9467635, 9488887, 9637033
     9711600, 9713537, 9714832, 9719541, 9736836, 7028305, 7519406, 8330783
     8431487, 8477973, 8496830, 8581792, 8607693, 8643160, 8650719, 8717461
     8730312, 8774868, 8813536, 8815639, 8822531, 8822832, 8834425, 8875671
     8879707, 8891929, 8914054, 8918433, 9001453, 9002336, 9007859, 9010222
     9011088, 9015983, 9027691, 9035113, 9041943, 9050716, 9053676, 9054253
     9057754, 9067282, 9068088, 9093300, 9120088, 9145541, 9167285, 9189070
     9202351, 9271246, 9272086, 9294110, 9298307, 9316329, 9378712, 9395500
     9408883, 9467727, 9504129, 9561609, 9584383, 9657157, 9661684, 9489422
     9595786, 8405205, 8543770, 8856467, 8998066, 8897784, 9004697, 9007836
     9036013, 9037724, 9047110, 9318214, 8328200, 8570322, 8629716, 8761974
     8857211, 8885539, 9035438, 8971021, 8685327, 8707506, 8866903, 8771297
     8772028, 8796511
-------------------------------------------------------------------------------
OPatch succeeded.

至此安装完成

你可能感兴趣的:(oracle)