oracle针对系统bug会定期的发布补丁,就是通常大家说 oracle patch 了 。安装补丁的工具就是oracle提供的Opatch,它可以很方便的安装各种oracle patch。
另外,oracle patch 也是分类,详细种类和opatch工具的使用可以参考这篇博客 http://blog.csdn.net/leshami/article/details/18600525
一、介绍一个安装环境
项目类型
|
RAC
|
|
数据库版本
|
11.2.0.4
|
|
数据库存储
|
ASM
|
|
操作系统
|
RHEL
|
二、需要在安装前仔细阅读README说明,了解补丁应用的范围和具体实施方法。在这里使用了p18139609_112040_Linux-x86-64.zip PSU 做安装测试工作。
2.1 升级OPatch工具,安装上述补丁要求使用OPatch的版本是11.2.0.3.6或是更高,我们下载p6880880_112000_Linux-x86-64.zip更新OPacth,对于数据库RAC环境需要对同时对database home和 GI home升级OPacth组件。
-
[oracle@mhxy01 ~]$unzip p6880880_112000_Linux-x86-64.zip #生成新的OPatch文件夹
[oracle@mhxy01 ~]$mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch_bak
[oracle@mhxy01 ~]$cp -rf OPatch $ORACLE_HOME/
[oracle@mhxy01 OPatch]$ ./opatch version
OPatch Version: 11.2.0.3.6
OPatch succeeded.
#以上操作分别对oracle和grid用户更新验证
2.2 使用grid用户生成OCM configuration响应文件 ocm.rsp,该文件可以避免在patching过程中重复的输入信息,生成方法比较简单。
-
[grid@mhxy01 bin]$ $ORACLE_HOME/OPatch/ocm/bin/emocmrsp
-
OCM Installation Response Generator 10.3.4.0.0 - Production
-
Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
-
-
Provide your email address to be informed of security issues, install and
-
initiate Oracle Configuration Manager. Easier for you if you use your My
-
Oracle Support Email address/User Name.
-
Visit http://www.oracle.com/support/policies.html for details.
-
Email address/User Name:
-
-
You have not provided an email address for notification of security issues.
-
Do you wish to remain uninformed of security issues ([Y]es, [N]o) [N]: Y
-
The OCM configuration response file (ocm.rsp) was successfully created.
-
[grid@mhxy01 bin]$ ll
-
total 16
-
-rwxr----- 1 grid oinstall 9063 Nov 27 2009 emocmrsp
-
-rw-r--r-- 1 grid oinstall 621 Aug 3 10:28 ocm.rsp
-
[grid@mhxy01 bin]$ exit
2.3 在patching前,验证GI home和database home的组件清单,下面我只列出了oracle的清单,省略了GI,在现实操作中两用户都需要检查。
-
[oracle@mhxy01 ~]$ $ORACLE_HOME/OPatch/opatch lsinventory -detail -oh $ORACLE_HOME
-
Oracle Interim Patch Installer version 11.2.0.3.6
-
Copyright (c) 2013, Oracle Corporation. All rights reserved.
-
-
-
Oracle Home : /oracle/database/product/11.2.0.4.0/db_1
-
Central Inventory : /oracle/grid/oraInventory
-
from : /oracle/database/product/11.2.0.4.0/db_1/oraInst.loc
-
OPatch version : 11.2.0.3.6
-
OUI version : 11.2.0.4.0
-
Log file location : /oracle/database/product/11.2.0.4.0/db_1/cfgtoollogs/opatch/opatch2016-08-03_10-30-22AM_1.log
-
-
Lsinventory Output file location : /oracle/database/product/11.2.0.4.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2016-08-03_10-30-22AM.txt
-
-
--------------------------------------------------------------------------------
-
Installed Top-level Products (1):
-
-
Oracle Database 11g 11.2.0.4.0
-
There are 1 product(s) installed in this Oracle Home.
-
-
-
Installed Components (136):
-
-
Agent Required Support Files 10.2.0.4.5
-
..................中间省略很多...............
-
XML Parser for Oracle JVM 11.2.0.4.0
-
There are 136 component(s) installed in this Oracle Home.
-
-
-
There are no Interim patches installed in this Oracle Home.
-
-
-
Rac system comprising of multiple nodes
-
Local node = mhxy01
-
Remote node = mhxy02
-
-
--------------------------------------------------------------------------------
-
-
OPatch succeeded.
-
[oracle@mhxy01 ~]$ exit
2.4 解压要安装的PSU补丁包,放置到非/tmp目录并保证oracle用户和grid用户具有访问该目录的权限。然后在两节点分别使用oracle和grid用户对补丁做prereq CheckConflictAgainstOHWithDetail 冲突检查
-
[root@mhxy01 bin]#mkdir -p /backup
-
[root@mhxy01 bin]#unzip p18139609_112040_Linux-x86-64.zip -d /backup
-
[root@mhxy01 bin]#chown -R root:oinstall /backup
-
#这里我们只列出一项检查,两节点的两用户都需要做冲突检查
-
[grid@mhxy01 ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /backup/18139609/
Oracle Interim Patch Installer version 11.2.0.3.6
Copyright (c) 2013, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /oracle/grid/crs
Central Inventory : /oracle/grid/oraInventory
from : /oracle/grid/crs/oraInst.loc
OPatch version : 11.2.0.3.6
OUI version : 11.2.0.4.0
Log file location : /oracle/grid/crs/cfgtoollogs/opatch/opatch2016-08-03_10-32-34AM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
2.5 在开始patching和rolling backup的时候都需要停止oem
-
[oracle@mhxy01 ~]$ /oracle/database/product/11.2.0.4.0/db_1/bin/emctl stop dbconsole
Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name.
[oracle@mhxy01 ~]$ export ORACLE_UNQNAME=mhxy
-
[oracle@mhxy01 ~]$ /oracle/database/product/11.2.0.4.0/db_1/bin/emctl stop dbconsole
-
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0
-
Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
-
https://mhxy01:1158/em/console/aboutApplication
-
Stopping Oracle Enterprise Manager 11g Database Control ...
-
... Stopped.
-
[oracle@mhxy01 ~]$ exit
2.6 Patch 安装 ,登录root用户,采用patch auto的方式安装 -ocmfr 指定2.2章节生成的ocm.rsp响应文件。
在patching过程十分缓慢 需要耐心等待,我们也可以通过输出的log日志跟踪具体的操作信息,其中包括补丁类型、OPatch版本、crs集群信息、DB和GI home是否共享、服务资源冲突性检查以后停止数据库相关资源 并分别对DB 和GI 执行opatch napply 操作日志。分析日志是解决问题的最主要途径,在自己就遭遇了 apply failed 的情况,在日志中查明原因是 Required amount of space(229.126MB) is not available. 也是没空间了 。
下面是正确的apply auto 信息。 需要在两个节点上分别执行以下操作。
-
[root@mhxy01 oracle]# /oracle/grid/crs/OPatch/opatch auto /backup/18139609 -ocmrf /oracle/grid/crs/OPatch/ocm/bin/ocm.rsp
-
Executing /oracle/grid/crs/perl/bin/perl /oracle/grid/crs/OPatch/crs/patch11203.pl -patchdir /backup -patchn 18139609 -ocmrf /oracle/grid/crs/OPatch/ocm/bin/ocm.rsp -paramfile /oracle/grid/crs/crs/install/crsconfig_params
-
-
This is the main log file: /oracle/grid/crs/cfgtoollogs/opatchauto2016-08-03_12-49-23.log
-
-
This file will show your detected configuration and all the steps that opatchauto attempted to do on your system:
-
/oracle/grid/crs/cfgtoollogs/opatchauto2016-08-03_12-49-23.report.log
-
-
2016-08-03 12:49:23: Starting Clusterware Patch Setup
-
Using configuration parameter file: /oracle/grid/crs/crs/install/crsconfig_params
-
-
Stopping RAC /oracle/database/product/11.2.0.4.0/db_1 ...
-
Stopped RAC /oracle/database/product/11.2.0.4.0/db_1 successfully
-
-
patch /backup/18139609/18031668 apply successful for home /oracle/database/product/11.2.0.4.0/db_1
-
patch /backup/18139609/18031740/custom/server/18031740 apply successful for home /oracle/database/product/11.2.0.4.0/db_1
-
-
Stopping CRS...
-
Stopped CRS successfully
-
-
patch /backup/18139609/18031668 apply successful for home /oracle/grid/crs
-
patch /backup/18139609/18031740 apply successful for home /oracle/grid/crs
-
patch /backup/18139609/18031731 apply successful for home /oracle/grid/crs
-
-
Starting CRS...
-
Installing Trace File Analyzer
-
CRS-4123: Oracle High Availability Services has been started.
-
-
Starting RAC /oracle/database/product/11.2.0.4.0/db_1 ...
-
Started RAC /oracle/database/product/11.2.0.4.0/db_1 successfully
-
-
opatch auto succeeded.
-
[root@mhxy01 oracle]#
3 更新数据库PSU信息
-
[oracle@mhxy01 ~]$ cd $ORACLE_HOME/rdbms/admin
-
[oracle@mhxy01 admin]$ sqlplus /nolog
-
-
SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 3 14:32:29 2016
-
-
Copyright (c) 1982, 2013, Oracle. All rights reserved.
-
-
SQL> CONNECT / AS SYSDBA
-
Connected to an idle instance.
-
SQL> STARTUP
-
ORACLE instance started.
-
-
Total System Global Area 835104768 bytes
-
Fixed Size 2257840 bytes
-
Variable Size 570428496 bytes
-
Database Buffers 260046848 bytes
-
Redo Buffers 2371584 bytes
-
Database mounted.
-
Database opened.
-
SQL> @catbundle.sql psu apply
-
PL/SQL procedure successfully completed.
-
SQL> COMMIT;
Commit complete.
SQL> SPOOL off
SQL> SET echo off
Check the following log file for errors:
/oracle/database/cfgtoollogs/catbundle/catbundle_PSU_MHXY_APPLY_2016Aug03_14_36_37.log
-
3.1 检查补丁更新情况,跟2.3节信息对比,明确PSU是否更新。当然除了下面方式外,还可以opatch lsinventory -bugs_fixed 检查 也可以在数据库里面检查dba_registry_history表信息
-
[oracle@mhxy01 admin]$ $ORACLE_HOME/OPatch/opatch lsinventory
-
Oracle Interim Patch Installer version 11.2.0.3.6
-
Copyright (c) 2013, Oracle Corporation. All rights reserved.
-
-
-
Oracle Home : /oracle/database/product/11.2.0.4.0/db_1
-
Central Inventory : /oracle/grid/oraInventory
-
from : /oracle/database/product/11.2.0.4.0/db_1/oraInst.loc
-
OPatch version : 11.2.0.3.6
-
OUI version : 11.2.0.4.0
-
Log file location : /oracle/database/product/11.2.0.4.0/db_1/cfgtoollogs/opatch/opatch2016-08-03_14-47-41PM_1.log
-
-
Lsinventory Output file location : /oracle/database/product/11.2.0.4.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2016-08-03_14-47-41PM.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 (2) :
-
-
Patch 18031740 : applied on Wed Aug 03 13:04:33 CST 2016
-
Unique Patch ID: 17253722
-
Patch description: "OCW Patch Set Update : 11.2.0.4.2 (18031740)"
-
Created on 19 Mar 2014, 09:06:31 hrs PST8PDT
-
Bugs fixed:
-
18328800, 16613232, 14525998, 14693336, 17273020, 17238586, 12928658
-
17391726, 17750548, 17387214, 18229842, 17172091, 17001914, 16346413
-
17155238, 17551223, 15832129, 17305100, 17483479, 17039197, 16317771
-
17292250, 17500165, 16206997, 17481314, 16876500, 17405302, 17065496
-
18343490, 13991403
-
-
Patch 18031668 : applied on Wed Aug 03 12:56:47 CST 2016
-
Unique Patch ID: 17255543
-
Patch description: "Database Patch Set Update : 11.2.0.4.2 (18031668)"
-
Created on 20 Feb 2014, 05:15:58 hrs PST8PDT
-
Sub-patch 17478514; "Database Patch Set Update : 11.2.0.4.1 (17478514)"
-
Bugs fixed:
-
17288409, 16399083, 17205719, 17811429, 10136473, 16472716, 17614227
-
17050888, 17040764, 17865671, 17325413, 14010183, 17726838, 13364795
-
17389192, 17612828, 17080436, 16613964, 17284817, 17441661, 17761775
-
17721717, 16721594, 17390431, 18203837, 17551709, 17344412, 16043574
-
17446237, 16863422, 18139690, 17071721, 17501491, 17610798, 17239687
-
17752121, 17468141, 17602269, 18203835, 17375354, 17313525, 17811456
-
16731148, 14133975, 18203838, 16956380, 17385178, 17235750, 13866822
-
17394950, 17478514, 17027426, 12905058, 14338435, 16450169, 13944971
-
18094246, 16929165, 16785708, 17265217, 17465741, 16220077, 16180763
-
16069901, 17546973, 16285691, 17323222, 18180390, 17088068, 16875449
-
17016369, 17443671, 16228604, 17811438, 17811447, 16837842, 18031668
-
16912439, 17332800, 17393683, 17622427, 17545847, 17186905, 16943711
-
16850630, 17082359, 17346671, 14852021, 17783588, 17437634, 16618694
-
17341326, 17296856, 17546761, 17716305
-
-
-
-
Rac system comprising of multiple nodes
-
Local node = mhxy01
-
Remote node = mhxy02
-
-
--------------------------------------------------------------------------------
-
-
OPatch succeeded.
-
#在数据库里面查询dba_registry_history;
-
SQL> select * from dba_registry_history;
ACTION_TIME ACTION NAMESPACE VERSION ID BUNDLE_SER COMMENTS
--------------------------------------------------------------------------- ---------- ---------- ---------- ---------- ---------- --------------------
24-AUG-13 12.03.45.119862 PM APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
10-APR-16 07.21.31.484992 PM APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
03-AUG-16 02.37.15.750467 PM APPLY SERVER 11.2.0.4 2 PSU PSU 11.2.0.4.2
03-AUG-16 02.39.24.088800 PM APPLY SERVER 11.2.0.4 2 PSU PSU 11.2.0.4.2
4.总结
在针对不同的生产数据库环境更新不同PSU的情况,就需要在patching前认真的阅读README文件和patching 中认真的跟踪log日志信息查询错误信息,解决went
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27039319/viewspace-2122922/
,如需转载,请注明出处,否则将追究法律责任。