欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

查看及管理Oracle patch

程序员文章站 2022-06-05 17:13:29
...

Oracle patch也即是Oracle补

Oracle patch也即是Oracle补丁。Oracle补丁又包含好几个种类,小的补丁简直是难以数计,难免让人眼花缭乱。尽管如此,Oracle patch还是有序可循的。而且Oracle提供的opatch工具非常方便的用于安装oracle patch,以及查看当前系统已经安装的patch。本文列出了patch的几种类型,以及主要描述通过opatch工具查看当前数据库的patch应用的情况。对于如何apply patch可参考Oracle官方文档。

1、Oracle patch类型
One-off patches (e.g. a bug fix)
One-off patches也称之为一次性补丁,通常针对特定的版本数据库或运行平台。此类补丁通常较小,使用的最为频繁
One-off patch只需要用Opatch工具apply即可,不需要升级/修正数据字典
如在数据库使用过程中出现某些异常后如较常见的ORA-00600、ORA-07445错误等可以通过一次性补丁来搞定

Critical Patch Update (CPU)
简称CPU,一般来说CPU包含了Oracle产品安全漏洞的修复补丁集(set of security bug fix),通常一年发布四期
该类patch的安装和安装one-off patch一样,同样使用”opatch apply”命令来完成
安装完成后应针对既有的数据库(已经创建在使用的数据库),应在数据库级别运行数据字典升级脚本

Bundled patches (For Windows and Exadata only)
用于解决在Windows平台无法利用替换共享库文件后relink的方式来更新Oracle binary,所以Oracle特别针对Windows发布区别于Unix上Normal/Molecular CPU的CPU Bundle patch
通常情况下,Bundle Patch会别较大,Windows bundle patches通常每一个季度都会发布

PSR(Patch Set Release)/Patch Set Update(PSU)
PSR就是大家常见的大补丁合集,通常1GB左右,也就是oracle版布号的第四位即为PSR号。也就是说oracle版布号的第四位会被修改
每一个PSR是都整合了之前的一些bug,并且经过了严格的测试,通常更新PSR风险相对较小
如10.2,10.2.0.1.0是基础发行版,至今已有五个PSR发布,最新10.2的PSR为10.2.0.5.0
PSU就是在每个PSR发布之间的补丁,由于新旧PSR之间周期较长,而数据库在运行期间难以保证不会出现新的bug,因此有了PSU
PSU是对于PSR的一个重要补充,每个PSU修改5位版本号的第5位。如,11.1版本升级为11.1.0.7.1;10.2版本为10.2.0.4.2
PSU与CPU一样,定期发布,计划一年发布四次,发布日期与CPU发布日期相同。由于PSU包括同期发布的CPU,只要安装PSU即可
PSU同样使用Opatch工具安装/删除,命令仍是apply和rollback。一个PSU可视作一个个别补丁,安装和删除操作同样简便

2、opatch工具

