opatch 是ORACLE开发的用来安装,卸载,检测patch冲突、管理ORACLE所有已经安装的补丁的工具,当然这是一个命令工具。opatch命令工具一般位于$ORACLE_HOME/OPatch/下,

1: 查看opatch帮助信息

一般可以用./opatch -help来查看帮助提示。不同版本的opatch的命令有所差异,通过help看到的信息估计有所出入。虽然opatch只有这几个命令,但是每个命令都有大量的参数,所以要完全掌握,还是需要花点时间去学习、实践。

[oracle@DB-Server OPatch]$ ./opatch -help
Invoking OPatch 10.2.0.4.2

Oracle Interim Patch Installer version 10.2.0.4.2
Copyright (c) 2007, Oracle Corporation.  All rights reserved.

Usage: opatch [ -help ] [ -r[eport] ] [ command ]

            command := apply
                       lsinventory
                       napply
                       nrollback
                       rollback
                       query
                       version
                       prereq
                       util

<global_arguments> := -help       Displays the help message for the command.
                       -report     Print the actions without executing.

example:
   'opatch -help'
   'opatch apply -help'
   'opatch lsinventory -help'
   'opatch napply -help'
   'opatch nrollback -help'
   'opatch rollback -help'
   'opatch prereq -help'
   'opatch util -help'

OPatch succeeded.

ORACLE 10g Release 2 官方文档关于opatch介绍http://docs.oracle.com/cd/B19306_01/em.102/b16227/oui8_opatch.htm ,里面关于opatch命令的介绍如下

Table 7-1 OPatch Commands

Command

Description

apply

Installs an interim patch. Refer to "apply Command" for more information.

napply

Installs n number of patches (hence napply). Refer to "napply Command" for more information.

auto

Applies Oracle Clusterware patches. Refer to "auto Command" for more information.

lsinventory

Lists what is currently installed on the system. Refer to "lsinventory Command" for more information.

query

Queries a given patch for specific details. Refer to "query Command" for more information.

rollback

Removes an interim patch. Refer to "rollback Command" for more information.

nrollback

Removes n number of patches (hence nrollback). Refer to "nrollback Command" for more information.

version

Prints the current version of the patch tool. Refer to "version Command" for more information.

关于opatch命令的详细文档信息其实可以查看 Users_Guide.txt & FAQ等

[oracle@DB-Server OPatch]$ ls

docs emdpatch.pl jlib opatch opatch.ini opatch.pl opatchprereqs

[oracle@DB-Server OPatch]$ cd docs/

[oracle@DB-Server docs]$ ls

FAQ Prereq_Users_Guide.txt Users_Guide.txt

2:查看opatch版本信息

[oracle@DB-Server OPatch]$ ./opatch version

Invoking OPatch 10.2.0.4.2

OPatch Version: 10.2.0.4.2

OPatch succeeded.

3:opatch 打补丁示例

以补丁p6074620_10204_Linux-x86-64.zip为例

Setp 1: 下载解压补丁文件

[oracle@DB-Server u04]$ unzip p6074620_10204_Linux-x86-64.zip

[oracle@DB-Server u04]$ cd 6074620/

Step 2: 关闭数据库实例

Step 3:查看补丁README.txt文件,了解注意事项

[oracle@DB-Server 6074620]$ more README.txt 

# 

#  WARNING: Failure to carefully read and understand these requirements may

#  result in your applying a patch that can cause  your Oracle Server to

#  malfunction, including interruption of service and/or loss of data. 

# 

#  If you do not meet all of the following requirements, please log an

#  iTAR, so that an Oracle Support Analyst may review your situation. The

#  Oracle analyst will help you determine if this patch is suitable for you

#  to apply to your system. We recommend that you avoid applying any

#  temporary patch unless directed by an Oracle Support Analyst who has

#  reviewed your system and determined that it is applicable. 

# 

#  Requirements: 

# 

#    - You must have located this patch via a Bug Database entry

#      and have the exact symptoms described in the bug entry. 

# 

#    - Your system configuration (Oracle Server version and patch

#      level, OS Version) must exactly match those in the bug

#      database entry - You must have NO OTHER PATCHES installed on

#      your Oracle Server since the latest patch set (or base release

#      x.y.z if you have no patch sets installed).

# 

#    - [Oracle 9.2.0.2 & above] You must have Perl 5.00503 (or later)

#      installed under the ORACLE_HOME, or elsewhere within the host

#      environment. OPatch is no longer included in patches as of 9.2.0.2.

#      Refer to the following link for details on Perl and OPatch:

#      http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=189489.1

