- 备份、环境检查
重要:在打PSU之前需要备份ORACLE的关键目录ORACLE_HOME,GRID_HOME,oraInventory.
tar -cvf /tmp/gridOraInventory.2020.tar /u01/app/oraInventory
tar -cvf /tmp/gridHOME.2020.tar /u01/app/11.2.0.4/grid
tar -cvf /tmp/oracleHOME.2020.tar /u01/app/oracle/product/11.2.0.4
2.创建OCR磁盘组备份
su - root
cd $ORACLE_HOME/bin
./ocrconfig -local -export /home/grid/ocr.20200423.bak
./ocrconfig -manualbackup
[root@rac1 bin]# pwd
/u01/app/11.2.0.4/grid/bin
[root@rac1 bin]# ./ocrconfig -local -export /home/grid/ocr.20200423.bak
[root@rac1 bin]# ./ocrconfig -manualbackup
rac1 2020/04/23 09:47:39 /u01/app/11.2.0.4/grid/cdata/rac-cluster/backup_20200423_094739.ocr
[root@rac1 bin]# cd /home/grid/
[root@rac1 grid]# ls
Desktop Documents Downloads Music ocr.20200423.bak oradiag_grid –p Pictures Public Templates Videos
[root@rac1 grid]#
3.创建spfile备份文件
su - oracle
sqlplus / as sysdba
SQL> create pfile=‘/home/oracle/pfile_2020.ora’ from spfile;
su - grid
sqlplus / as sysasm
SQL> create pfile=‘/home/grid/pfile_2020.ora’ from spfile;
[root@rac1 grid]# su - oracle
[oracle@rac1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 23 09:49:41 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> create pfile='/home/oracle/pfile_2020.ora' from spfile;
File created.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
[oracle@rac1 ~]$ su - grid
Password:
[grid@rac1 ~]$ sqlplus / as sysasm
SQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 23 09:50:35 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
SQL> create pfile='/home/grid/pfile_2020.ora' from spfile;
File created.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
[grid@rac1 ~]$ ll /home/oracle/pfile_2020.ora
-rw-r--r-- 1 oracle asmadmin 1412 Apr 23 09:49 /home/oracle/pfile_2020.ora
[grid@rac1 ~]$ ll /home/grid/pfile_2020.ora
-rw-r--r-- 1 grid oinstall 257 Apr 23 09:50 /home/grid/pfile_2020.ora
[grid@rac1 ~]$
4.查看当前打补丁的环境信息
su - grid
crsctl query crs softwareversion
su - oracle
sqlplus / as sysdba
SQL> select * from v$version;
SQL> set linesize 200 pagesize 2000
col comp_name format a50
col version format a20
col status format a20
select comp_name,version,status from dba_registry;
[grid@rac1 ~]$ crsctl query crs softwareversion
Oracle Clusterware version on node [rac1] is [11.2.0.4.0]
[grid@rac1 ~]$ su - oracle
Password:
[oracle@rac1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 23 10:15:08 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
SQL> set linesize 200 pagesize 2000
col comp_name format a50
col version format a20
col status format a20
select comp_name,version,status from dba_registry;SQL> SQL> SQL> SQL>
COMP_NAME VERSION STATUS
-------------------------------------------------- -------------------- --------------------
OWB 11.2.0.4.0 VALID
Oracle Application Express 3.2.1.00.12 VALID
Oracle Enterprise Manager 11.2.0.4.0 VALID
OLAP Catalog 11.2.0.4.0 VALID
Spatial 11.2.0.4.0 VALID
Oracle Multimedia 11.2.0.4.0 VALID
Oracle XML Database 11.2.0.4.0 VALID
Oracle Text 11.2.0.4.0 VALID
Oracle Expression Filter 11.2.0.4.0 VALID
Oracle Rules Manager 11.2.0.4.0 VALID
Oracle Workspace Manager 11.2.0.4.0 VALID
Oracle Database Catalog Views 11.2.0.4.0 VALID
Oracle Database Packages and Types 11.2.0.4.0 VALID
JServer JAVA Virtual Machine 11.2.0.4.0 VALID
Oracle XDK 11.2.0.4.0 VALID
Oracle Database Java Packages 11.2.0.4.0 VALID
OLAP Analytic Workspace 11.2.0.4.0 VALID
Oracle OLAP API 11.2.0.4.0 VALID
Oracle Real Application Clusters 11.2.0.4.0 VALID
19 rows selected.
- 更新OPatch 版本(查看补丁包中的README文件,如果版本满足要求,则可以跳过该步骤)
查看当前OPatch 的版本
su - grid
/u01/app/11.2.0.4/grid/OPatch/opatch version
su - oracle
/u01/app/oracle/product/11.2.0.4/db_1/OPatch/opatch version
[oracle@rac1 ~]$ su - grid
Password:
[grid@rac1 ~]$ /u01/app/11.2.0.4/grid/OPatch/opatch version
OPatch Version: 11.2.0.3.4
OPatch succeeded.
[oracle@rac1 ~]$ su - oracle
Password:
[oracle@rac1 ~]$ /u01/app/oracle/product/11.2.0.4/db_1/OPatch/opatch version
OPatch Version: 11.2.0.3.4
OPatch succeeded.
备份原来的 OPatch 目录(在OPatch 版本不满足条件的时候才需要进行该操作)
su - root
mv /u01/app/11.2.0.4/grid/OPatch /u01/app/11.2.0.4/grid/OPatch.2020.bk
mv /u01/app/oracle/product/11.2.0.4/db_1/OPatch /u01/app/oracle/product/11.2.0.4/db_1/OPatch.2020.bk
[oracle@rac1 ~]$ su - root
Password:
[root@rac1 ~]# mv /u01/app/11.2.0.4/grid/OPatch /u01/app/11.2.0.4/grid/OPatch.2020.bk
[root@rac1 db_1]# mv /u01/app/oracle/product/11.2.0.4/db_1/OPatch /u01/app/oracle/product/11.2.0.4/db_1/OPatch.2020.bk
解压 OPatch 压缩包
#unzip p6880880_112000_Linux-x86-64.zip
#mv /u01/meida/OPatch/ /u01/app/11.2.0.4/grid/OPatch
#unzip p6880880_112000_Linux-x86-64.zip
#mv /u01/meida/OPatch/ /u01/app/oracle/product/11.2.0.4/db_1/OPatch
[root@rac1 meida]# unzip p6880880_112000_Linux-x86-64.zip
[root@rac1 meida]# ls
OPatch p30501155_112040_Linux-x86-64.zip p6880880_112000_Linux-x86-64.zip patches
[root@rac1 meida]# mv /u01/meida/OPatch/ /u01/app/11.2.0.4/grid/OPatch
[root@rac1 meida]# unzip p6880880_112000_Linux-x86-64.zip
[root@rac1 meida]# ls
OPatch p30501155_112040_Linux-x86-64.zip p6880880_112000_Linux-x86-64.zip patches
[root@rac1 meida]# mv /u01/meida/OPatch/ /u01/app/oracle/product/11.2.0.4/db_1/OPatch
修改 OPatch 的属主、属组
chown -R oracle:oinstall /u01/app/oracle/product/11.2.0.4/db_1/OPatch
chown -R grid:oinstall /u01/app/11.2.0.4/grid/OPatch
[root@rac1 meida]# chown -R oracle:oinstall /u01/app/oracle/product/11.2.0.4/db_1/OPatch
[root@rac1 meida]# chown -R grid:oinstall /u01/app/11.2.0.4/grid/OPatch
6.解压补丁包、检测冲突
解压补丁包
mkdir -p /u01/media/patches
unzip p6880880_112000_Linux-x86-64.zip -d /u01/meida/patches/
chmod 775 -R /u01/meida/patches/
chown -R grid:oinstall /u01/meida/
[root@rac1 meida]# mkdir -p /u01/meida/patches
[root@rac1 meida]# unzip p30501155_112040_Linux-x86-64.zip -d /u01/meida/patches/
[root@rac1 meida]# ls
p30501155_112040_Linux-x86-64.zip p6880880_112000_Linux-x86-64.zip patches
[root@rac1 meida]# cd patches/
[root@rac1 patches]# ls
30501155
[root@rac1 ~]# chown -R grid:oinstall /u01/meida/
检测补丁包与已打补丁是否冲突
su - grid
/u01/app/11.2.0.4/grid/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/meida/patches/30501155/
su - oracle
/u01/app/oracle/product/11.2.0.4/db_1/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/meida/patches/30501155/
[grid@rac1 u01]$ /u01/app/11.2.0.4/grid/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/meida/patches/30501155/
Oracle Interim Patch Installer version 11.2.0.3.23
Copyright (c) 2020, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/11.2.0.4/grid
Central Inventory : /u01/app/oraInventory
from : /u01/app/11.2.0.4/grid/oraInst.loc
OPatch version : 11.2.0.3.23
OUI version : 11.2.0.4.0
Log file location : /u01/app/11.2.0.4/grid/cfgtoollogs/opatch/opatch2020-04-23_11-15-37AM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
[grid@rac1 u01]$ su - oracle
Password:
[oracle@rac1 ~]$ /u01/app/oracle/product/11.2.0.4/db_1/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/meida/patches/30501155/
Oracle Interim Patch Installer version 11.2.0.3.23
Copyright (c) 2020, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/oracle/product/11.2.0.4/db_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/11.2.0.4/db_1/oraInst.loc
OPatch version : 11.2.0.3.23
OUI version : 11.2.0.4.0
Log file location : /u01/app/oracle/product/11.2.0.4/db_1/cfgtoollogs/opatch/opatch2020-04-23_11-17-23AM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
[oracle@rac1 ~]$
- 打补丁
打补丁前停掉实例
(OPatch下有emocmrsp的可以通过生成响应文件进行打补丁)
su - root
su - grid -c “/u01/app/11.2.0.4/grid/OPatch/ocm/bin/emocmrsp -no_banner -output /tmp/grid_ocm.rsp”
su - oracle -c “/u01/app/oracle/product/11.2.0.4/db_1/OPatch/ocm/bin/emocmrsp -no_banner -output /tmp/oracle_ocm.rsp”
u01/app/11.2.0.4/grid/OPatch/opatch auto /u01/media/patches -ocmrf /tmp/grid_ocm.rsp
PS: Oracle 11g RAC 环境,使用auto的方式对GI打补丁的过程中会把DB的补丁也打上,不需要再单独对DB进行打补丁,如果发现DB没有打上,再对DB单独进行
opatch auto /u01/meida/patches/30501155/ -oh /u01/app/oracle/product/11.2.0.4/db_1/ -ocmrf /tmp/oracle_ocm.rsp
两个节点都要执行
(OPatch下没有emocmrsp,无法生成响应文件)
su - grid
/u01/app/11.2.0.4/grid/OPatch/opatch auto /u01/meida/patches/30501155 -oh /u01/app/11.2.0.4/grid/
su - oracle
/u01/app/oracle/product/11.2.0.4/db_1/OPatch/opatch auto /u01/media/patches/30501155 -oh /u01/app/oracle/product/11.2.0.4/db_1/
两个节点都要执行
[oracle@rac1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 23 11:38:11 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
[root@rac1 meida]# /u01/app/11.2.0.4/grid/OPatch/opatch auto /u01/meida/patches/30501155 -oh /u01/app/11.2.0.4/grid/
Executing /u01/app/11.2.0.4/grid/perl/bin/perl /u01/app/11.2.0.4/grid/OPatch/crs/patch11203.pl -patchdir /u01/meida/patches -patchn 30501155 -oh /u01/app/11.2.0.4/grid/ -paramfile /u01/app/11.2.0.4/grid/crs/install/crsconfig_params
This is the main log file: /u01/app/11.2.0.4/grid/cfgtoollogs/opatchauto2020-04-26_13-07-31.log
This file will show your detected configuration and all the steps that opatchauto attempted to do on your system:
/u01/app/11.2.0.4/grid/cfgtoollogs/opatchauto2020-04-26_13-07-31.report.log
2020-04-26 13:07:31: Starting Clusterware Patch Setup
Using configuration parameter file: /u01/app/11.2.0.4/grid/crs/install/crsconfig_params
Stopping CRS...
Stopped CRS successfully
patch /u01/meida/patches/30501155/29938455 apply successful for home /u01/app/11.2.0.4/grid
patch /u01/meida/patches/30501155/30298532 apply successful for home /u01/app/11.2.0.4/grid
patch /u01/meida/patches/30501155/29509309 apply successful for home /u01/app/11.2.0.4/grid
Starting CRS...
Installing Trace File Analyzer
CRS-4123: Oracle High Availability Services has been started.
opatch auto succeeded.
[root@rac1 meida]# /u01/app/oracle/product/11.2.0.4/db_1/OPatch/opatch auto /u01/meida/patches/30501155/ -oh /u01/app/oracle/product/11.2.0.4/db_1/
Executing /u01/app/11.2.0.4/grid/perl/bin/perl /u01/app/oracle/product/11.2.0.4/db_1/OPatch/crs/patch11203.pl -patchdir /u01/meida/patches -patchn 30501155 -oh /u01/app/oracle/product/11.2.0.4/db_1/ -paramfile /u01/app/11.2.0.4/grid/crs/install/crsconfig_params
This is the main log file: /u01/app/oracle/product/11.2.0.4/db_1/cfgtoollogs/opatchauto2020-04-26_13-24-00.log
This file will show your detected configuration and all the steps that opatchauto attempted to do on your system:
/u01/app/oracle/product/11.2.0.4/db_1/cfgtoollogs/opatchauto2020-04-26_13-24-00.report.log
2020-04-26 13:24:00: Starting Clusterware Patch Setup
Using configuration parameter file: /u01/app/11.2.0.4/grid/crs/install/crsconfig_params
Stopping RAC /u01/app/oracle/product/11.2.0.4/db_1 ...
Stopped RAC /u01/app/oracle/product/11.2.0.4/db_1 successfully
patch /u01/meida/patches/30501155/29938455/custom/server/29938455 apply successful for home /u01/app/oracle/product/11.2.0.4/db_1
patch /u01/meida/patches/30501155/30298532 apply successful for home /u01/app/oracle/product/11.2.0.4/db_1
Starting RAC /u01/app/oracle/product/11.2.0.4/db_1 ...
Started RAC /u01/app/oracle/product/11.2.0.4/db_1 successfully
opatch auto succeeded.
另外一个节点执行同样的操作
- 验证已打补丁情况
su - grid
/u01/app/11.2.0.4/grid/OPatch/opatch lsinventory
su - oracle
/u01/app/oracle/product/11.2.0.4/db_1/OPatch/opatch lsinventory
[root@rac1 ~]# su - grid
[grid@rac1 ~]$ /u01/app/11.2.0.4/grid/OPatch/opatch lsinventory
Oracle Interim Patch Installer version 11.2.0.3.23
Copyright (c) 2020, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/11.2.0.4/grid
Central Inventory : /u01/app/oraInventory
from : /u01/app/11.2.0.4/grid/oraInst.loc
OPatch version : 11.2.0.3.2