[python] view plaincopyprint?查看及管理Oracle patch查看及管理Oracle patch

  1. Oracle 为我们提供了用于patch安装、回退、管理与追踪的工具opatch,该工具为命令行工具,简单易用,可以根据opatch的帮助命令来获取帮助信息
  2. #获得opatch的帮助信息
  3. [oracle@linux1 OPatch]$ ./opatch -help
  4. Invoking OPatch 11.1.0.6.6 #opatch的版本
  5. Oracle Interim Patch Installer version 11.1.0.6.6
  6. Copyright (c) 2009, Oracle Corporation. All rights reserved.
  7. Usage: opatch [ -help ] [ -r[eport] ] [ command ]
  8. command := apply #安装patch
  9. lsinventory #查看所有已安装的patch
  10. napply #用于Apply a set of patches at a time
  11. nrollback #用于Rollback a set of patches at a time
  12. rollback #Rollback an existing one-off patch indicated by the reference-id
  13. query
  14. version
  15. prereq #用于检查安装patch之前的先决条件
  16. util
  17. := -help Displays the help message for the command.
  18. -report Print the actions without executing.
  19. example: #可以通过下面的方式来查看每一个具体命令的用法
  20. 'opatch -help'
  21. 'opatch apply -help'
  22. 'opatch lsinventory -help'
  23. 'opatch napply -help'
  24. 'opatch nrollback -help'
  25. 'opatch rollback -help'
  26. 'opatch prereq -help'
  27. 'opatch util -help'
  28. OPatch succeeded.
  29. #下面查看oracle 10g下的补丁信息,对于如何安装补丁,本文不作演示
  30. oracle@M10DB01p:/users/oracle/OraHome10g/OPatch> ./opatch lsinventory
  31. Invoking OPatch 10.2.0.3.0
  32. .........
  33. Oracle Home : /users/oracle/OraHome10g
  34. Central Inventory : /users/oracle/oraInventory
  35. from : /etc/oraInst.loc
  36. OPatch version : 10.2.0.3.0
  37. OUI version : 10.2.0.3.0
  38. OUI location : /users/oracle/OraHome10g/oui
  39. Log file location : /users/oracle/OraHome10g/cfgtoollogs/opatch/opatch2013-12-19_09-54-27AM.log
  40. Lsinventory Output file location : /users/oracle/OraHome10g/cfgtoollogs/opatch/lsinv/lsinventory2013-12-19_09-54-27AM.txt
  41. --------------------------------------------------------------------------------
  42. Installed Top-level Products (2):
  43. Oracle Database 10g 10.2.0.1.0#基础版本号
  44. Oracle Database 10g Release 2 Patch Set 2 10.2.0.3.0#PSR号为3
  45. There are 2 products installed in this Oracle Home.
  46. Interim patches (2) : #列出了2个临时补丁patch号及bug号
  47. Patch 5556081 : applied on Wed Feb 1511:16:15 HKT 2012
  48. Created on 9 Nov 2006, 22:20:50 hrs PST8PDT
  49. Bugs fixed:
  50. 5556081
  51. Patch 5557962 : applied on Wed Feb 1511:16:08 HKT 2012
  52. Created on 9 Nov 2006, 23:23:06 hrs PST8PDT
  53. Bugs fixed:
  54. 4269423, 5557962, 5528974
  55. --------------------------------------------------------------------------------
  56. OPatch succeeded.
  57. #也可以通过查询dba_server_registry查看当前数据补丁的使用情况
  58. SQL> select comp_name,version from dba_server_registry;
  59. COMP_NAME VERSION
  60. -------------------------------------------------- ------------------------------
  61. Oracle XML Database 10.2.0.3.0
  62. Oracle Label Security 10.2.0.3.0
  63. Oracle Expression Filter 10.2.0.3.0
  64. Oracle Rules Manager 10.2.0.3.0
  65. Oracle Workspace Manager 10.2.0.1.0
  66. Oracle Database Catalog Views 10.2.0.3.0
  67. Oracle Database Packages and Types 10.2.0.3.0
  68. JServer JAVA Virtual Machine 10.2.0.3.0
  69. Oracle XDK 10.2.0.3.0
  70. Oracle Database Java Packages 10.2.0.3.0
  71. 10 rows selected.
  72. #下面是Oracle 11g下使用lsinventory -detail时patch的应用情况
  73. [oracle@linux1 OPatch]$ ./opatch lsinventory -detail
  74. Invoking OPatch 11.1.0.6.6
  75. Oracle Interim Patch Installer version 11.1.0.6.6
  76. Copyright (c) 2009, Oracle Corporation. All rights reserved.
  77. ...............(省略)
  78. --------------------------------------------------------------------------------
  79. Installed Top-level Products (1):
  80. Oracle Database 11g 11.2.0.1.0
  81. There are 1 products installed in this Oracle Home.
  82. Installed Products (134):
  83. Agent Required Support Files 10.2.0.4.2
  84. Assistant Common Files 11.2.0.1.0
  85. Bali Share 1.1.18.0.0
  86. Buildtools Common Files 11.2.0.1.0
  87. Character Set Migration Utility 11.2.0.1.0
  88. Cluster Verification Utility Common Files 11.2.0.1.0
  89. Database Configuration and Upgrade Assistants 11.2.0.1.0
  90. ...............(省略)
  91. SSL Required Support Files for InstantClient 11.2.0.1.0
  92. Sun JDK 1.5.0.17.0
  93. XDK Required Support Files 11.2.0.1.0
  94. XML Parser for Java 11.2.0.1.0
  95. XML Parser for Oracle JVM 11.2.0.1.0
  96. There are 134 products installed in this Oracle Home.
  97. Interim patches (1) :
  98. Patch 8670579 : applied on Thu Aug 1517:53:20 CST 2013
  99. Unique Patch ID: 12243614
  100. Created on 25 Feb 2010, 09:55:12 hrs US/Eastern
  101. Bugs fixed:
  102. 8670579
  103. Files Touched: #这里列出了相应的文件
  104. /ahseteco.o --> ORACLE_HOME/lib/libnnz11.a
  105. /am11rkg.o --> ORACLE_HOME/lib/libnnz11.a
  106. /amsha.o --> ORACLE_HOME/lib/libnnz11.a
  107. /cpui32.o --> ORACLE_HOME/lib/libnnz11.a
  108. /sha.o --> ORACLE_HOME/lib/libnnz11.a
  109. /x931rand.o --> ORACLE_HOME/lib/libnnz11.a
  110. /am11dkg.o --> ORACLE_HOME/lib/libnnz11.a
  111. /am931rnd.o --> ORACLE_HOME/lib/libnnz11.a
  112. /amsharnd.o --> ORACLE_HOME/lib/libnnz11.a
  113. /ghash.o --> ORACLE_HOME/lib/libnnz11.a
  114. /shacomm.o --> ORACLE_HOME/lib/libnnz11.a
  115. libnnz11.so --> ORACLE_HOME/lib/libnnz11.so
  116. Patch Location in Inventory:
  117. /u01/app/oracle/db_1/inventory/oneoffs/8670579
  118. Patch Location in Storage area:
  119. /u01/app/oracle/db_1/.patch_storage/8670579_Feb_25_2010_09_55_12
  120. Rac system comprising of multiple nodes #列出了当前环境的节点
  121. Local node = linux1
  122. Remote node = linux2
  123. --------------------------------------------------------------------------------
  124. OPatch succeeded.
  125. #下面是Oracle 11g下使用使用lsinventory -bugs_fixed来查看patch的情形
  126. [oracle@linux1 OPatch]$ ./opatch lsinventory -bugs_fixed
  127. Invoking OPatch 11.1.0.6.6
  128. ...............(省略)
  129. ------------------------------------------------------------------------------------------------------
  130. Installed Top-level Products (1):
  131. Oracle Database 11g 11.2.0.1.0
  132. There are 1 products installed in this Oracle Home.
  133. List of Bugs fixed by Installed Patches:
  134. Bug Fixed by Installed at Description
  135. Patch
  136. --- -------- ------------ ----------- #下面给出了和bug有关的具体描述
  137. 8670579 8670579 Thu Aug 1517:53:20 CST 2013 DBBETA :NETCA/DBCA FAILED WITH HOTSPOT VIRTUAL MACHINE
  138. Rac system comprising of multiple nodes
  139. Local node = linux1
  140. Remote node = linux2
  141. ------------------------------------------------------------------------------------------------------
  142. OPatch succeeded.