# 

#    - [IBM AIX O/S & Java patches for Oracle 9.2] 

#      In order to apply java class updates to IBM AIX based systems using 

#      java_131, you must update your java if you are running a version prior 

#      to Service Refresh build date 20030630a. This is 

#      necessary to fix IBM Defect#60472. 

# 

#      To identify which java build date you are on, enter the following 

#      command ; 

# 

#      > $ORACLE_HOME/jdk/bin/java -fullversion 

#      ... example response ... 

#      java full version "J2RE 1.3.1 IBM AIX build ca131-20030630a" 

# 

#      The string ends in the date format YYYYMMDD or YYYYMMDDa where 'a' 

#      indicates an updated release to the original build. You should always 

#      apply the latest AIX Java SDK 1.3.1  Service Update available from IBM. 

#      As a minimum, the above service refresh can be found under 

#      APAR IY47055. The signature for the updated JVM is ca131-20030630a. 

#      Information on the latest available fixes, as well as how to apply 

#      the APARs to your AIX systems, is available at the IBM Java site.

# 

#      If you are running AIX 5L, you can safely ignore any comment against

#      the APAR that says (AIXV43 only). The APAR is applicable to 

#      both AIX 4.3 and AIX 5L. 

# 

#      Once you have updated your java installation you need to copy these 

#      updated files to Oracle's copies in $ORACLE_HOME/jdk. 

#      As the Oracle owner, simply issue the following commands; 

# 

#      > cd /usr/java131 

#      > cp -fpR * $ORACLE_HOME/jdk 

# 

#

#  If you do NOT meet these requirements, or are not certain that you meet

#  these requirements, please log an iTAR requesting assistance with this

#  patch and Support will make a determination about whether you should

#  apply this patch. 

# 

#-------------------------------------------------------------------------

#  Interim Patch for Base Bugs: 6074620 

#-------------------------------------------------------------------------

#

#  DATE:  Thu Jan 29 22:43:53 2009

#  -------------------------------

#  Platform Patch for : Linux x86-64

#  Product Version #  : 10.2.0.4

#  Product Patched    : RDBMS

#

#  Bugs Fixed by this patch:

#  -------------------------

#  6074620:LGWR UNCONDITIONALLY WRITES TO TRACE FILE

#

#  Patch Installation Instructions:

#  --------------------------------

#  To apply the patch, unzip the PSE container file:

#

#  p6074620_10204_Linux-x86-64.zip

#

#  Set your current directory to the directory where the patch

#  is located:

#

#    % cd 6074620

#

#  Ensure that the directory containing the opatch script appears in

#  your $PATH; then enter the following command:

#

#    % opatch apply

#

#  Patch Special Instructions:

#  ---------------------------

#  Make sure all instances running under the ORACLE_HOME being patched

#  are cleanly shutdown before installing this patch. Also ensure that

#  the tool used to terminate the instance(s) has exited cleanly.

#

#  If the Oracle inventory is not setup correctly this utility will

#  fail. To check accessibility to the inventory you can use the

#  command

#

#    % opatch lsinventory

#

#  If you have any problems installing this PSE or are not sure

#  about inventory setup please call Oracle support.

#

#  Patch Deinstallation Instructions:

#  ----------------------------------

#  Use the following command:

#

#    % cd 6074620

#    % opatch rollback -id 6074620

#

Setp 4: opatch打补丁

[oracle@DB-Server 6074620]$ $ORACLE_HOME/OPatch/opatch apply

 

Invoking OPatch 10.2.0.4.2

 

Oracle Interim Patch Installer version 10.2.0.4.2

 

Copyright (c) 2007, Oracle Corporation. All rights reserved.

 

Oracle Home : /u01/app/oracle/product/10.2.0/db_1

 

Central Inventory : /u01/app/oracle/oraInventory

 

from : /etc/oraInst.loc

 

OPatch version : 10.2.0.4.2

 

OUI version : 10.2.0.4.0

 

OUI location : /u01/app/oracle/product/10.2.0/db_1/oui

 

Log file location : /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch2014-04-11_17-02-01PM.log

 

ApplySession applying interim patch '6074620' to OH '/u01/app/oracle/product/10.2.0/db_1'

 

Running prerequisite checks...

 

OPatch detected non-cluster Oracle Home from the inventory and will patch the local system only.

 

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.

 

(Oracle Home = '/u01/app/oracle/product/10.2.0/db_1')

 

Is the local system ready for patching? [y|n]

 

Could not recognize input. Please re-enter.

 

y

 

User Responded with: Y

 

