Oracle 11g RAC集群PSU补丁安装(二)

Oracle 11g RAC集群PSU补丁安装(二)

本文章描述新建GI集群软件和Oracle数据库软件,已经创建数据库并数据库已经对外使用情况下,安装GI和数据库软件的PSU补丁包;

一、安装建议

1、先安装GI和Oracle数据库软件PSU补丁

2、升级数据字典

二、PSU安装环境

复制代码
本实验环境:11.2.0.4 RAC
操作系统:linux 7.9
数据库名称:orcl
待补丁包:p33575261_112040_Linux-x86-64.zip
补丁存放位置:/u01/soft/ (两个节点都上传补丁包和最新的OPatch工具包),如下
cd /u01/soft/
ls -ltr p33*  p688*
-rw-r--r-- 1 grid   oinstall 1386494818 Jan 16  2023 p33575261_112040_Linux-x86-64.zip
-rw-r--r-- 1 grid   oinstall  124902830 Jan 16  2023 p6880880_112000_Linux-x86-64-11.2.0.3.36.zip

三、PSU安装前准备工作

(一)GI集群和Oracle数据库软件安装前准备工作
复制代码
1、需要提前安装Perl模块Env包,否则会在第一步rootcrs.pl -unlock时报错
yum install perl-Env -y
2、grid用户ORACLE_HOME目录的所属为root:oinstall权限为755,需要调整权限为775
su - grid
[grid@hostrac1 app]$ env|grep ORACLE_HOME
ORACLE_HOME=/u01/app/crs
root用户修改权限
chmod 775  /u01/app/crs
3、以前的PSU可以通过auto模式,通过opatch工具生成个ocm应答文件,通过root一条命令完成GI集群和Oracle数据库软件PSU补丁包的安装。但是2020年一季度后,oracle对新的psu补丁做了些改动,之后的补丁必须把opatch工具包升级到11.2.0.3.23+,但是新版本的opatch工具包却不再提供ocm脚本,只能手动模式逐个应用补丁
4、/u01/soft 调整为权限775,存放补丁包
root用户修改权限
chmod 775  /u01/soft
5、阅读补丁文件的readme描述,确认各个组件的版本
OCW  PSU:32758914
ACFS PSU:33112794
DB   PSU:33477185
备注:手工安装方式,只能手动模式逐个应用补丁集
6、条件允许的情况下,强烈建议备份GI集群软件和Oracle数据库软件的ORACLE_HOME目录
7、停止em代理,emctl stop dbconsole。(如果有使用em代理,一定要提前关闭掉,使用oracle用户)
8、应用psu前需要关闭节点上所有数据库实例 srvctl stop database -d orcl
9、OCR集群配置文件手工备份(可选)
一个节点执行执行即可,类似如下:
/u01/app/crs/bin/ocrconfig  -manualbackup
hostrac1     2026/06/15 16:29:17     /u01/app/crs/cdata/hostrac-cluster/backup_20260615_162917.ocr
/u01/app/crs/bin/ocrconfig  -export /home/grid/ocrexport_$(date +%Y%m%d%H%M%S).xml
ll /home/grid/ocrexport*
-rw------- 1 root root 114136 Jun 15 16:30 /home/grid/ocrexport_20260615163028.xml
(二)PSU补丁包安装完毕后,升级数据字典前准备工作
复制代码
1、考虑主机上是否有定时任务(例如备份任务这些,建议期间停止这些定时任务)
2、oracle数据库中的无效对象,尽量提前处理,因为数据库中的数据字典升级以后,需要重新编译所有无效的对象,如果库中存在大量无效对象,会影响整个补丁安装过程
3、提前快照一份无效对象清单,psu安装前后进行比对,确保整个psu升级过程,没有产生新的无效对象
4、数据库组件检查,用于安装前后对比
5、临时关闭数据库中的job
6、关闭数据库(最好immediate干净方式)
7、可选项,如果是非常重要的核心数据库,建议重新打开数据库,开启数据库闪回功能,建立闪回还原点,然后再次immediate方式关闭数据库。该步骤主要是预防,如果数据库字典升级出现异常,可以快速闪回至还原点,快速将数据库还原至升级前的状态。

