检查当前数据库CPU和PSU补丁信息
方法一:
登录数据库,检查DBA_REGISTRY_HIST视图。
SYS@orcl> select *fromdba_registry_history;
ACTION_TIME ACTION NAMESPACE VERSION ID BUNDLE_SERIES COMMENTS--------------------- ------------------------------ ---------- ---------- ---------- ---------------
2013-08-24 12:03:45.119862 APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
2015-07-24 17:37:04.622489 APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0方法二:
通过opatch lsinventory方式。
$/u01/app/oracle/product/11.2.0/db_1/OPatch/opatch lsinventory
查看opatch版本信息
[oracle@OCP~]$ /u01/app/oracle/product/11.2.0/db_1/OPatch/opatch version
OPatch Version:11.2.0.3.4OPatch succeeded.
升级前关闭数据库和监听。
上传PSU11.2.0.4.5补丁包并解压
本例是将补丁包复制到/u01/app/oracle/patchPakge下,用unzip进行解压
[oracle@OCP patchPakge]$ unzip p19769489_112040_Linux-x86-64.zip
测试兼容性, 如果之前没有打过,这步也可以忽略。
[oracle@11g opatch]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail-phBaseDir 下载解压后的补丁包路径 -oh $ORACLE_HOME
进入解压目录进行安装,安装补丁
[oracle@OCP patchPakge]$ cd19769489/[oracle@OCP19769489]$ /u01/app/oracle/product/11.2.0/db_1/OPatch/opatch apply
Oracle Interim Patch Installer version11.2.0.3.4Copyright (c)2012, Oracle Corporation. All rights reserved.
Oracle Home :/u01/app/oracle/product/11.2.0/db_1
Central Inventory :/u01/app/oraInventoryfrom : /u01/app/oracle/product/11.2.0/db_1/oraInst.loc
OPatch version :11.2.0.3.4OUI version :11.2.0.4.0Log file location :/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2015-07-24_20-08-16PM_1.log
Verifying environment and performing prerequisite checks...
Prerequisite check"CheckMinimumOPatchVersion"failed.
The details are:
The OPatch being used has version11.2.0.3.4 whilethe following patch(es) require higher versions:
Patch17478514 requires OPatch version 11.2.0.3.5.
Patch18031668 requires OPatch version 11.2.0.3.5.
Patch18522509 requires OPatch version 11.2.0.3.5.
Patch19121551 requires OPatch version 11.2.0.3.5.
Patch19769489 requires OPatch version 11.2.0.3.5.
Please download latest OPatchfromMy Oracle Support.
UtilSession failed: Prerequisite check"CheckMinimumOPatchVersion"failed.
Log file location:/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2015-07-24_20-08-16PM_1.log
OPatch failed with error code73
2、OPatch应用报错,检查日志
[oracle@OCP19769489]$cat u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2015-07-24_20-08-16PM_1.log
[Jul24, 2015 8:08:26 PM] Prerequisite check "CheckMinimumOPatchVersion"failed.
The details are:
[Jul24, 2015 8:08:26 PM] OUI-67073:UtilSession failed: Prerequisite check "CheckMinimumOPatchVersion"failed.
[Jul24, 2015 8:08:26 PM] Stack Description: java.lang.RuntimeException: Prerequisite check "CheckMinimumOPatchVersion"failed.
显示opatch版本有问题,先更新opatch版本。
下载p6880880,并解压缩
[oracle@OCP patchPakge]$ unzip p6880880_112000_Linux-x86-64.zip
[oracle@OCP patchPakge]$ rm-rf /u01/app/oracle/product/11.2.0/db_1/OPatch
[oracle@OCP patchPakge]$ cp-r OPatch/ /u01/app/oracle/product/11.2.0/db_1/[oracle@OCP patchPakge]$/u01/app/oracle/product/11.2.0/db_1/OPatch/opatch version
OPatch Version:11.2.0.3.6OPatch succeeded.
通过新版本Opatch安装PSU
[oracle@OCP19769489]$ /u01/app/oracle/product/11.2.0/db_1/OPatch/opatch apply
Oracle Interim Patch Installer version11.2.0.3.6Copyright (c)2013, Oracle Corporation. All rights reserved.
Oracle Home :/u01/app/oracle/product/11.2.0/db_1
Central Inventory :/u01/app/oraInventoryfrom : /u01/app/oracle/product/11.2.0/db_1/oraInst.loc
OPatch version :11.2.0.3.6OUI version :11.2.0.4.0Log file location :/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2015-07-24_20-23-44PM_1.log
Verifying environment and performing prerequisite checks...
Prerequisite check"CheckActiveFilesAndExecutables"failed.
The details are:
Following executables are active :/u01/app/oracle/product/11.2.0/db_1/bin/oracle/u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1UtilSession failed: Prerequisite check"CheckActiveFilesAndExecutables"failed.
Log file location:/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2015-07-24_20-23-44PM_1.log
OPatch failed with error code73通过报错提示“Check Active Files And Executables”可能是有些执行程序用到了/u01/app/oracle/product/11.2.0/db_1/lib/目录下的库文件libclntsh.so.11.1和/u01/app/oracle/product/11.2.0/db_1/bin/下的oracle。
用fuser查看是谁在用这些文件并kill这些进程。
[oracle@OCP19769489]$ fuser /u01/app/oracle/product/11.2.0/db_1/bin/oracle/u01/app/oracle/product/11.2.0/db_1/bin/oracle: 3221e
[oracle@OCP19769489]$ fuser /u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1
/u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1: 3174m
[oracle@OCP19769489]$ kill -9 3221 3174重新执行安装opatch
[oracle@OCP19769489]$ /u01/app/oracle/product/11.2.0/db_1/OPatch/opatch apply
Oracle Interim Patch Installer version11.2.0.3.6Copyright (c)2013, Oracle Corporation. All rights reserved.
Oracle Home :/u01/app/oracle/product/11.2.0/db_1
Central Inventory :/u01/app/oraInventoryfrom : /u01/app/oracle/product/11.2.0/db_1/oraInst.loc
OPatch version :11.2.0.3.6OUI version :11.2.0.4.0Log file location :/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2015-07-24_20-30-44PM_1.log
Verifying environment and performing prerequisite checks...
OPatch continues with these patches:17478514 18031668 18522509 19121551 19769489Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.
…………………….
Composite patch19769489successfully applied.
OPatch Session completed with warnings.
Log file location:/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2015-07-24_20-30-44PM_1.log
OPatch completed with warnings.
检查Opatch是否已经完成
[oracle@OCP19769489]$ /u01/app/oracle/product/11.2.0/db_1/OPatch/opatch lsinventory
Oracle Interim Patch Installer version11.2.0.3.6Copyright (c)2013, Oracle Corporation. All rights reserved.
Oracle Home :/u01/app/oracle/product/11.2.0/db_1
Central Inventory :/u01/app/oraInventoryfrom : /u01/app/oracle/product/11.2.0/db_1/oraInst.loc
OPatch version :11.2.0.3.6OUI version :11.2.0.4.0Log file location :/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2015-07-24_20-40-00PM_1.log
Lsinventory Output file location :/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2015-07-24_20-40-00PM.txt--------------------------------------------------------------------------------Installed Top-level Products (1):
Oracle Database 11g11.2.0.4.0There are1 product(s) installed in thisOracle Home.
Interim patches (1) :
Patch19769489 : applied on Fri Jul 24 20:36:26 CST 2015Unique Patch ID:18236413Patch description:"Database Patch Set Update : 11.2.0.4.5 (19769489)"Created on28 Dec 2014, 21:22:44hrs PST8PDT
Sub-patch 19121551; "Database Patch Set Update : 11.2.0.4.4 (19121551)"Sub-patch 18522509; "Database Patch Set Update : 11.2.0.4.3 (18522509)"Sub-patch 18031668; "Database Patch Set Update : 11.2.0.4.2 (18031668)"Sub-patch 17478514; "Database Patch Set Update : 11.2.0.4.1 (17478514)"......--------------------------------------------------------------------------------OPatch succeeded.
结果显示安装成功。
更新dba_registry_history视图为最新PSU信息
SQL>startup
SQL> !lsnrctl start
SQL>alter system register;
升级数据库数据字典
SQL> @?/rdbms/admin/catbundle.sql psu apply
编译无效对象的脚本
SQL>@?/rdbms/admin/utlrp.sql
查看更新后的视图信息set line 150col ACTION_TIMEfora30
col ACTIONfora8
col NAMESPACEfora8
col VERSIONfora10
col BUNDLE_SERIESfora5
col COMMENTSfora20select * fromdba_registry_history;
ACTION_TIME ACTION NAMESPACE VERSION ID BUNDLE_SERIES COMMENTS------------------------------ ------ ---------- ---------- ---------- --------------- -------------------------
2013-08-24 12:03:45.119862 APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
2015-07-24 17:37:04.622489 APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
2015-07-24 20:52:13.592073 APPLY SERVER 11.2.0.4 5 PSU PSU 11.2.0.4.5SYS@orcl> select action,comments fromregistry$history;
ACTION COMMENTS------ -------------------------APPLY Patchset11.2.0.2.0APPLY Patchset11.2.0.2.0APPLY PSU11.2.0.4.5 #显示安装成功,补丁成功从11.2.0.2.0版本升级到补丁11.2.0.4.5查看无效对象
SYS@orcl>select count(*) from dba_objects where status<>'VALID'; #为零表示正常