Oracle 为我们提供了用于patch安装、回退、管理与追踪的工具opatch,该工具为命令行工具,简单易用,可以根据opatch的帮助命令来获取帮助信息
#获得opatch的帮助信息
[oracle@linux1 OPatch]$ ./opatch -help
Invoking OPatch 11.1.0.6.6   #opatch的版本

Oracle Interim Patch Installer version 11.1.0.6.6
Copyright (c) 2009, Oracle Corporation.  All rights reserved.

 Usage: opatch [ -help ] [ -r[eport] ] [ command ]

            command := apply          #安装patch
                       lsinventory    #查看所有已安装的patch
                       napply         #用于Apply a set of patches at a time
                       nrollback      #用于Rollback a set of patches at a time
                       rollback       #Rollback an existing one-off patch indicated by the reference-id 
                       query          
                       version 
                       prereq         #用于检查安装patch之前的先决条件
                       util

  := -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下的补丁信息,对于如何安装补丁,本文不作演示
oracle@M10DB01p:/users/oracle/OraHome10g/OPatch> ./opatch lsinventory
Invoking OPatch 10.2.0.3.0
    .........
Oracle Home       : /users/oracle/OraHome10g
Central Inventory : /users/oracle/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 10.2.0.3.0
OUI version       : 10.2.0.3.0
OUI location      : /users/oracle/OraHome10g/oui
Log file location : /users/oracle/OraHome10g/cfgtoollogs/opatch/opatch2013-12-19_09-54-27AM.log

