oracle11 打补丁方法
检查当前数据库CPU和PSU补丁信息 方法一: 登录数据库,检查DBA_REGISTRY_HIST视图。 SYS@orcl> select *from dba_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.4 OPatch 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]$ cd 19769489/ [oracle@OCP 19769489]$ /u01/app/oracle/product/11.2.0/db_1/OPatch/opatch apply Oracle Interim Patch Installer version 11.2.0.3.4 Copyright (c) 2012, Oracle Corporation. All rights reserved. Oracle Home : /u01/app/oracle/product/11.2.0/db_1 Central Inventory : /u01/app/oraInventory from : /u01/app/oracle/product/11.2.0/db_1/oraInst.loc OPatch version : 11.2.0.3.4 OUI version : 11.2.0.4.0 Log 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 version 11.2.0.3.4 while the following patch(es) require higher versions: Patch 17478514 requires OPatch version 11.2.0.3.5. Patch 18031668 requires OPatch version 11.2.0.3.5. Patch 18522509 requires OPatch version 11.2.0.3.5. Patch 19121551 requires OPatch version 11.2.0.3.5. Patch 19769489 requires OPatch version 11.2.0.3.5. Please download latest OPatch from My 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 code 73 2、OPatch应用报错,检查日志 [oracle@OCP19769489]$cat u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2015-07-24_20-08-16PM_1.log [Jul 24, 2015 8:08:26 PM] Prerequisite check "CheckMinimumOPatchVersion" failed. The details are: [Jul 24, 2015 8:08:26 PM] OUI-67073:UtilSession failed: Prerequisite check "CheckMinimumOPatchVersion" failed. [Jul 24, 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.6 OPatch succeeded. 通过新版本Opatch安装PSU [oracle@OCP 19769489]$ /u01/app/oracle/product/11.2.0/db_1/OPatch/opatch apply Oracle Interim Patch Installer version 11.2.0.3.6 Copyright (c) 2013, Oracle Corporation. All rights reserved. Oracle Home : /u01/app/oracle/product/11.2.0/db_1 Central Inventory : /u01/app/oraInventory from : /u01/app/oracle/product/11.2.0/db_1/oraInst.loc OPatch version : 11.2.0.3.6 OUI version : 11.2.0.4.0 Log 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.1 UtilSession 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 code 73 通过报错提示“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@OCP 19769489]$ 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@OCP 19769489]$ 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@OCP 19769489]$ kill -9 3221 3174 重新执行安装opatch [oracle@OCP 19769489]$ /u01/app/oracle/product/11.2.0/db_1/OPatch/opatch apply Oracle Interim Patch Installer version 11.2.0.3.6 Copyright (c) 2013, Oracle Corporation. All rights reserved. Oracle Home : /u01/app/oracle/product/11.2.0/db_1 Central Inventory : /u01/app/oraInventory from : /u01/app/oracle/product/11.2.0/db_1/oraInst.loc OPatch version : 11.2.0.3.6 OUI version : 11.2.0.4.0 Log 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 19769489 Do you want to proceed? [y|n] y User Responded with: Y All checks passed. ……………………. Composite patch 19769489 successfully 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@OCP 19769489]$ /u01/app/oracle/product/11.2.0/db_1/OPatch/opatch lsinventory Oracle Interim Patch Installer version 11.2.0.3.6 Copyright (c) 2013, Oracle Corporation. All rights reserved. Oracle Home : /u01/app/oracle/product/11.2.0/db_1 Central Inventory : /u01/app/oraInventory from : /u01/app/oracle/product/11.2.0/db_1/oraInst.loc OPatch version : 11.2.0.3.6 OUI version : 11.2.0.4.0 Log 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 11g 11.2.0.4.0 There are 1 product(s) installed in this Oracle Home. Interim patches (1) : Patch 19769489 : applied on Fri Jul 24 20:36:26 CST 2015 Unique Patch ID: 18236413 Patch description: "Database Patch Set Update : 11.2.0.4.5 (19769489)" Created on 28 Dec 2014, 21:22:44 hrs 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 150 col ACTION_TIME for a30 col ACTION for a8 col NAMESPACE for a8 col VERSION for a10 col BUNDLE_SERIES for a5 col COMMENTS for a20 select * from dba_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.5 SYS@orcl> select action,comments from registry$history; ACTION COMMENTS ------ ------------------------- APPLY Patchset 11.2.0.2.0 APPLY Patchset 11.2.0.2.0 APPLY PSU 11.2.0.4.5 #显示安装成功,补丁成功从11.2.0.2.0版本升级到补丁11.2.0.4.5 查看无效对象 SYS@orcl>select count(*) from dba_objects where status<>'VALID'; #为零表示正常