前段时间测试单机数据库升级补丁,那么在RAC中怎么自动为集群软件、数据库升级补丁呢,下面让我们来看看。
环境:redhat6.3_x64+Oracle11g RAC (11.2.0.4.0)
所需补丁包:p6880880_112000_Linux-x86-64.zip p20996923_112040_Linux-x86-64.zip
补丁信息:
p20996923_112040_Linux-x86-64.zip==> GI PSUs are cumulative and include the Database PSU and associated CPU program security content
p6880880_112000_Linux-x86-64.zip==> You must use the OPatch utility version 11.2.0.3.6 or later to apply this patch. (11.2.0.3.10)
将两个包上传至RAC各节点,解压。
unzip p6880880_112000_Linux-x86-64.zip | unzip p20996923_112040_Linux-x86-64.zip
温馨提示:在做数据库的任何操作,都建议在操作前备份数据库,以免造成不必要损失。
将新的目录 OPatch 分别拷贝到各个节点的GRID、Oracle主目录中,cp -rf OPatch $GRID_HOME、$ORACLE_HOME(建议提前备份)
查看opatch 信息:
-
[grid@rac01 OPatch]$ ./opatch lsinventory
-
Oracle Interim Patch Installer version 11.2.0.3.10
-
Copyright (c) 2015, Oracle Corporation. All rights reserved.
-
-
-
Oracle Home : /grid/crs_home/product/11.2.0
-
Central Inventory : /grid/oraInventory
-
from : /grid/crs_home/product/11.2.0/oraInst.loc
-
OPatch version : 11.2.0.3.10
-
OUI version : 11.2.0.4.0
-
Log file location : /grid/crs_home/product/11.2.0/cfgtoollogs/opatch/opatch2015-07-31_14-31-35PM_1.log
-
-
Lsinventory Output file location : /grid/crs_home/product/11.2.0/cfgtoollogs/opatch/lsinv/lsinventory2015-07-31_14-31-35PM.txt
-
-
--------------------------------------------------------------------------------
-
Local Machine Information::
-
Hostname: rac01
-
ARU platform id: 226
-
ARU platform description:: Linux x86-64
-
-
Installed Top-level Products (1):
-
-
Oracle Grid Infrastructure 11g 11.2.0.4.0
-
There are 1 products installed in this Oracle Home.
-
-
-
There are no Interim patches installed in this Oracle Home.
-
-
-
Rac system comprising of multiple nodes
-
Local node = rac01
-
Remote node = rac02
-
-
--------------------------------------------------------------------------------
-
-
OPatch succeeded.
通过grid用户创建ocm配置文件,各个节点都需要(也可以拷贝到其他节点):
-
[grid@rac01 bin]$ pwd
-
/grid/crs_home/product/11.2.0/OPatch/ocm/bin
-
[grid@rac01 bin]$ ./emocmrsp -no_banner -output /grid/soft/ocm.rsp
检查每个节点grid、oracle的patch的相容性。例如
检查通过后,停止数据库: srvctl stop database -d racdb
以root用户开始执行下面语句,每个节点都需要执行(依次):
-
[root@rac01 ~]# export GI_HOME=/grid/crs_home/product/11.2.0
-
[root@rac01 ~]# $GI_HOME/OPatch/opatch auto /grid/soft/20996923 -ocmrf /grid/soft/ocm.rsp
-
Executing /grid/crs_home/product/11.2.0/perl/bin/perl /grid/crs_home/product/11.2.0/OPatch/crs/patch11203.pl -patchdir /grid/soft -patchn 20996923 -ocmrf /grid/soft/ocm.rsp -paramfile /grid/crs_home/product/11.2.0/crs/install/crsconfig_params
-
-
This is the main log file: /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto2015-08-03_09-20-46.log
-
-
This file will show your detected configuration and all the steps that opatchauto attempted to do on your system:
-
/grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto2015-08-03_09-20-46.report.log
-
-
2015-08-03 09:20:46: Starting Clusterware Patch Setup
-
Using configuration parameter file: /grid/crs_home/product/11.2.0/crs/install/crsconfig_params
-
-
Stopping RAC /oracle/app/oracle/product/11.2.0 ...
-
Stopped RAC /oracle/app/oracle/product/11.2.0 successfully
-
-
patch /grid/soft/20996923/20760982 apply successful for home /oracle/app/oracle/product/11.2.0
-
patch /grid/soft/20996923/20831122/custom/server/20831122 apply successful for home /oracle/app/oracle/product/11.2.0
-
-
Stopping CRS...
-
Stopped CRS successfully
-
-
patch /grid/soft/20996923/20760982 apply successful for home /grid/crs_home/product/11.2.0
-
patch /grid/soft/20996923/20831122 apply successful for home /grid/crs_home/product/11.2.0
-
patch /grid/soft/20996923/20299019 apply successful for home /grid/crs_home/product/11.2.0
-
-
Starting CRS...
-
Installing Trace File Analyzer
-
CRS-4123: Oracle High Availability Services has been started.
-
-
Starting RAC /oracle/app/oracle/product/11.2.0 ...
-
Started RAC /oracle/app/oracle/product/11.2.0 successfully
-
-
opatch auto succeeded.
-
[root@rac01 ~]#
下面是后台输出日志,由于日志太多,截取部分日志信息:
-
...................
-
Verifying environment and performing prerequisite checks...
-
OPatch continues with these patches: 17478514 18031668 18522509 19121551 19769489 20299013 20760982
-
-
Do you want to proceed? [y|n]
-
Y (auto-answered by -silent)
-
User Responded with: Y
-
All checks passed.
-
-
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
-
(Oracle Home = '/oracle/app/oracle/product/11.2.0')
-
Is the local system ready for patching? [y|n]
-
Y (auto-answered by -silent)
-
User Responded with: Y
-
Backing up files...
-
Applying sub-patch '17478514' to OH '/oracle/app/oracle/product/11.2.0'
-
-
Patching component oracle.rdbms, 11.2.0.4.0...
-
...........
-
..........
-
2015-08-03 09:30:30: Unlock crshome...
-
2015-08-03 09:30:30: crshome passed is
-
2015-08-03 09:30:30: Exclude file used is /grid/crs_home/product/11.2.0/OPatch/crs/installPatch.excl
-
2015-08-03 09:30:30: Home location in olr.loc is /grid/crs_home/product/11.2.0
-
2015-08-03 09:30:30: unlock crs home is /grid/crs_home/product/11.2.0
-
2015-08-03 09:30:30: Executing /grid/crs_home/product/11.2.0/bin/crsctl stop crs -f
-
2015-08-03 09:30:30: Executing cmd: /grid/crs_home/product/11.2.0/bin/crsctl stop crs -f
-
2015-08-03 09:34:05: Command output:
-
> CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'rac01'
-
> CRS-2673: Attempting to stop 'ora.crsd' on 'rac01'
-
> CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on 'rac01'
-
> CRS-2673: Attempting to stop 'ora.LISTENER_SCAN1.lsnr' on 'rac01'
-
.............
下面是后台执行具体操作
-
[grid@rac01 opatch]$ tail -f /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto2015-08-03_09-20-46.report.log
-
crs_home=/grid/crs_home/product/11.2.0 version=11.2.0.4.0 owner=grid opatch_ver=11.2.0.3.10
-
rac_home=/oracle/app/oracle/product/11.2.0 version=11.2.0.4.0 owner=oracle opatch_ver=11.2.0.3.10
-
-
*********** Steps to be executed as owner unless specified as root ***********
-
-
-
1: /oracle/app/oracle/product/11.2.0/OPatch/opatch prereq CheckComponents -ph /grid/soft/20996923/20760982 -oh /oracle/app/oracle/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
2: /oracle/app/oracle/product/11.2.0/OPatch/opatch prereq CheckComponents -ph /grid/soft/20996923/20831122/custom/server/20831122 -oh /oracle/app/oracle/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
3: /oracle/app/oracle/product/11.2.0/OPatch/opatch prereq CheckConflictAgainstOH -ph /grid/soft/20996923/20760982 -oh /oracle/app/oracle/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
4: /oracle/app/oracle/product/11.2.0/OPatch/opatch prereq CheckConflictAgainstOH -ph /grid/soft/20996923/20831122/custom/server/20831122 -oh /oracle/app/oracle/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
5: /grid/crs_home/product/11.2.0/OPatch/opatch prereq CheckComponents -ph /grid/soft/20996923/20760982 -oh /grid/crs_home/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
6: /grid/crs_home/product/11.2.0/OPatch/opatch prereq CheckComponents -ph /grid/soft/20996923/20831122 -oh /grid/crs_home/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
7: /grid/crs_home/product/11.2.0/OPatch/opatch prereq CheckComponents -ph /grid/soft/20996923/20299019 -oh /grid/crs_home/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
8: /grid/crs_home/product/11.2.0/OPatch/opatch prereq CheckConflictAgainstOH -ph /grid/soft/20996923/20760982 -oh /grid/crs_home/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
9: /grid/crs_home/product/11.2.0/OPatch/opatch prereq CheckConflictAgainstOH -ph /grid/soft/20996923/20831122 -oh /grid/crs_home/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
10: /grid/crs_home/product/11.2.0/OPatch/opatch prereq CheckConflictAgainstOH -ph /grid/soft/20996923/20299019 -oh /grid/crs_home/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
11: /oracle/app/oracle/product/11.2.0/bin/emctl stop dbconsole
-
-
12: /oracle/app/oracle/product/11.2.0/bin/emctl stop agent
-
-
13: /oracle/app/oracle/product/11.2.0/OPatch/opatch prereq CheckApplicable -ph /grid/soft/20996923/20760982 -oh /oracle/app/oracle/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
14: /oracle/app/oracle/product/11.2.0/OPatch/opatch prereq CheckApplicable -ph /grid/soft/20996923/20831122/custom/server/20831122 -oh /oracle/app/oracle/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
15: /oracle/app/oracle/product/11.2.0/bin/srvctl stop home -o /oracle/app/oracle/product/11.2.0 -s /oracle/app/oracle/product/11.2.0/srvm/admin/stophome.txt -n rac01 -f
-
-
16: /grid/soft/20996923/20831122/custom/server/20831122/custom/scripts/prepatch.sh -dbhome /oracle/app/oracle/product/11.2.0
-
-
17: /oracle/app/oracle/product/11.2.0/OPatch/opatch napply /grid/soft/20996923/20760982 -local -silent -ocmrf /grid/soft/ocm.rsp -oh /oracle/app/oracle/product/11.2.0 -invPtrLoc /oracle/app/oracle/product/11.2.0/oraInst.loc
-
-
18: /oracle/app/oracle/product/11.2.0/OPatch/opatch napply /grid/soft/20996923/20831122/custom/server/20831122 -local -silent -ocmrf /grid/soft/ocm.rsp -oh /oracle/app/oracle/product/11.2.0 -invPtrLoc /oracle/app/oracle/product/11.2.0/oraInst.loc
-
-
19: /grid/soft/20996923/20831122/custom/server/20831122/custom/scripts/postpatch.sh -dbhome /oracle/app/oracle/product/11.2.0
-
-
20: /grid/crs_home/product/11.2.0/crs/install/rootcrs.pl -unlock : run as root
-
-
21: /sbin/fuser -k /grid/crs_home/product/11.2.0/bin/crsctl.bin : run as root
-
-
22: /grid/crs_home/product/11.2.0/OPatch/opatch prereq CheckApplicable -ph /grid/soft/20996923/20760982 -oh /grid/crs_home/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
23: /grid/crs_home/product/11.2.0/OPatch/opatch prereq CheckApplicable -ph /grid/soft/20996923/20831122 -oh /grid/crs_home/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
24: /grid/crs_home/product/11.2.0/OPatch/opatch prereq CheckApplicable -ph /grid/soft/20996923/20299019 -oh /grid/crs_home/product/11.2.0 -customLogDir /grid/crs_home/product/11.2.0/cfgtoollogs/opatchauto/core
-
-
25: /grid/crs_home/product/11.2.0/OPatch/opatch napply /grid/soft/20996923/20760982 -local -silent -ocmrf /grid/soft/ocm.rsp -oh /grid/crs_home/product/11.2.0 -invPtrLoc /grid/crs_home/product/11.2.0/oraInst.loc
-
-
26: /grid/crs_home/product/11.2.0/OPatch/opatch napply /grid/soft/20996923/20831122 -local -silent -ocmrf /grid/soft/ocm.rsp -oh /grid/crs_home/product/11.2.0 -invPtrLoc /grid/crs_home/product/11.2.0/oraInst.loc
-
-
27: /grid/crs_home/product/11.2.0/OPatch/opatch napply /grid/soft/20996923/20299019 -local -silent -ocmrf /grid/soft/ocm.rsp -oh /grid/crs_home/product/11.2.0 -invPtrLoc /grid/crs_home/product/11.2.0/oraInst.loc
-
-
28: /grid/crs_home/product/11.2.0/bin/emctl start dbconsole
-
-
29: /grid/crs_home/product/11.2.0/rdbms/install/rootadd_rdbms.sh : run as root
-
-
30: /grid/crs_home/product/11.2.0/crs/install/rootcrs.pl -patch : run as root
-
-
31: /oracle/app/oracle/product/11.2.0/bin/emctl start dbconsole
-
-
32: /oracle/app/oracle/product/11.2.0/bin/emctl start agent
-
-
33: /oracle/app/oracle/product/11.2.0/bin/srvctl start home -o /oracle/app/oracle/product/11.2.0 -s /oracle/app/oracle/product/11.2.0/srvm/admin/stophome.txt -n rac01
再各个节点执行完自动升级后,启动数据库:srvctl start database -d racdb
执行下面语句,在每个节点
-
SQL> @?/rdbms/admin/catbundle.sql psu apply
-
-
PL/SQL procedure successfully completed.
-
-
-
Function created.
-
-
-
Function created.
-
-
-
PL/SQL procedure successfully completed.
-
..............
-
SQL> INSERT INTO registry$history
-
2 (action_time, action,
-
3 namespace, version, id,
-
4 bundle_series, comments)
-
5 VALUES
-
6 (SYSTIMESTAMP, 'APPLY',
-
7 SYS_CONTEXT('REGISTRY$CTX','NAMESPACE'),
-
8 '11.2.0.4',
-
9 7,
-
10 'PSU',
-
11 'PSU 11.2.0.4.7');
-
-
1 row created.
-
-
SQL> COMMIT;
-
-
Commit complete.
-
-
SQL> SPOOL off
-
SQL> SET echo off
-
Check the following log file for errors:
-
/oracle/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_RACDB_APPLY_2015Aug03_09_58_09.log
检查数据库信息:
-
SQL> select * from dba_registry_history;
-
-
ACTION_TIME ACTION NAMESPACE VERSION ID BUNDLE_SERIES COMMENTS
-
------------------------------ ---------------- ---------- ---------- ---------- --------------- --------------------------
-
2014-09-28 05:52:58.357412 APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
-
2015-08-03 09:59:48.521212 APPLY SERVER 11.2.0.4 7 PSU PSU 11.2.0.4.7
-
2015-08-03 10:00:11.433233 APPLY SERVER 11.2.0.4 7 PSU PSU 11.2.0.4.7
查看grid 版本信息
-
[grid@rac01 OPatch]$ ./opatch lsinventory -detail -oh $ORACLE_HOME | grep -i patch
-
Oracle Interim Patch Installer version 11.2.0.3.10
-
OPatch version : 11.2.0.3.10
-
Log file location : /grid/crs_home/product/11.2.0/cfgtoollogs/opatch/opatch2015-08-03_10-49-36AM_1.log
-
Lsinventory Output file location : /grid/crs_home/product/11.2.0/cfgtoollogs/opatch/lsinv/lsinventory2015-08-03_10-49-36AM.txt
-
Oracle One-Off Patch Installer 11.2.0.3.4
-
Interim patches (3) :
-
Patch 20299019 : applied on Mon Aug 03 09:43:14 CST 2015
-
Unique Patch ID: 18573450
-
Patch description: "ACFS Patch set update : 11.2.0.4.6 (20299019)"
-
Patch Location in Inventory:
-
Patch Location in Storage area:
-
/grid/crs_home/product/11.2.0/.patch_storage/20299019_Mar_27_2015_15_26_30
-
Patch 20831122 : applied on Mon Aug 03 09:41:03 CST 2015
-
Unique Patch ID: 18923533
-
Patch description: "OCW Patch Set Update : 11.2.0.4.7 (20831122)"
-
crspatch.pm --> ORACLE_HOME/crs/install/crspatch.pm
-
Patch Location in Inventory:
-
Patch Location in Storage area:
-
/grid/crs_home/product/11.2.0/.patch_storage/20831122_Jul_1_2015_06_26_45
-
Patch 20760982 : applied on Mon Aug 03 09:39:05 CST 2015
-
Unique Patch ID: 18908105
-
Patch description: "Database Patch Set Update : 11.2.0.4.7 (20760982)"
-
Sub-patch 20299013; "Database Patch Set Update : 11.2.0.4.6 (20299013)"
-
Sub-patch 19769489; "Database Patch Set Update : 11.2.0.4.5 (19769489)"
-
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)"
-
bug16595641.sql --> ORACLE_HOME/patch/scripts/bug16595641.sql
-
bug17088068.sql --> ORACLE_HOME/patch/scripts/bug17088068.sql
-
bug17381384.sql --> ORACLE_HOME/patch/scripts/bug17381384.sql
-
bug19289642.sql --> ORACLE_HOME/patch/scripts/bug19289642.sql
-
sdopatch.sql --> ORACLE_HOME/md/admin/sdopatch.sql
-
Patch Location in Inventory:
-
Patch Location in Storage area:
-
/grid/crs_home/product/11.2.0/.patch_storage/20760982_Jun_4_2015_00_23_20
-
OPatch succeeded.
-
[grid@rac01 OPatch]$
至此,oracle11g rac 打补丁完成,通过一条命令,我们就可以为gird、database升级,方面高效,通过后台日志,我们可以看到,它的每一步操作,能够让我们更好的掌握升级、了解其过程。
文盲筱烨,2015年8月3日
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29487349/viewspace-1760397/
,如需转载,请注明出处,否则将追究法律责任。