【转】opatch学习
【转自:https://yq.aliyun.com/articles/28007,仅作学习用途】
Opatch 是oracle公司开发的安装,卸载,检测patch冲突的工具,管理oracle所有已经安装的补丁!
opatch命令格式为:
opatch < command > [< command_options >] [ -h[elp] ]
(一)opatch -help查看帮助信息
[oracle@rac1 ~]$ opatch -h
Oracle Interim Patch Installer version 11.2.0.3.4
Copyright (c) 2012, Oracle Corporation. All rights reserved.
Usage: opatch [ -help ] [ -report ] [ command ]
command :=
apply --安装个别补丁
lsinventory --列出inventory信息
lspatches --列出已安装补丁
napply --apply的加强版,可同时打多个补丁
rollback --回滚个别补丁
nrollback --回滚多个补丁
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'
(二)patch安装
(2.1) 安装non-recommended patch要咨询ORACLE SUPPORT,确认bug的现象和官方文档中的描述吻合
(2.2) 安装patch,系统必须确保perl的版本号大于5.00503,可以使用如下命令确认:
[root@redhat6 ~]# perl -v
This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi
Copyright 1987-2009, Larry Wall
(2.3) Verify the OUI Inventory.
检查 OUI Inventory Opatch工具需要完整且有效的Inventory信息。如果执行opatch lsinventory 出错,请及时和oracle 技术支持联系并使inventory 信息正确。
(2.4) 创建存放patch的目录,比如
mkdir /home/oracle/patch
(2.5)下载patch 并解压到存放patch的目录:以 patch 9472669为例:
oracle@rac1:/home/oracle/opatch>ls
p9472669_112010_Linux-x86-64.zip
oracle@rac1:/home/oracle/opatch>unzip -d /home/oracle/patch p9472669_112010_Linux-x86-64.zip
oracle@rac1:/home/oracle/opatch>ls
9472669 p9472669_112010_Linux-x86-64.zip
(2.6) 关闭oracle数据库所有服务:数据库,监听
(2.7)安装一个补丁,到下载的补丁目录下,执行$OARCLE_HOME/OPatch/opatch apply
oracle@rac1:/home/oracle/opatch>cd 9472669/
oracle@rac1:/home/oracle/opatch/9472669>ls
etc files README.txt
oracle@rac1:/home/oracle/opatch/9472669>$ORACLE_HOME/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.
(2.8)用inventory 命令查看已经安装的patch
oracle@rac1:/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.
或者执行opatch lspatches 查看已经安装的patch:
oracle@rac1:/home/oracle/opatch/12419378>$ORACLE_HOME/OPatch/opatch lspatches
12419378;
9472669;
(三)卸载补丁
oracle@rac1:/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@rac1:/home/oracle/opatch/9472669>$ORACLE_HOME/OPatch/opatch lspatches
12419378;