两大类准备工作必须同步完成,才能进行下一步PSU补丁包安装。

(三)准备工作具体操作
升级数据字典前准备工作

1、检查root用户和oracle用户下有没有数据库相关的定时任务,安装psu之前提前注释掉

复制代码
su - root
crontab -l
su - oracle
crontab -l

2、检查数据库中的失效对象

复制代码
su - oracle
sqlplus "/as sysdba"
set linesize 200 pagesize 999
select owner,object_name,object_id,data_object_id,object_type,status 
from dba_objects where status<> 'VALID';

3、快照一份无效对象清单

复制代码
su - oracle
sqlplus "/as sysdba"
create table  sys.t_invilid_objects 
as 
select owner,object_name,object_id,data_object_id,object_type,status 
from dba_objects where status<> 'VALID';

4、数据库组件检查

复制代码
su - oracle
sqlplus "/as sysdba"
set linesize 200 pagesize 999
col ACTION_TIME format a30
col comments format a19
col comp_name format a35
col object_name format a30
col owner format a20
select * from dba_registry_history;
select comp_id,comp_name,status from dba_registry;

5、临时关闭数据库中的job

复制代码
alter system set job_queue_processes =0;
备注:该参数修改为0,表示oracle后台关闭job任务执行进程,因此所有job都会暂停执行

6、关闭数据库(最好immediate干净方式)

复制代码
可以先关闭监听、检查数据库中的活动事务(确保无大事务活动)、然后kill掉所有节点的外部连接,然后在所有节点执行强制检查点
最后再尝试干净的immediate关闭数据库
su - oracle
srvctl stop database -d orcl
可以参考我的文章《Oracle单库环境下计划内启停数据库的步骤》

7、可选项,后续单独编写Oracle数据库闪回管理知识文章

GI集群和Oracle数据库软件安装前准备工作

1、条件允许的情况下,强烈建议备份GI集群软件和Oracle数据库软件的ORACLE_HOME目录(所有节点都执行)

复制代码
Oracle用户的ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
grid用户的ORACLE_HOME=/u01/app/crs
1)Oracle数据库软件的ORACLE_HOME目录备份
方法一:
tar命令用root用户,经过验证,文件属性都是保持原有的
tar命令 
cd /u01/app/oracle/product/11.2.0/
tar  -czvf db_1.tar.zip   ./db_1

解压命令
cd /u01/app/oracle/product/11.2.0/
tar  -xzvf db_1.tar.zip  .

方法二:
cp命令,同样使用root命令
cp -a选项表示递归cp和保留文件原始属性(时间戳、文件权限、所有权)
cp -a相当于cp -r -p -d 其中r表示递归备份,-p表示保留文件属性,-d表示原为软连接复制后也一样
cd /u01/app/oracle/product/11.2.0/
cp -a db_1/  db_1_$(date +%F)/

还原命令如下:
mv  db_1/  db_1_old/
mv db_1_$(date +%F)/  db_1


2)GI集群软件的ORACLE_HOME目录备份
方法一:
tar命令用root用户,经过验证,文件属性都是保持原有的
tar命令 
cd /u01/app/
tar  -czvf crs.tar.zip   ./crs

解压命令
cd /u01/app/
tar  -xzvf crs.tar.zip  .

方法二:
cp命令,同样使用root命令
cp -a选项表示递归cp和保留文件原始属性(时间戳、文件权限、所有权)
cp -a相当于cp -r -p -d 其中r表示递归备份,-p表示保留文件属性,-d表示原为软连接复制后也一样
cd /u01/app/
cp -a crs/  crs_$(date +%F)/

还原命令如下:
mv  crs/  crs_old/
mv crs_1_$(date +%F)/  crs

2、停止em代理,emctl stop dbconsole。(如果有使用em代理,一定要提前关闭掉,使用oracle用户)(所有节点都执行)

复制代码
su - oracle
emctl stop dbconsole

8、应用psu前需要关闭节点上所有数据库实例