Lsinventory Output file location : /users/oracle/OraHome10g/cfgtoollogs/opatch/lsinv/lsinventory2013-12-19_09-54-27AM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (2):

Oracle Database 10g                                                  10.2.0.1.0 #基础版本号
Oracle Database 10g Release 2 Patch Set 2                            10.2.0.3.0 #PSR号为3
There are 2 products installed in this Oracle Home.


Interim patches (2) :                                                #列出了2个临时补丁patch号及bug号

Patch  5556081      : applied on Wed Feb 15 11:16:15 HKT 2012
   Created on 9 Nov 2006, 22:20:50 hrs PST8PDT
   Bugs fixed:
     5556081

Patch  5557962      : applied on Wed Feb 15 11:16:08 HKT 2012
   Created on 9 Nov 2006, 23:23:06 hrs PST8PDT
   Bugs fixed:
     4269423, 5557962, 5528974
--------------------------------------------------------------------------------
OPatch succeeded.

#也可以通过查询dba_server_registry查看当前数据补丁的使用情况
SQL> select comp_name,version from dba_server_registry;

COMP_NAME                                          VERSION
-------------------------------------------------- ------------------------------
Oracle XML Database                                10.2.0.3.0
Oracle Label Security                              10.2.0.3.0
Oracle Expression Filter                           10.2.0.3.0
Oracle Rules Manager                               10.2.0.3.0
Oracle Workspace Manager                           10.2.0.1.0
Oracle Database Catalog Views                      10.2.0.3.0
Oracle Database Packages and Types                 10.2.0.3.0
JServer JAVA Virtual Machine                       10.2.0.3.0
Oracle XDK                                         10.2.0.3.0
Oracle Database Java Packages                      10.2.0.3.0

10 rows selected.

#下面是Oracle 11g下使用lsinventory -detail时patch的应用情况
[oracle@linux1 OPatch]$ ./opatch lsinventory -detail
Invoking OPatch 11.1.0.6.6

Oracle Interim Patch Installer version 11.1.0.6.6
Copyright (c) 2009, Oracle Corporation.  All rights reserved.
              ...............(省略) 
--------------------------------------------------------------------------------
Installed Top-level Products (1): 

Oracle Database 11g                                                  11.2.0.1.0
There are 1 products installed in this Oracle Home.

Installed Products (134): 

Agent Required Support Files                                         10.2.0.4.2
Assistant Common Files                                               11.2.0.1.0
Bali Share                                                           1.1.18.0.0
Buildtools Common Files                                              11.2.0.1.0
Character Set Migration Utility                                      11.2.0.1.0
Cluster Verification Utility Common Files                            11.2.0.1.0
Database Configuration and Upgrade Assistants                        11.2.0.1.0
               ...............(省略)
SSL Required Support Files for InstantClient                         11.2.0.1.0
Sun JDK                                                              1.5.0.17.0
XDK Required Support Files                                           11.2.0.1.0
XML Parser for Java                                                  11.2.0.1.0
XML Parser for Oracle JVM                                            11.2.0.1.0
There are 134 products installed in this Oracle Home.

Interim patches (1) :

Patch  8670579      : applied on Thu Aug 15 17:53:20 CST 2013
Unique Patch ID:  12243614
   Created on 25 Feb 2010, 09:55:12 hrs US/Eastern
   Bugs fixed:
     8670579
   Files Touched:       #这里列出了相应的文件
     /ahseteco.o --> ORACLE_HOME/lib/libnnz11.a
     /am11rkg.o --> ORACLE_HOME/lib/libnnz11.a
     /amsha.o --> ORACLE_HOME/lib/libnnz11.a
     /cpui32.o --> ORACLE_HOME/lib/libnnz11.a
     /sha.o --> ORACLE_HOME/lib/libnnz11.a
     /x931rand.o --> ORACLE_HOME/lib/libnnz11.a
     /am11dkg.o --> ORACLE_HOME/lib/libnnz11.a
     /am931rnd.o --> ORACLE_HOME/lib/libnnz11.a
     /amsharnd.o --> ORACLE_HOME/lib/libnnz11.a
     /ghash.o --> ORACLE_HOME/lib/libnnz11.a
     /shacomm.o --> ORACLE_HOME/lib/libnnz11.a
     libnnz11.so --> ORACLE_HOME/lib/libnnz11.so
   Patch Location in Inventory:
     /u01/app/oracle/db_1/inventory/oneoffs/8670579
   Patch Location in Storage area:
     /u01/app/oracle/db_1/.patch_storage/8670579_Feb_25_2010_09_55_12

