Oracle 11g单库环境PSU补丁安装

本文以linux7、Oracle 11.2.0.4版本、33575261 PSU补丁包安装为例,其它linux版本、oracle 11g版本、其它psu补丁包安装步骤都基本类似

本文中Opatch补丁包和PSU补丁包都上传至/u01/psu目录下

一、步骤简述

复制代码
安装方式有两类:
A类、已经安装Oracle数据库的服务器上,按以下步骤完成PSU补丁安装
(1)安装前准备
1、考虑主机上是否有定时任务(例如备份任务这些,建议期间停止这些定时任务)
2、oracle数据库中的无效对象,尽量提前处理,因为数据库中的数据字典升级以后,需要重新编译所有无效的对象,如果库中存在大量无效对象,会影响整个补丁安装过程
3、提前快照一份无效对象清单,psu安装前后进行比对,确保整个psu升级过程,没有产生新的无效对象
4、数据库组件检查,用于安装前后对比
5、临时关闭数据库中的job
6、关闭数据库(最好immediate干净方式)
7、可选项,如果是非常重要的核心数据库,建议重新打开数据库,开启数据库闪回功能,建立闪回还原点,然后再次immediate方式关闭数据库。该步骤主要是预防,如果数据库字典升级出现异常,可以快速闪回至还原点,快速将数据库还原至升级前的状态。
8、备份Oracle数据库软件的ORACLE_HOME目录
9、opatch 版本准备,符合要求的opatch版本来安装psu补丁
(2)正式安装
1、环境变量设置
2、上传和解压psu补丁包
3、补丁冲突检查
4、dbconsole确认,如果活动,关闭即可
5、psu补丁安装
6、psu补丁安装总结
7、安装PSU补丁后,更新升级数据字典
8、检查和验证psu安装情况
9、重启监听
10、重启数据库,开启业务进行功能性简单测试
11、安装该补丁常见的错误了解,查询readme.html中最后部分

B类、刚新建Oracle数据库的服务器上,建议按以下步骤完成PSU补丁安装
1、安装数据库软件
2、安装psu补丁(安装数据库前将补丁安装,后续不需要运行数据字典升级脚本了)
3、安装数据库

二、已经安装Oracle数据库的服务器上,PSU补丁安装

备注:oracle数据库已经创建,而非仅仅只是安装Oracle数据库软件

(1)安装前准备

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干净方式)

关闭数据库的方式,可以参考我的文章《Oracle单库环境下计划内启停数据库的步骤》

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

8、备份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  .

备注:操作系统oracle用户执行tar命令,可能报错
[oracle@localhost app]$ tar  -cf db_1.tar   ./db_1      
tar: ./db_1/bin/nmb: Cannot open: Permission denied
tar: ./db_1/bin/nmhs: Cannot open: Permission denied
tar: ./db_1/bin/nmo: Cannot open: Permission denied
tar: Exiting with failure status due to previous errors


方法二:
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

9、opatch 版本准备,符合要求的opatch版本来安装psu补丁

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

cd /u01/psu
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

(2)正式安装psu

前提说明

复制代码
以33575261补丁包为例,包含GI和ORACLE的补丁
解压后,通过阅读readme.html文件(可以windows下解压查看),如下:
Patch Number  Description                                      Applicable Homes
33477185      DB PSU 11.2.0.4.220118                           Both DB homes and Grid home
32758914      OCW PATCH SET UPDATE 11.2.0.4.210720             Both DB homes and Grid home
33112794      ACFS PATCH SET UPDATE 11.2.0.4.210720Footnote 1  Only Grid home
单库环境下,只需要安装 33477185这个DB PSU补丁包

1、环境变量设置

复制代码
su - oracle
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
备注:主要将OPatch目录加入可执行环境变量中

2、解压psu补丁包

复制代码
ls -ltr /u01/psu
total 1475976
-rw-r--r-- 1 oracle oinstall 1386494818 Oct 16 14:19 p33575261_112040_Linux-x86-64.zip
-rw-r--r-- 1 oracle oinstall  124902830 Oct 16 14:19 p6880880_112000_Linux-x86-64-11.2.0.3.36.zip

cd /u01/psu
unzip -q p33575261_112040_Linux-x86-64.zip

3、补丁冲突检查

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

4、dbconsole确认,如果活动,关闭即可

复制代码
检查dbconsole
emctl status dbconsole

关闭dbconsole
emctl stop dbconsole

5、psu补丁安装

复制代码
cd /u01/psu/33575261/33477185
opatch apply
安装过程中,会提示二个交互式回答,都输入y即可
y
y
备注:如果按照时出现Prerequisite check "CheckSystemCommandAvailable" failed.错误,操作系统按照如下包,再继续执行psu补丁包安装即可
yum install -y psmisc

安装完毕验证
opatch lsinv

输出显示类似如下:
Patch description:  "Database Patch Set Update : 11.2.0.4.220118 (33477185)"
   Created on 15 Dec 2021, 07:23:11 hrs UTC