Backing up files and inventory (not for auto-rollback) for the Oracle Home

 

Backing up files affected by the patch '6074620' for restore. This might take a while...

 

Backing up files affected by the patch '6074620' for rollback. This might take a while...

 

Patching component oracle.rdbms, 10.2.0.4.0...

 

Updating archive file "/u01/app/oracle/product/10.2.0/db_1/lib/libserver10.a" with "lib/libserver10.a/kcrr.o"

 

Running make for target ioracle

 

ApplySession adding interim patch '6074620' to inventory

 

Verifying the update...

 

Inventory check OK: Patch ID 6074620 is registered in Oracle Home inventory with proper meta-data.

 

Files check OK: Files from Patch ID 6074620 are present in Oracle Home.

 

The local system has been patched and can be restarted.

 

OPatch succeeded.

 

5:opatch 查看补丁情况

[oracle@DB-Server OPatch]$ ./opatch lsinventory

 

Invoking OPatch 10.2.0.4.2

 

Oracle Interim Patch Installer version 10.2.0.4.2

 

Copyright (c) 2007, Oracle Corporation. All rights reserved.

 

Oracle Home : /u01/app/oracle/product/10.2.0/db_1

 

Central Inventory : /u01/app/oracle/oraInventory

 

from : /etc/oraInst.loc

 

OPatch version : 10.2.0.4.2

 

OUI version : 10.2.0.4.0

 

OUI location : /u01/app/oracle/product/10.2.0/db_1/oui

 

Log file location : /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch2014-04-11_17-04-41PM.log

 

Lsinventory Output file location : /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2014-04-11_17-04-41PM.txt

 

--------------------------------------------------------------------------------

 

Installed Top-level Products (2): 

 

Oracle Database 10g 10.2.0.1.0

 

Oracle Database 10g Release 2 Patch Set 3 10.2.0.4.0

 

There are 2 products installed in this Oracle Home.

 

Interim patches (1) :

 

Patch 6074620 : applied on Fri Apr 11 17:03:10 CST 2014

 

Created on 29 Jan 2009, 22:44:17 hrs US/Pacific

 

Bugs fixed:

 

6074620

 

--------------------------------------------------------------------------------

 

OPatch succeeded.

 

6:opatch 卸载补丁

[oracle@DB-Server OPatch]$ ./opatch rollback -id 9264253

 

Invoking OPatch 10.2.0.4.2

 

Oracle Interim Patch Installer version 10.2.0.4.2

 

Copyright (c) 2007, Oracle Corporation. All rights reserved.

 

Oracle Home : /u01/app/oracle/product/10.2.0/db_1

 

Central Inventory : /u01/app/oracle/oraInventory

 

from : /etc/oraInst.loc

 

OPatch version : 10.2.0.4.2

 

OUI version : 10.2.0.4.0

 

OUI location : /u01/app/oracle/product/10.2.0/db_1/oui

 

Log file location : /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch2014-04-15_09-01-41AM.log

 

RollbackSession rolling back interim patch '9264253' from OH '/u01/app/oracle/product/10.2.0/db_1'

 

Running prerequisite checks...

 

OPatch detected non-cluster Oracle Home from the inventory and will patch the local system only.

 

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.

 

(Oracle Home = '/u01/app/oracle/product/10.2.0/db_1')

 

Is the local system ready for patching? [y|n]

 

y

 

User Responded with: Y

 

Backing up files affected by the patch '9264253' for restore. This might take a while...

 

Patching component oracle.rdbms, 10.2.0.4.0...

 

Updating archive file "/u01/app/oracle/product/10.2.0/db_1/lib/libserver10.a" with "lib/libserver10.a/ksu.o"

 

Running make for target ioracle

 

RollbackSession removing interim patch '9264253' from inventory

 

The local system has been patched and can be restarted.

 

OPatch succeeded.

 

参考资料:

http://docs.oracle.com/cd/B19306_01/em.102/b16227/oui8_opatch.htm

http://blog.csdn.net/tianlesoftware/article/details/5809526