Rac system comprising of multiple nodes   #列出了当前环境的节点
  Local node = linux1
  Remote node = linux2
--------------------------------------------------------------------------------
OPatch succeeded.

#下面是Oracle 11g下使用使用lsinventory -bugs_fixed来查看patch的情形
[oracle@linux1 OPatch]$  ./opatch lsinventory -bugs_fixed
Invoking OPatch 11.1.0.6.6
             ...............(省略)
------------------------------------------------------------------------------------------------------
Installed Top-level Products (1): 

Oracle Database 11g                                                  11.2.0.1.0
There are 1 products installed in this Oracle Home.

List of Bugs fixed by Installed Patches:

Bug        Fixed by  Installed at                   Description
            Patch                                              
---        --------  ------------                   -----------  #下面给出了和bug有关的具体描述

8670579    8670579   Thu Aug 15 17:53:20 CST 2013   DBBETA :NETCA/DBCA FAILED WITH HOTSPOT VIRTUAL MACHINE

Rac system comprising of multiple nodes
  Local node = linux1
  Remote node = linux2
------------------------------------------------------------------------------------------------------
OPatch succeeded.

查看及管理Oracle patch

更多参考

有关Oracle RAC请参考
使用crs_setperm修改RAC资源的所有者及权限
使用crs_profile管理RAC资源配置文件
RAC 数据库的启动与关闭
再说 Oracle RAC services
Services in Oracle Database 10g
Migrate datbase from single instance to Oracle RAC
Oracle RAC 连接到指定实例
Oracle RAC 负载均衡测试(结合服务器端与客户端)
Oracle RAC 服务器端连接负载均衡(Load Balance)
Oracle RAC 客户端连接负载均衡(Load Balance)
ORACLE RAC 下非缺省端口监听配置(listener.ora tnsnames.ora)
ORACLE RAC 监听配置 (listener.ora tnsnames.ora)
配置 RAC 负载均衡与故障转移
CRS-1006 , CRS-0215 故障一例
基于Linux (RHEL 5.5) 安装Oracle 10g RAC
使用 runcluvfy 校验Oracle RAC安装环境

有关Oracle 网络配置相关基础以及概念性的问题请参考:
配置非默认端口的动态服务注册
配置sqlnet.ora限制IP访问Oracle
Oracle 监听器日志配置与管理
设置 Oracle 监听器密码(LISTENER)
配置ORACLE 客户端连接到数据库

有关基于用户管理的备份和备份恢复的概念请参考
Oracle 冷备份
Oracle 热备份
Oracle 备份恢复概念
Oracle 实例恢复
Oracle 基于用户管理恢复的处理
SYSTEM 表空间管理及备份恢复
SYSAUX表空间管理及恢复
Oracle 基于备份控制文件的恢复(unsing backup controlfile)

有关RMAN的备份恢复与管理请参考
RMAN 概述及其体系结构
RMAN 配置、监控与管理
RMAN 备份详解
RMAN 还原与恢复
RMAN catalog 的创建和使用
基于catalog 创建RMAN存储脚本
基于catalog 的RMAN 备份与恢复
RMAN 备份路径困惑
使用RMAN实现异机备份恢复(WIN平台)
使用RMAN迁移文件系统数据库到ASM
linux 下RMAN备份shell脚本
使用RMAN迁移数据库到异机

有关ORACLE体系结构请参考
Oracle 表空间与数据文件
Oracle 密码文件
Oracle 参数文件
Oracle 联机重做日志文件(ONLINE LOG FILE)
Oracle 控制文件(CONTROLFILE)
Oracle 归档日志
Oracle 回滚(ROLLBACK)和撤销(UNDO)
Oracle 数据库实例启动关闭过程
Oracle 10g SGA 的自动化管理
Oracle 实例和Oracle数据库(Oracle体系结构)