ORACLE opatch命令学习实践

简介:

  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.

clip_image001

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.
 

clip_image002

相关文章
|
10月前
|
Oracle 关系型数据库 分布式数据库
PolarDB常见问题之PolarDB(Oracle兼容版) 执行命令报错如何解决
PolarDB是阿里云推出的下一代关系型数据库,具有高性能、高可用性和弹性伸缩能力,适用于大规模数据处理场景。本汇总囊括了PolarDB使用中用户可能遭遇的一系列常见问题及解答,旨在为数据库管理员和开发者提供全面的问题指导,确保数据库平稳运行和优化使用体验。
|
5月前
|
Oracle 关系型数据库 网络安全
Oracle 19c 安装教程学习
Oracle 19c 安装教程学习
217 2
|
7月前
|
运维 Oracle 前端开发
Oracle 11g RAC集群日常运维命令总结
Oracle 11g RAC集群日常运维命令总结
148 2
|
7月前
|
SQL 运维 Oracle
入门级Oracle 11g日常运维命令总结
入门级Oracle 11g日常运维命令总结
246 1
|
9月前
|
SQL Oracle 关系型数据库
探索 Linux 命令 `db_archive`:Oracle 数据库归档日志的工具
探索 Linux 中的 `db_archive`,实际与 Oracle 数据库归档日志管理相关。在 Oracle 中,归档日志用于恢复,当在线重做日志满时自动归档。管理员可使用 SQL*Plus 查看归档模式,通过 `RMAN` 进行备份和恢复操作。管理归档日志需谨慎,避免数据丢失。了解归档管理对 Oracle 管理员至关重要,确保故障时能快速恢复数据库。
|
10月前
|
SQL Oracle 关系型数据库
Oracle SQL*Plus的HELP命令:你的数据库“百事通”
【4月更文挑战第19天】`Oracle SQL*Plus` 的 `HELP` 命令是数据库查询的强大工具,犹如“百事通”。在遇到困惑时,`HELP` 可提供详细命令解释和用法示例,解答基础到高级的 SQL 和 PL/SQL 疑问。它还是“活字典”,揭示命令关联与区别,如 `SET` 和 `ALTER SESSION`。此外,`HELP` 解释数据库概念,如“事务”,并支持模糊查询。无论新手还是专家,`HELP` 都是数据库探索的得力助手。
|
10月前
|
SQL Oracle 关系型数据库
Oracle SQL*Plus的SET命令:你的数据库会话“调色板”
【4月更文挑战第19天】Oracle SQL*Plus的SET命令是数据库会话的“调色板”,用于设置输出格式、反馈信息和各种偏好。它能调整PAGESIZE和LINESIZE以优化显示,控制ECHO和FEEDBACK开关以定制反馈,以及统计命令执行时间(TIMING)和调试SQL(VERIFY)。更高级的选项如HEADING和COLSEP可改善输出的可读性。通过灵活运用SET命令,能提升工作效率和体验,是数据库管理员和开发者的必备工具。
|
10月前
|
SQL Oracle 关系型数据库
Oracle SQL*Plus的COLUMN命令:数据展示的“化妆师”
【4月更文挑战第19天】Oracle SQL*Plus的COLUMN命令是数据展示的利器,能美化和格式化输出。它可定制列标题、调整显示格式(如数字的小数位数和日期格式),添加前缀和后缀(如货币符号),以及控制列宽和是否折行,使得数据呈现更直观、专业。利用COLUMN命令,能将原始数据转化为易于理解和视觉吸引力强的展示形式。
|
10月前
|
Oracle 关系型数据库 数据库
Oracle 11gR2学习之三(创建用户及表空间、修改字符集和Oracle开机启动)
Oracle 11gR2学习之三(创建用户及表空间、修改字符集和Oracle开机启动)
|
10月前
|
存储 Oracle 网络协议
Oracle 11gR2学习之二(创建数据库及OEM管理篇)
Oracle 11gR2学习之二(创建数据库及OEM管理篇)

推荐镜像

更多