ORACLE opatch命令学习实践
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
如果帖子看不到图片或格式混乱或内容不全(超过长度),可以查看附件或访问我个人博客http://www.cnblogs.com/kerrycode/p/3666789.html
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]$ ls
etc files README.txt
[oracle@DB-Server 6074620]$ more README.txt
# ---------------------------
# 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://blog.csdn.net/tianlesoftware/article/details/5809526
该贴由hui.chen转至本版2014-11-5 16:24:21