复制代码
可以先关闭监听、检查数据库中的活动事务(确保无大事务活动)、然后kill掉所有节点的外部连接,然后在所有节点执行强制检查点
最后再尝试干净的immediate关闭数据库
su - oracle
srvctl stop database -d orcl

四、具体PSU安装步骤

(一)GI集群和Oracle数据库软件PSU补丁安装

前提:首先在集群中的一个节点执行下面的安装步骤,该节点完成以后。再在RAC剩余节点完成下面的步骤,直至所有节点都完成

1、环境变量设置,oracle用户和grid用户,将OPatch目录加入可执行环境变量中(两个节点都需要执行)

复制代码
grid用户
su - grid
echo "PATH=$PATH:$ORACLE_HOME/OPatch"   >> ~/.bash_profile
source ~/.bash_profile

oracle用户
su - oracle
echo "PATH=$PATH:$ORACLE_HOME/OPatch"   >> ~/.bash_profile
source ~/.bash_profile

2、opatch 版本准备,符合要求的opatch版本来安装psu补丁(两个节点都需要执行)

复制代码
提前上传符合的Opatch版本,存放至/u01/soft目录
Oracle用户下:
su - oracle
mv $ORACLE_HOME/OPatch  $ORACLE_HOME/OPatch_$(date +%F)
ls -ld $ORACLE_HOME/OPatch*

cd /u01/soft
unzip -q p6880880_112000_Linux-x86-64-11.2.0.3.36.zip -d $ORACLE_HOME
ls -ld $ORACLE_HOME/OPatch*

验证
$ORACLE_HOME/OPatch/opatch version


grid用户下:
su - grid
mv $ORACLE_HOME/OPatch  $ORACLE_HOME/OPatch_$(date +%F)
ls -ld $ORACLE_HOME/OPatch*

cd /u01/soft
unzip -q p6880880_112000_Linux-x86-64-11.2.0.3.36.zip -d $ORACLE_HOME
ls -ld $ORACLE_HOME/OPatch*

验证
$ORACLE_HOME/OPatch/opatch version

3、解压psu补丁包(两个节点都需要执行)

复制代码
su - grid
cd /u01/soft
unzip -q p33575261_112040_Linux-x86-64.zip

4、补丁冲突检查,针对新安装的集群环境,这一步骤可选,基本不会有补丁包冲突(两个节点都需要执行)

复制代码
grid用户
su - grid
cd /u01/soft/33575261
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
备注:检查成功,会显示pass通过显示如下
Prereq "checkConflictAgainstOHWithDetail" passed.

oracle用户
su - oracle
cd /u01/soft/33575261
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
备注:检查成功,会显示pass通过显示如下
Prereq "checkConflictAgainstOHWithDetail" passed.
5、GI集群软件psu补丁安装
复制代码
1)
root用户执行,注意unlock crs资源会关闭crs进程
/u01/app/crs/crs/install/rootcrs.pl -unlock

备注:其中/u01/app/crs为grid集群软件的ORACLE_HOME目录

2)
grid用户执行,安装OCW、ACFS、DB三个补丁集
su - grid
$ORACLE_HOME/OPatch/opatch napply -oh $ORACLE_HOME -local /u01/soft/33575261/32758914
$ORACLE_HOME/OPatch/opatch napply -oh $ORACLE_HOME -local /u01/soft/33575261/33112794
$ORACLE_HOME/OPatch/opatch napply -oh $ORACLE_HOME -local /u01/soft/33575261/33477185

至此GI集群软件的PSU补丁包安装完成,继续Oracle数据库软件PSU补丁集安装
6、Oracle数据库软件PSU补丁集安装,安装OCW和DB两个补丁集
复制代码
oracle用户执行
1)运行该补丁中数据库(DB)组件的预脚本
su - oracle
/u01/soft/33575261/32758914/custom/server/32758914/custom/scripts/prepatch.sh -dbhome $ORACLE_HOME
路径说明:<UNZIPPED_PATCH_LOCATION>/<GI_PSU_number>/<OCW Components_number>/custom/server/<OCW Components_number>/custom/scripts/prepatch.sh -dbhome <ORACLE_HOME>

