1.数据库当前版本

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

2.上传11.2.0.4.160419补丁包并解压

[oraprod@ebsprod 11.2.0.4.16_patch]$ unzip p22502456_112040_Linux-x86-64\(1\).zip

 

3.查看补丁升级官方文档说明

[oraprod@ebsprod OPatch]$ firefox README.html

仔细阅读文档,了解升级前的注意事项。其中文档中要求OPatch版本在11.2.0.3.6以上应用这个补丁

You must use the OPatch utility version 11.2.0.3.6 or later to apply this patch. Oracle recommends that you use the latest released OPatch version for 11.2, which is available for download from My Oracle Support patch 6880880 by selecting the 11.2.0.0.0 release.

For information about OPatch documentation, including any known issues, see My Oracle Support Document 293369.1 OPatch documentation list.

4.查看OPatch版本,并升级OPatch

[oraprod@ebsprod OPatch]$ /u01/app/oracle/product/11.2.0/db_1/OPatch/opatch version                                

OPatch Version: 11.2.0.3.4

OPatch succeeded.

----版本过低,需要先升级OPatch版本,按照文档要求,官方找到p6880880包下载

 

----下载后,上传并解压

[oraprod@ebsprod OPatch]$ unzip p6880880_112000_Linux-x86-64.zip

[oracle@zyx OPatch]$ pwd

/install/OPatch

[oraprod@ebsprod OPatch]$ more README.txt     ------查看说明文档

 

How to install the utility:

---------------------------

To install this patch, Please extract the file "zipped file" using unzip or winzip,

depending upon the platform. You should extract the zip file directly under the

ORACLE_HOME. Please follow the following steps for extracting the zip file of OPatch.

(1) Please take a backup of $ORACLE_HOME/OPatch into a dedicated backup

location.

(2) Please remove the contents of $ORACLE_HOME/OPatch directory (Please do not

remove $ORACLE_HOME/OPatch directory itself)

(3) Please unzip the OPatch downloaded zip into $ORACLE_HOME directory.

To check the version of the opatch utility installed in the above step,

go to the $ORACLE_HOME/OPatch directory and run "opatch version".

 

----文档中说,可以先将$ORACLE_HOME/OPatch下的文件拷贝到其他路径备份,然后将下载的新版本覆盖该目录

----当然,如果不做备份,也可以直接将新版本解压覆盖$ORACLE_HOME/OPatch

[oraprod@ebsprod OPatch]$unzip p6880880_112000_Linux-x86-64.zip -d $ORACLE_HOME

Archive:  p6880880_112000_Linux-x86-64.zip

replace /u01/app/oracle/product/11.2.0/db_1/OPatch/jlib/oracle.opatch.classpath.jar? [y]es, [n]o, [A]ll, [N]one, [r]ename: A

 

----再次检查一下版本

[oraprod@ebsprod OPatch]$ ./opatch version
OPatch Version: 11.2.0.3.12
OPatch succeeded.
[oraprod@ebsprod OPatch]$

 

5.检测PSU补丁是否与当前环境存在冲突

[oraprod@ebsprod OPatch]$ /u01/app/oracle/product/11.2.0/db_1/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./


6.关闭所有db组件


 [oraprod@ebsprod OPatch]$ lsnrctl stop

SQL> shut immediate

 

7.开始升级

----在补丁目录下应用补丁

[oraprod@ebsprod OPatch]$ $ORACLE_HOME/OPatch/opatch apply

 

----应用补丁成功之后,执行catbundle.sql将补丁信息反射到数据库中,使数据库知道你最后一次打了什么补丁或者回滚了哪些补丁:

SQL> startup

SQL> @?/rdbms/admin/catbundle.sql psu apply

 

----完成后,启动监听

SQL> ho lsnrctl start PROD


8.查看升级后版本

SQL> l
  1* select action,comments from registry$history
SQL> /

ACTION                   COMMENTS
------------------------------ ------------------------------
VIEW INVALIDATE            view invalidation
UPGRADE                Upgraded from 11.1.0.7.0
APPLY                   Patchset 11.2.0.2.0
CPU                   CPUJul2007
UPGRADE                Upgraded from 10.2.0.3.0
UPGRADE                Upgraded from 11.1.0.6.0
APPLY                   PSU 11.2.0.4.160419

 

SQL> l
  1* select * from dba_registry_history
SQL> /

ACTION_TIME                ACTION        NAMESPACE  VERSION          ID BUNDLE_SERIES  COMMENTS
----------------------------------- --------------- ---------- ---------- ---------- -------------- --------------------------------------------------------------------------------
18-JUN-16 03.16.46.395527 PM        VIEW INVALIDATE                 8289601            view invalidation
18-JUN-16 03.23.14.877007 PM        UPGRADE        SERVER     11.2.0.4.0                Upgraded from 11.1.0.7.0
18-JUN-16 03.25.57.512451 PM        APPLY        SERVER     11.2.0.4        0 PSU        Patchset 11.2.0.2.0
23-JAN-08 04.07.02.182324 PM        CPU         SERVER     10.2.0.3.0    6079591            CPUJul2007
26-NOV-08 11.39.09.067225 PM        UPGRADE        SERVER     11.1.0.6.0                Upgraded from 10.2.0.3.0
22-JAN-09 04.34.49.320298 AM        UPGRADE        SERVER     11.1.0.7.0                Upgraded from 11.1.0.6.0
19-JUN-16 03.18.11.237328 PM        APPLY        SERVER     11.2.0.4       160419 PSU        PSU 11.2.0.4.160419

9.检测失效对象,编译

 select a.OWNER,count(1) from dba_objects a where a.status='INVALID' group by a.OWNER

 

----如果有失效对象,可以执行下面脚本编译

SQL> @?/rdbms/admin/utlrp.sql