Opatch 是oracle公司开发的安装,卸载,检测patch冲突的工具,管理oracle所有已经安装的补丁!
opatch命令格式为:
opatch < command > [< command_options >] [ -h[elp] ]
oracle@rac3:/home/oracle/opatch/9472669>$ORACLE_HOME/OPatch/opatch -h
Oracle 中间补丁程序安装程序版本 11.2.0.1.9
版权所有 (c) 2011, Oracle Corporation。保留所有权利。
Usage: opatch [ -help ] [ -r[eport] ] [ command ]
command :=
apply 安装个别补丁
lsinventory 对inventory进行列表
lspatches 显示已经打的补丁
napply apply 的加强版本,可以同时打多个补丁
nrollback 同时回滚多个补丁
rollback 卸载个别补丁
query 显示某一个别补丁的详细信息
version 显示opatch版本信息
prereq
util
:= -help Displays the help message for the command.
-report Print the actions without executing.
example:
'opatch -help'
'opatch -help -fmw'
'opatch auto -help'
'opatch apply -help'
'opatch lsinventory -help'
'opatch lspatches -help'
'opatch napply -help'
'opatch nrollback -help'
'opatch rollback -help'
'opatch prereq -help'
'opatch util -help'
OPatch succeeded.
1 安装前准备:
1.1 安装non-recommended patch要咨询ORACLE SUPPORT,确认bug的现象和官方文档中的描述吻合
1.2 安装patch,系统必须确保perl的版本号大于5.00503,可以使用如下命令确认:
[root@rac3 oracle]# perl -v
This is perl, v5.8.8 built for x86_64-linux-thread-multi
如果不是可以参考Note 189489.1 - Oracle Data Server Interim Patch Installation来解决!
1.3 Verify the OUI Inventory.
检查 OUI Inventory Opatch工具需要完整且有效的Inventory信息。如果执行opatch lsinventory 出错,请及时和oracle 技术支持联系并使inventory 信息正确。
1.4 下载最新的Opatch工具:在metalink 上搜索bug db 6880880 比如linux 平台: p6880880_112000_Linux-x86-64
oracle@rac3:/opt/oracle/11.2.0/alifpre/OPatch>sh opatch version
OPatch Version: 11.2.0.1.9
OPatch succeeded.
1.5 创建存放patch的目录,比如
mkdir /home/oracle/patch
1.6 下载patch 并解压到存放patch的目录:以 patch 9472669为例:
oracle@rac3:/home/oracle/opatch>ls
p9472669_112010_Linux-x86-64.zip
oracle@rac3:/home/oracle/opatch>unzip -d /home/oracle/patch p9472669_112010_Linux-x86-64.zip
oracle@rac3:/home/oracle/opatch>ls
9472669 p9472669_112010_Linux-x86-64.zip
1.7 关闭oracle数据库所有服务:数据库,监听(可以放在前面的步骤中执行)
2 安装补丁
2.1安装一个补丁:
oracle@rac3:/home/oracle/opatch>cd 9472669/
oracle@rac3:/home/oracle/opatch/9472669>ls
etc files README.txt
oracle@rac3:/home/oracle/opatch/9472669>sh /opt/oracle/11.2.0/alifpre/OPatch/opatch apply
Oracle 中间补丁程序安装程序版本 11.2.0.1.9
版权所有 (c) 2011, Oracle Corporation。保留所有权利。
Oracle Home : /opt/oracle/11.2.0/alifpre
Central Inventory : /opt/oraInventory
from : /opt/oracle/11.2.0/alifpre/oraInst.loc
OPatch version : 11.2.0.1.9
OUI version : 11.2.0.1.0
Log file location : /opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/opatch2011-11-27_19-14-55下午.log
Applying interim patch '9472669' to OH '/opt/oracle/11.2.0/alifpre'
Verifying environment and performing prerequisite checks...
All checks passed.
提供电子邮件地址以用于接收有关安全问题的通知, 安装 Oracle Configuration Manager 并启动它。如果您使用 My Oracle
Support 电子邮件地址/用户名, 操作将更简单。
有关详细信息, 请访问 http://www.oracle.com/support/policies.html。
电子邮件地址/用户名:
尚未提供电子邮件地址以接收有关安全问题的通知。
是否不希望收到有关安全问题 (是 [Y], 否 [N]) [N] 的通知: Y
请关闭本地系统上在此 ORACLE_HOME 之外运行的 Oracle 实例。
(Oracle 主目录 = '/opt/oracle/11.2.0/alifpre')
本地系统是否已准备打补丁? [y|n]
Y
User Responded with: Y
Backing up files...
正在为组件 oracle.rdbms, 11.2.0.1.0 打补丁...
Patch 9472669 successfully applied
Log file location: /opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/opatch2011-11-27_19-14-55下午.log
OPatch succeeded.
用inventory 命令查看已经安装的patch
oracle@rac3:/home/oracle/opatch/9472669>$ORACLE_HOME/OPatch/opatch lsinventory
Oracle 中间补丁程序安装程序版本 11.2.0.1.9
版权所有 (c) 2011, Oracle Corporation。保留所有权利。
Oracle Home : /opt/oracle/11.2.0/alifpre
Central Inventory : /opt/oraInventory
from : /opt/oracle/11.2.0/alifpre/oraInst.loc
OPatch version : 11.2.0.1.9
OUI version : 11.2.0.1.0
Log file location : /opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/opatch2011-11-27_19-18-39下午.log
Lsinventory Output file location : /opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/lsinv/lsinventory2011-11-27_19-18-39下午.txt
--------------------------------------------------------------------------------
已安装的顶级产品 (1):
Oracle Database 11g 11.2.0.1.0
此 Oracle 主目录中已安装 1 个产品。
中间补丁程序 (1) :
Patch 9472669 : applied on Sun Nov 27 19:16:54 CST 2011
Unique Patch ID: 12554106
Created on 4 May 2010, 01:12:36 hrs PST8PDT
Bugs fixed:
9472669
--------------------------------------------------------------------------------
OPatch succeeded.
oracle@rac3:/home/oracle/opatch/9472669>
或者执行opatch lspatches 查看已经安装的patch:
oracle@rac3:/home/oracle/opatch/12419378>$ORACLE_HOME/OPatch/opatch lspatches
12419378;
9472669;
2.2 安装补丁集:
Bug 11724930 - 11.2.0.1.5 Patch Set Update (PSU) [ID 11724930.8]
oracle@rac3:/home/oracle/opatch/11724930>sh /opt/oracle/11.2.0/alifpre/OPatch/opatch apply
Oracle 中间补丁程序安装程序版本 11.2.0.1.9
版权所有 (c) 2011, Oracle Corporation。保留所有权利。
Oracle Home : /opt/oracle/11.2.0/alifpre
Central Inventory : /opt/oraInventory
from : /opt/oracle/11.2.0/alifpre/oraInst.loc
OPatch version : 11.2.0.1.9
OUI version : 11.2.0.1.0
Log file location : /opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/opatch2011-11-27_20-51-49下午.log
Applying interim patch '11724930' to OH '/opt/oracle/11.2.0/alifpre'
Verifying environment and performing prerequisite checks...
All checks passed.
提供电子邮件地址以用于接收有关安全问题的通知, 安装 Oracle Configuration Manager 并启动它。如果您使用 My Oracle
Support 电子邮件地址/用户名, 操作将更简单。
有关详细信息, 请访问 http://www.oracle.com/support/policies.html。
电子邮件地址/用户名:
尚未提供电子邮件地址以接收有关安全问题的通知。
是否不希望收到有关安全问题 (是 [Y], 否 [N]) [N] 的通知: Y
请关闭本地系统上在此 ORACLE_HOME 之外运行的 Oracle 实例。
(Oracle 主目录 = '/opt/oracle/11.2.0/alifpre')
本地系统是否已准备打补丁? [y|n]
y
User Responded with: Y
Backing up files...
正在为组件 oracle.rdbms.rsf, 11.2.0.1.0 打补丁...
正在为组件 oracle.rdbms.dbscripts, 11.2.0.1.0 打补丁...
正在为组件 oracle.rdbms, 11.2.0.1.0 打补丁...
将文件复制到 "/opt/oracle/11.2.0/alifpre/cpu/scripts/bug9371993.sql"
将文件复制到 "/opt/oracle/11.2.0/alifpre/cpu/scripts/bug9016295.sql"
将文件复制到 "/opt/oracle/11.2.0/alifpre/cpu/scripts/bug9758569.sql"
将文件复制到 "/opt/oracle/11.2.0/alifpre/psu/scripts/bug8820324.sql"
将文件复制到 "/opt/oracle/11.2.0/alifpre/psu/11.2.0.1.5/catpsu.sql"
将文件复制到 "/opt/oracle/11.2.0/alifpre/psu/11.2.0.1.5/catpsu_rollback.sql"
正在为组件 oracle.oraolap, 11.2.0.1.0 打补丁...
正在为组件 oracle.rdbms.deconfig, 11.2.0.1.0 打补丁...
正在为组件 oracle.javavm.server, 11.2.0.1.0 打补丁...
正在为组件 oracle.precomp.common, 11.2.0.1.0 打补丁...
正在为组件 oracle.network.rsf, 11.2.0.1.0 打补丁...
正在为组件 oracle.network.listener, 11.2.0.1.0 打补丁...
正在为组件 oracle.rdbms.dv.oc4j, 11.2.0.1.0 打补丁...
正在为组件 oracle.sdo.locator, 11.2.0.1.0 打补丁...
正在为组件 oracle.sysman.console.db, 11.2.0.1.0 打补丁...
正在为组件 oracle.sysman.oms.core, 10.2.0.4.2 打补丁...
正在为组件 oracle.rdbms.dv, 11.2.0.1.0 打补丁...
正在为组件 oracle.xdk.rsf, 11.2.0.1.0 打补丁...
正在为组件 oracle.ldap.rsf.ic, 11.2.0.1.0 打补丁...
正在为组件 oracle.ldap.rsf, 11.2.0.1.0 打补丁...
Patch 11724930 successfully applied
Log file location: /opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/opatch2011-11-27_20-51-49下午.log
OPatch succeeded.
注意:关于patch 冲突的问题:
OPatch categorizes two types of conflicts:
(a) Conflicts with a patch already applied to the ORACLE_HOME
In this case, please stop the patch installation and contact Oracle Support Services.
对于一个patch与已经安装的冲突,则要停止安装并和Oracle Support Services联系。
(b) Conflicts with subset patch already applied to the ORACLE_HOME
In this case, please continue the install, as the new patch contains all the fixes from the existing patch in the ORACLE_HOME.
The subset patch will automatically be rolled back prior to the installation of the new patch.
即如果是与已经安装的补丁集的子补丁冲突,则继续安装,那些冲突的子补丁会自动回滚!
比如:
oracle@rac3:/home/oracle/opatch/12419378>sh /opt/oracle/11.2.0/alifpre/OPatch/opatch apply
Oracle 中间补丁程序安装程序版本 11.2.0.1.9
版权所有 (c) 2011, Oracle Corporation。保留所有权利。
Oracle Home : /opt/oracle/11.2.0/alifpre
Central Inventory : /opt/oraInventory
from : /opt/oracle/11.2.0/alifpre/oraInst.loc
OPatch version : 11.2.0.1.9
OUI version : 11.2.0.1.0
Log file location : /opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/opatch2011-11-27_20-58-00下午.log
Applying interim patch '12419378' to OH '/opt/oracle/11.2.0/alifpre'
Verifying environment and performing prerequisite checks...
Interim patch 12419378 is a superset of the patch(es) [ 11724930 ] in the Oracle Home
OPatch 将回退补丁程序子集并应用指定的补丁程序。
Patch 12419378: Optional component(s) missing : [ oracle.client, 11.2.0.1.0 ]
All checks passed.
提供电子邮件地址以用于接收有关安全问题的通知, 安装 Oracle Configuration Manager 并启动它。如果您使用 My Oracle
Support 电子邮件地址/用户名, 操作将更简单。
有关详细信息, 请访问 http://www.oracle.com/support/policies.html。
电子邮件地址/用户名:
尚未提供电子邮件地址以接收有关安全问题的通知。
是否不希望收到有关安全问题 (是 [Y], 否 [N]) [N] 的通知: Y
请关闭本地系统上在此 ORACLE_HOME 之外运行的 Oracle 实例。
(Oracle 主目录 = '/opt/oracle/11.2.0/alifpre')
本地系统是否已准备打补丁? [y|n]
y
User Responded with: Y
Backing up files...
Rolling back interim patch '11724930' from OH '/opt/oracle/11.2.0/alifpre'
正在为组件 oracle.rdbms.rsf, 11.2.0.1.0 打补丁...
正在为组件 oracle.rdbms.dbscripts, 11.2.0.1.0 打补丁...
正在为组件 oracle.rdbms, 11.2.0.1.0 打补丁...
用 "/opt/oracle/11.2.0/alifpre/.patch_storage/11724930_Mar_25_2011_03_03_29/files//rdbms/jlib/schagent.jar/oracle/scheduler/agent/ExecutionAgent$1.class" 更新 jar 文件 "/opt/oracle/11.2.0/alifpre/rdbms/jlib/schagent.jar"
用 "/opt/oracle/11.2.0/alifpre/.patch_storage/11724930_Mar_25_2011_03_03_29/files//rdbms/jlib/schagent.jar/oracle/scheduler/agent/ExecutionAgent$2.class" 更新 jar 文件 "/opt/oracle/11.2.0/alifpre/rdbms/jlib/schagent.jar"
....省略....
正在为组件 oracle.oraolap, 11.2.0.1.0 打补丁...
正在为组件 oracle.rdbms.deconfig, 11.2.0.1.0 打补丁...
正在为组件 oracle.javavm.server, 11.2.0.1.0 打补丁...
正在为组件 oracle.precomp.common, 11.2.0.1.0 打补丁...
正在为组件 oracle.network.rsf, 11.2.0.1.0 打补丁...
正在为组件 oracle.network.listener, 11.2.0.1.0 打补丁...
正在为组件 oracle.rdbms.dv.oc4j, 11.2.0.1.0 打补丁...
正在为组件 oracle.sdo.locator, 11.2.0.1.0 打补丁...
正在为组件 oracle.sysman.console.db, 11.2.0.1.0 打补丁...
正在为组件 oracle.sysman.oms.core, 10.2.0.4.2 打补丁...
正在为组件 oracle.rdbms.dv, 11.2.0.1.0 打补丁...
正在为组件 oracle.xdk.rsf, 11.2.0.1.0 打补丁...
正在为组件 oracle.ldap.rsf.ic, 11.2.0.1.0 打补丁...
正在为组件 oracle.ldap.rsf, 11.2.0.1.0 打补丁...
正在为组件 oracle.sysman.plugin.db.main.repository, 11.2.0.1.0 打补丁...
Patch 12419378 successfully applied
OPatch 会话已完成, 但出现警告。
别忘了查看日志/opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/opatch2011-11-27_20-58-00下午.log。
对于psu 可以通过下面的命令查看所有的补丁!
oracle@rac3:/home/oracle/opatch/12419378>$ORACLE_HOME/OPatch/opatch lsinventory
Oracle Home : /opt/oracle/11.2.0/alifpre
Central Inventory : /opt/oraInventory
from : /opt/oracle/11.2.0/alifpre/oraInst.loc
OPatch version : 11.2.0.1.9
OUI version : 11.2.0.1.0
Log file location : /opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/opatch2011-11-27_21-09-19下午.log
Lsinventory Output file location : /opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/lsinv/lsinventory2011-11-27_21-09-19下午.txt
--------------------------------------------------------------------------------
已安装的顶级产品 (1):
Oracle Database 11g 11.2.0.1.0
此 Oracle 主目录中已安装 1 个产品。
中间补丁程序 (2) :
Patch 12419378 : applied on Sun Nov 27 21:00:37 CST 2011
Unique Patch ID: 13769952
Created on 8 Jul 2011, 02:47:43 hrs PST8PDT
Bugs fixed:
9068088, 9363384, 8865718, 8898852, 8801119, 9054253, 8725286, 8974548
9093300, 8909984, 8755082, 8780372, 9952216, 8664189, 8769569, 7519406
9302343, 9471411, 8822531, 7705591, 8650719, 10205230, 9637033, 8883722
8639114, 8723477, 8729793, 8919682, 8856478, 9001453, 8733749, 8565708
8735201, 8684517, 8870559, 8773383, 8981059, 8812705, 9488887, 12534742
8813366, 12534743, 9242411, 12534745, 12534746, 12534747, 8822832
12534748, 8897784, 8760714, 12534749, 8775569, 8671349, 8898589, 9714832
8642202, 9011088, 9369797, 9170608, 9165206, 8834636, 8891037, 8431487
8570322, 8685253, 8872096, 8718952, 8799099, 12534750, 9032717, 9399090
12534751, 12534752, 9713537, 9546223, 12534753, 12534754, 8588519
8783738, 12534755, 12534756, 8834425, 9454385, 8856497, 8890026, 8721315
10248516, 8818175, 8674263, 10249532, 9145541, 8720447, 9272086, 9467635
9010222, 9102860, 9197917, 8991997, 8661168, 8803762, 12419378, 8769239
9654983, 8706590, 8546356, 10408903, 8778277, 9058865, 8815639, 11724991
9971778, 9971779, 9027691, 9454036, 9454037, 9454038, 8761974, 9255542
9275072, 8496830, 8702892, 8818983, 8475069, 8875671, 9328668, 8891929
8798317, 9971780, 8782959, 8774868, 8820324, 8544696, 8702535, 9952260
9406607, 8268775, 9036013, 9363145, 8933870, 8405205, 9467727, 8822365
9676419, 11724930, 8761260, 8790767, 8795418, 8913269, 8717461, 8861700
9531984, 8607693, 8780281, 8330783, 8784929, 8780711, 9341448, 9015983
10323077, 8828328, 9119194, 10323079, 8832205, 8717031, 8665189, 9482399
9676420, 9399991, 8821286, 8633358, 9321701, 9655013, 9231605, 8796511
9167285, 8782971, 8756598, 8703064, 9390484, 9066116, 9007102, 9461782
10323080, 10323081, 10323082, 8753903, 8505803, 9382101, 9352237, 9216806
8918433, 11794163, 9057443, 8790561, 11794164, 8733225, 8795792, 11794165
11794167, 9067282, 8928276, 8837736, 9210925
Patch 9472669 : applied on Sun Nov 27 19:16:54 CST 2011
Unique Patch ID: 12554106
Created on 4 May 2010, 01:12:36 hrs PST8PDT
Bugs fixed:
9472669
3 卸载补丁:
oracle@rac3:/home/oracle/opatch/9472669>$ORACLE_HOME/OPatch/opatch rollback -id 9472669
Oracle 中间补丁程序安装程序版本 11.2.0.1.9
版权所有 (c) 2011, Oracle Corporation。保留所有权利。
Oracle Home : /opt/oracle/11.2.0/alifpre
Central Inventory : /opt/oraInventory
from : /opt/oracle/11.2.0/alifpre/oraInst.loc
OPatch version : 11.2.0.1.9
OUI version : 11.2.0.1.0
Log file location : /opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/opatch2011-11-27_21-59-51下午.log
RollbackSession 从 OH '/opt/oracle/11.2.0/alifpre' 回退中间补丁程序 '9472669'
请关闭本地系统上在此 ORACLE_HOME 之外运行的 Oracle 实例。
(Oracle 主目录 = '/opt/oracle/11.2.0/alifpre')
本地系统是否已准备打补丁? [y|n]
y
User Responded with: Y
正在为组件 oracle.rdbms, 11.2.0.1.0 打补丁...
RollbackSession 从产品清单中删除中间补丁程序 '9472669'
Log file location: /opt/oracle/11.2.0/alifpre/cfgtoollogs/opatch/opatch2011-11-27_21-59-51下午.log
OPatch succeeded.
oracle@rac3:/home/oracle/opatch/9472669>$ORACLE_HOME/OPatch/opatch lspatches
12419378;