Sub-patch  33128584; "Database Patch Set Update : 11.2.0.4.211019 (33128584)"
Sub-patch  32758711; "Database Patch Set Update : 11.2.0.4.210720 (32758711)"
......

6、psu补丁安装总结:

复制代码
1)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文章表示,可以忽略

2)下面错误可以忽略,官方提示:(这个是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)

3)下面这个不是报错,这个ORACLE数据库软件没有安装组件,只是一个提示,因此该组件对应的补丁无需安装
Applying sub-patch '26392168' to OH '/u01/app/oracle/product/11.2.0/db_1'
ApplySession: Optional component(s) [ oracle.oid.client, 11.2.0.4.0 ]  not present in the Oracle Home or a higher version is found.

7、安装PSU补丁后,更新升级数据字典,如下:

复制代码
cd $ORACLE_HOME/rdbms/admin
sqlplus "/as sysdba"
startup
@catbundle.sql psu apply

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

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

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

复制代码
1)检查日志文件,排查升级过程中有无异常
类似如下:
cat /u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_ORCL_APPLY_2026Mar10_22_49_57.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
select * from dba_registry_history;
输出结果:
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
09-MAR-26 10.59.04.522728 PM   APPLY  SERVER     11.2.0.4          0 PSU           Patchset 11.2.0.2.0
10-MAR-26 10.50.12.863747 PM   APPLY  SERVER     11.2.0.4     220118 PSU           PSU 11.2.0.4.220118
最后一行表示已经安装成功最小的pus补丁、完成数据字典的升级

9、重启监听

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

复制代码
数据库中的job任务:
alter system set job_queue_processes =1000;
开启root用户和oracle用户下数据库相关的定时任务:
su - root
crontab -l
su - oracle
crontab -l

11、安装该补丁常见的错误了解,查询readme.html中最后部分

复制代码
Known Issues
For information about OPatch issues, see My Oracle Support Document 293369.1 Primary Note For OPatch.
For issues documented after the release of this PSU, see My Oracle Support Document 2816983.1  Oracle Database Patch Set Update 11.2.0.4.220118 Known Issues.
Other issues are as follows.

Issue 1
The following ignorable errors may be encountered while running the catbundle.sql script or its rollback script: 
ORA-00942: table or view does not exist
ORA-00955: name is already used by an existing object
ORA-01430: column being added already exists in table
ORA-01432: public synonym to be dropped does not exist
ORA-01434: private synonym to be dropped does not exist
ORA-01435: user does not exist
ORA-01917: user or role 'XDB' does not exist
ORA-01920: user name '<user-name>' conflicts with another user or role name
ORA-01921: role name '<role name>' conflicts with another user or role name
ORA-01927: cannot REVOKE privileges you did not grant
ORA-01952: system privileges not granted to 'WKSYS'
ORA-02303: cannot drop or replace a type with type or table dependents
ORA-02443: Cannot drop constraint - nonexistent constraint
ORA-04043: object <object-name> does not exist
ORA-06512: at line <line number>. (That is, if ORA-06512 follows any of preceding errors, it can be safely ignored.)
ORA-14452: attempt to create, alter or drop an index on temporary table already in use
ORA-29809: cannot drop an operator with dependent objects
ORA-29830: operator does not exist
ORA-29832: cannot drop or replace an indextype with dependent indexes
ORA-29844: duplicate operator name specified 
ORA-29931: specified association does not exist

Issue 2
Warnings may be returned during the re-link phase of 33477185 . These warnings may be ignored. 
warning: overriding commands for target `nmosudo'
warning: ignoring old commands for target `nmosudo'

See the following document for additional information.
Document 1562458.1 Relinking the DB Control 11.2.0.3 Agent Displays a Warning Message "overriding commands for target 'nmosudo'"  

。。。省去部分非linux平台可能出现的报错

Issue 6
If Oracle Database Vault is enabled, the following error can occur during the execution of the Post Installation or Deinstallation steps:
initjvmaux.drop_sros();
EXECUTE IMMEDIATE 'create or replace java system';
...
ORA-01031: insufficient privileges
ORA-06512: at "SYS.INITJVMAUX", line 535
ORA-06512: at line 3

To recover from this issue, see the following My Oracle Support Document 1935120.1 ORA-01031 during Post Install / De-install for Database PSU or OJVM PSU with Data Vault installed 

Issue 7
When trying to install the Oracle Database Patch Set Update 11.2.0.4.220118, OPatch reports:
/refresh/home/app/oracle/product/11.2.0/client_1/rdbms/admin/orasdkbase_shrept.lst: No such file or directory
/usr/bin/ld: cannot open linker script file
/refresh/home/app/oracle/product/11.2.0/client_1/rdbms/admin/liborasdkbase.def: No such file or directory
  collect2: ld returned 1 exit status
/refresh/home/app/oracle/product/11.2.0/client_1/bin/genorasdksh: Failed to link liborasdkbase.so.11.1
make: *** [liborasdkbase] Error 1
Cause: BUG 24331924 - MISSING LIBORASDKBASE FROM 11.2.0.4 RUNTIME CLIENT
Solution: Follow these steps:
1.Apply patch 24331924.
2.Re-apply the PSU.

