【Oracle】Opatch 工具介紹
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
<global_arguments> := -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/opatch3011-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/opatch3011-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/opatch3011-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/opatch3011-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/opatch3011-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/opatch3011-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/opatch3011-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/opatch3011-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/opatch3011-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/opatch3011-11-27_21-59-51下午.log
OPatch succeeded.
oracle@rac3:/home/oracle/opatch/9472669>$ORACLE_HOME/OPatch/opatch lspatches
12419378;