ORACLE opatch命令学习实践的更多相关文章

  1. Nagios学习实践系列——配置研究[监控当前服务器]

    其实上篇Nagios学习实践系列——基本安装篇只是安装了Nagios基本组件,虽然能够打开主页,但是如果不配置相关配置文件文件,那么左边菜单很多页面都打不开,相当于只是一个空壳子.接下来,我们来学习研 ...

  2. 别出心裁的Linux命令学习法

    别出心裁的Linux命令学习法 操作系统操作系统为你完成所有"硬件相关.应用无关"的工作,以给你方便.效率.安全.操作系统的功能我总结为两点:管家婆和服务生: 管家婆:通过进程.虚 ...

  3. Appium学习实践(三)测试用例脚本以及测试报告输出

    之前Appium学习实践(二)Python简单脚本以及元素的属性设置中的脚本,会有一个问题,就是在每个测试用例完成之后都会执行tearDown,然后重新setUp,这样导致脚本的执行效率偏低,而且会有 ...

  4. penghui_031413 Bat命令学习

    penghui_031413   Bat命令学习 基础部分:====================================================================== ...

  5. TCP/IP协议学习之实例ping命令学习笔记

    TCP/IP协议学习之实例ping命令学习笔记(一) 一. 目的为了让网络协议学习更有效果,在真实网络上进行ping命令前相关知识的学习,暂时不管DNS,在内网中,进行2台主机间的ping命令的整个详 ...

  6. Oracle教程之学习笔记

    Oracle教程之学习笔记... ----------------------------------- Oracle教程:---学习笔记: ============================= ...

  7. Nagios学习实践系列

    其实上篇Nagios学习实践系列--基本安装篇只是安装了Nagios基本组件,虽然能够打开主页,但是如果不配置相关配置文件文件,那么左边菜单很多页面都打不开,相当于只是一个空壳子.接下来,我们来学习研 ...

  8. Java命令学习系列(二)——Jstack

    Java命令学习系列(二)——Jstack 2015-04-18 分类:Java 阅读(512) 评论(0) jstack是java虚拟机自带的一种堆栈跟踪工具. 功能 jstack用于生成java虚 ...

  9. 安装虚拟机&Linux命令学习

    安装虚拟机&Linux命令学习 基于VirtualBox虚拟机安装Ubuntu 1.下载安装VirtualBox 根据自己电脑(32位操作系统)的实际情况,我在网上找了相应的VirtualBo ...

随机推荐

  1. npm上传自己的项目

    npm安装就不介绍了,自行度娘.本文介绍npm上传 先初始化:npm init 根据提示填完系统介绍信息(package.json): 再登录npmjs: npm login 效果如图: 输入注册的用 ...

  2. Hive Tutorial(上)(Hive 入门指导)

    用户指导 Hive 指导 Hive指导 概念 Hive是什么 Hive不是什么 获得和开始 数据单元 类型系统 内置操作符和方法 语言性能 用法和例子(在<下>里面) 概念 Hive是什么 ...

  3. 对来自于Azure的远程连接文件(.rdp)的另一种更便捷的自定义方法

    在上一篇日志中(很抱歉那张比较黑的截图)介绍了如何获得Azure中的Windows虚拟机的远程连接文件,以及一种基于文本编辑方式进行自定义的方法. 实际上对于在Windows下的用户来说,我们可以使用 ...

  4. struct 大小计算

    结构体是一种复合数据类型,通常编译器会自动的进行其成员变量的对齐,已提高数据存取的效率.在默认情况下,编译器为结构体的成员按照自然对齐(natural alignment)条方式分配存储空间,各个成员 ...

  5. HTML基本元素(二)

    1.图像 <img src="URL" alt="" /> 说明 src 定义图像的url alt 定义图像的替代文本 width 设置图像的宽度 ...

  6. 这些Javascript知识点,面试和平时开发都需要

    No1.语法和类型 1.声明定义 变量类型:var,定义变量:let,定义块域(scope)本地变量:const,定义只读常量.    变量格式:以字母.下划线“_”或者$符号开头,大小写敏感.    ...

  7. 不使用jQuery对Web API接口POST,PUT,DELETE数据

    前些天,Insus.NET有演示Web API接口的操作: <怎样操作WebAPI接口(显示数据)>http://www.cnblogs.com/insus/p/5670401.html ...

  8. CSS3+jQuery实现时钟插件

    查看效果:http://hovertree.com/texiao/hoverclock/demo4.htm 本插件使用方便,可以在博客园的页面中使用,请看本页面右侧:http://www.cnblog ...

  9. ASP.NET 5 已死 - 隆重介绍 ASP.NET Core 1.0 和 .NET Core 1.0

    还没正式登场就死了?不能怪我标题党,是大神Scott在他博客上这么说的,我只是翻译了一下. 在1月20号最新的ASP.NET Community Standup视频中,微软aspnet开发组的大帅哥 ...

  10. csharp: MySQL Stored Procedure using DAL

    # 建表 塗聚文 20160907 drop table attendrecord; create table attendrecord ( seq INT NOT NULL PRIMARY KEY ...