2)开始安装安装OCW和DB两个补丁集
$ORACLE_HOME/OPatch/opatch napply -oh $ORACLE_HOME -local /u01/soft/33575261/32758914/custom/server/32758914
$ORACLE_HOME/OPatch/opatch napply -oh $ORACLE_HOME -local /u01/soft/33575261/33477185

3)运行该补丁中数据库(DB)组件的后脚本
/u01/soft/33575261/32758914/custom/server/32758914/custom/scripts/postpatch.sh -dbhome $ORACLE_HOME
路径说明:<UNZIPPED_PATCH_LOCATION>/<GI_PSU_number>/<OCW Components_number>/custom/server/<OCW Components_number>/custom/scripts/postpatch.sh -dbhome <ORACLE_HOME>

至此Oracle数据库软件的PSU补丁包安装完成

7、刷新参数配置和重启启动集群

复制代码
root用户执行
/u01/app/crs/rdbms/install/rootadd_rdbms.sh
/u01/app/crs/crs/install/rootcrs.pl -patch
备注:其中/u01/app/crs为grid集群软件的ORACLE_HOME目录

至此,一个集群节点PSU补丁包安装完毕

8、剩余集群节点,按上面步骤,继续完成PSU补丁安装,直至集群中所有节点都完成。

至此GI集群软件和Oracle数据库软件PSU补丁安装完毕,后续继续进行Oracle数据库数据字典升级。

(二)Oracle数据库数据字典升级

备注:由于是共享一个数据库,只需在一个节点上执行数据字典升级操作即可

1、数据字典更新升级

复制代码
脚本只需要在一个节点上执行,但需要将数据库定义为单机模式。
su - oracle
cd $ORACLE_HOME/rdbms/admin
sqlplus  / AS SYSDBA
startup nomount
alter system set cluster_database=false scope=spfile;
SHUTDOWN immediate;
STARTUP upgrade;
@catbundle.sql psu apply

输出如下:
Check the following log file for errors:
/u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_ORCL_APPLY_2026Jun15_17_30_50.log
具体的检查,可以查询下一步,确认没有异常错误,才能继续执行下面步骤

继续执行
@dbmsjdev.sql
exec dbms_java_dev.disable
上述数据字典升级过程会导致部分过程失效,需要编译无效对象
@utlrp.sql

2、检查和验证psu安装情况

复制代码
1)检查日志文件,排查升级过程中有无异常
类似如下:
cat /u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_ORCL_APPLY_2026Jun15_17_30_50.log | grep '^ORA-'
如果都是下面的常见错误,即可忽略
grep '^ORA-' /u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_ORCL_APPLY_2026Mar10_22_49_57.log
ORA-02303: cannot drop or replace a type with type or table dependents
ORA-02303: cannot drop or replace a type with type or table dependents
ORA-02303: cannot drop or replace a type with type or table dependents
ORA-02303: cannot drop or replace a type with type or table dependents
ORA-00955: name is already used by an existing object
ORA-00955: name is already used by an existing object
ORA-00955: name is already used by an existing object
ORA-00955: name is already used by an existing object
ORA-00942: table or view does not exist
ORA-04043: object DROP_AW_ELIST_ALL does not exist
ORA-02303: cannot drop or replace a type with type or table dependents
ORA-02303: cannot drop or replace a type with type or table dependents
ORA-02303: cannot drop or replace a type with type or table dependents
ORA-02303: cannot drop or replace a type with type or table dependents
ORA-00955: name is already used by an existing object
ORA-00955: name is already used by an existing object
ORA-00955: name is already used by an existing object
ORA-00955: name is already used by an existing object
ORA-00942: table or view does not exist

2)检测是否有失效的对象:
sqlplus "/as sysdba"
select owner,object_name
from dba_objects where status<> 'VALID'
minus 
select owner,object_name from t_invilid_objects;
#备注,没有输出结果表示升级前后没有新增的无效对象,属于期望的查询结果

SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
#输出结果为0表示数据库中没有无效对象,属于期望的查询结果