Issue 8
Problem: The permission of the library file $ORACLE_HOME/lib/libsqlplus.so may change from 644 to 640, after applying this PSU patch. 
You may first notice this issue from the following error encountered from SQL*Plus through non-oracle user:
ld.so.1: sqlplus: fatal: ?../lib/libsqlplus.so: Permission denied
This issue is discussed further in My Oracle Support Document 2201729.1. This issue is fixed in a future release Oracle Database 12c release 2 (12.2).
Workaround: For earlier versions, do the following:
Change the permission of the library file $ORACLE_HOME/lib/libsqlplus.so back to 644 to allow the non-oracle users and application users to connect.
Otherwise, apply the patch 22730454 on top of this PSU release.

至此,完成Oracle数据库PSU补丁包安装

三、刚新建Oracle数据库的服务器上,建议按以下步骤完成PSU补丁安装

1、安装数据库软件

2、安装psu补丁(安装数据库前将补丁安装,后续不需要运行数据字典升级脚本了)

复制代码
由于数据库软件刚刚新建,因此第一种方式中很多步骤都可以省去,例如关闭定时任务、关闭job、备份目录等等这些都不需要执行,只需简单执行如下几步:
1、opatch 版本准备,符合要求的opatch版本来安装psu补丁
2、环境变量设置
3、上传和解压psu补丁包
4、补丁冲突检查
5、psu补丁安装
6、psu补丁安装总结

具体详细步骤如下:
1、opatch 版本准备,符合要求的opatch版本来安装psu补丁
提前上传符合的Opatch版本,存放至/u01/psu目录
su - oracle
mv $ORACLE_HOME/OPatch  $ORACLE_HOME/OPatch_$(date +%F)
ls -ld $ORACLE_HOME/OPatch*

cd /u01/psu
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

2、环境变量设置
su - oracle
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
备注:主要将OPatch目录加入可执行环境变量中

3、上传和解压psu补丁包
ls -ltr /u01/psu
total 1475976
-rw-r--r-- 1 oracle oinstall 1386494818 Oct 16 14:19 p33575261_112040_Linux-x86-64.zip
-rw-r--r-- 1 oracle oinstall  124902830 Oct 16 14:19 p6880880_112000_Linux-x86-64-11.2.0.3.36.zip

cd /u01/psu
unzip -q p33575261_112040_Linux-x86-64.zip

4、补丁冲突检查
cd /u01/psu/33575261/33477185
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
备注:检查成功,会显示pass通过显示如下
Prereq "checkConflictAgainstOHWithDetail" passed.

5、psu补丁安装
cd /u01/psu/33575261/33477185
opatch apply
安装过程中,会提示二个交互式回答,都输入y即可
y
y
备注:如果按照时出现Prerequisite check "CheckSystemCommandAvailable" failed.错误,操作系统按照如下包,再继续执行psu补丁包安装即可
yum install -y psmisc

安装完毕验证
opatch lsinv

输出显示类似如下:
Patch description:  "Database Patch Set Update : 11.2.0.4.220118 (33477185)"
   Created on 15 Dec 2021, 07:23:11 hrs UTC
Sub-patch  33128584; "Database Patch Set Update : 11.2.0.4.211019 (33128584)"
Sub-patch  32758711; "Database Patch Set Update : 11.2.0.4.210720 (32758711)"

6、psu补丁安装总结
1)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文章表示,可以忽略

2)下面错误可以忽略,官方提示:(这个是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)

3)下面这个不是报错,这个ORACLE数据库软件没有安装组件,只是一个提示,因此该组件对应的补丁无需安装
Applying sub-patch '26392168' to OH '/u01/app/oracle/product/11.2.0/db_1'
ApplySession: Optional component(s) [ oracle.oid.client, 11.2.0.4.0 ]  not present in the Oracle Home or a higher version is found.

完成PSU补丁包安装!

3、安装数据库

由于前面软件已经安装好PSU补丁包,更新升级数据字典创建数据库过程中会自动完成。

相关推荐
Java面试题总结2 小时前
PostgreSQL表名超长踩坑记
数据库·postgresql
泯仲2 小时前
从零起步学习MySQL 第三章:DML语句定义及常见用法示例
数据库·学习·mysql
難釋懷2 小时前
Redis主从-主从数据同步原理
前端·数据库·redis
霖霖总总3 小时前
[Redis小技巧7]Redis Bitmaps 深度解析:从原理到用户签到实战
数据库·redis·缓存
Keanu-3 小时前
Redis 安装与部署
数据库·redis
我爱小疯喵喵3 小时前
2 常用数据库命令行操作
数据库
七夜zippoe3 小时前
Docker容器化实战:核心概念、镜像制作与多阶段构建全解析
java·jvm·数据库·docker·oracle·容器化
跟着珅聪学java3 小时前
Electron 精美菜单设计
运维·前端·数据库
xcLeigh3 小时前
Oracle 替换工程实践深度解析:金仓数据库破解 PL/SQL 兼容与跨交易日数据一致性核心难题
数据库·sql·oracle·数据迁移·金仓·kingbasees