Oracle补丁及opatch工具介绍(三)

2014-11-24 11:56:42 · 作者: · 浏览: 2
'opatch util -help'
OPatch succeeded.
官网上对命令的一些解释:
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.
在$ORACLE_HOME/OPatch/docs目录下,用指南文件(Users_Guide.txt),其中有详细的命令格式和使用示例,可以参考。
Opatch执行操作时,除在屏幕输出结果外,还生成日志文件。日志文件的路径和文件名格式如下:
$ORACLE_HOME/.patch_storage/< patch_id >/< action >-< patch_id >_< mm-dd-yyyy_hh-mi-ss>.log
其中“patch_id”是Oracle技术支持部门为个别补丁分配的编号。
3.3 opatch安装个别补丁示例:
以Patch 5689937 为例。
3.3.1 patch下载
从metalink下载补丁的压缩文件p5689937_10201_LINUX.zip.将此文件解压缩至某一目录中。解压缩后,这一补丁的所有文件都在子目录5689937下,目录名就是个别补丁的补丁号,opatch依据目录名获得信息,所以一定不要重命名子目录。
3.3.2 安装patch
进入patch文件5689937 目录,在patch的目录下面有一个readme的安装文档,里面有安装步骤和一些问题的处理方法。
3.3.2.1 关闭数据库和监听
Shut down all instances and listeners associated with the Oracle home that you are updating.
3.3.2.2. 进入patch目录,运行opatch apply命令
-bash-3.2$ cd p5689937_10201_LINUX/
-bash-3.2$ ls
5689937 patchmd.xml README. html
-bash-3.2$ cd 5689937/
-bash-3.2$ ls
custom etc files README.txt
-bash-3.2$ pwd
/mnt/p5689937_10201_LINUX/5689937
-bash-3.2$ export PATH=$PATH:/usr/ccs/bin
-bash-3.2$ $ORACLE_HOME/OPatch/opatch apply
3.3.2.3 启动实例,运行相关脚本
-bash-3.2$ cd $ORACLE_HOME/cpu/CPUJan2007/ -- 要进入这个目录才能找到脚本
-bash-3.2$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Aug 9 04:48:19 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 281018368 bytes
Fixed Size 1218968 bytes
Variable Size 83887720 bytes
Database Buffers 192937984 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL> @catcpu.sql
如果catcpu.sql 脚本报任何无效对象,执行如下脚本:
SQL> @ /rdbms/admin/utlrp.sql
可以用如下SQL 检查无效对象:
SQL> SELECT OBJECT_NAME FROM DBA_OBJECTS WHERE STATUS= 'INVALID';
3.3.3 用inventory 命令查看已经安装的patch
-bash-3.2$ $ORACLE_HOME/OPatch/opatch lsinventory
Invoking OPatch 10.2.0.1.0
Oracle interim Patch Installer version 10.2.0.1.0
Copyright (c) 2005, Oracle Corporation. All rights reserved..
Oracle Home : /u01/oracle/oracle/product/10.2.0/db_1
Central Inventory : /u01/oracle/oraInventory
from : /u01/oracle/oracle/product/10.2.0/db_1/oraInst.loc
OPatch version : 10.2.0.1.0
OUI version : 10.2.0.1.0
OUI location : /u01/oracle/oracle/product/10.2.0/db_1//oui
Log file location : /u01/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opa