3)检查psu补丁集信息已经在数据库体现,可以查询:
sqlplus "/as sysdba"
set linesize 200
col ACTION_TIME format a30
col NAMESPACE format a10 
col action format a6
col version format a8
col BUNDLE_SERIES format a13
col comments format a19
col comp_id format a20
col comp_name format a40
col status format a10
select * from dba_registry_history;
select comp_id,comp_name,status from dba_registry;

输出结果:
ACTION_TIME                    ACTION NAMESPACE  VERSION          ID BUNDLE_SERIES COMMENTS
------------------------------ ------ ---------- -------- ---------- ------------- -------------------
24-AUG-13 12.03.45.119862 PM   APPLY  SERVER     11.2.0.4          0 PSU           Patchset 11.2.0.2.0
15-JUN-26 03.57.12.502571 PM   APPLY  SERVER     11.2.0.4          0 PSU           Patchset 11.2.0.2.0
15-JUN-26 05.31.13.673372 PM   APPLY  SERVER     11.2.0.4     220118 PSU           PSU 11.2.0.4.220118
最后一行表示已经安装成功最小的pus补丁、完成数据字典的升级

3、重启数据库,开启数据库中临时关闭的job任务,开启操作系统的定时任务,开启业务进行功能性简单测试

复制代码
1)重新正常打开
su - oracle
sqlplus "/as sysdba"
alter system set cluster_database=true scope=spfile;    //调整为集群模式,这一步一定要还原
SHUTDOWN IMMEDIATE;
exit
srvctl start database -d orcl

验证
sqlplus "as /as sysdba"
SQL> show parameter cluster
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean     TRUE

2)开启数据库中的job任务:
alter system set job_queue_processes =1000;

3)开启root用户和oracle用户下数据库相关的定时任务:
su - root
crontab -l
su - oracle
crontab -l

4)开启业务进行功能性简单测试

至此,完成集群RAC数据库PSU补丁安装!

五、PSU安装总结

复制代码
1、要提前安装Perl模块Env包(yum install perl-Env -y),否则会在第一步rootcrs.pl -unlock时报错,如下:
[root@hostrac1 ~]# /u01/app/crs/crs/install/rootcrs.pl -unlock
Can't locate Env.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /u01/app/crs/crs/install) at /u01/app/crs/crs/install/crsconfig_lib.pm line 703.
BEGIN failed--compilation aborted at /u01/app/crs/crs/install/crsconfig_lib.pm line 703.
Compilation failed in require at /u01/app/crs/crs/install/rootcrs.pl line 305.
BEGIN failed--compilation aborted at /u01/app/crs/crs/install/rootcrs.pl line 305.

2、linux 7上安装psu报如下错误:
/bin/ld: warning: -z lazyload ignored.
/bin/ld: warning: -z nolazyload ignored.
/bin/ld: warning: -z lazyload ignored.
/bin/ld: warning: -z nolazyload ignored.
/bin/ld: warning: -z lazyload ignored.
/bin/ld: warning: -z nolazyload ignored.
/bin/ld: warning: -z lazyload ignored.
/bin/ld: warning: -z nolazyload ignored.
/bin/ld: warning: -z lazyload ignored.
/bin/ld: warning: -z nolazyload ignored.
/bin/ld: warning: -z lazyload ignored.
/bin/ld: warning: -z nolazyload ignored.
/bin/ld: warning: -z lazyload ignored.
/bin/ld: warning: -z nolazyload ignored.
/bin/ld: warning: -z lazyload ignored.
/bin/ld: warning: -z nolazyload ignored.
/bin/ld: warning: -z lazyload ignored.
/bin/ld: warning: -z nolazyload ignored
DOC 2071922.1文章表示,可以忽略

3、下面错误可以忽略,官方提示:(这个是linux 6 和linux 7都会报错)
OPatch found the word "error" in the stderr of the make command.
Please look at this stderr. You can re-run this make command.
Stderr output:
chmod: changing permissions of '/u01/app/oracle/product/11.2.0/db_1/bin/extjobO': Operation not permitted
make: [iextjob] Error 1 (ignored)