最近生产上要给Oracle数据库打11g最新的补丁,这里先做一个测试记录一下。
Oracle数据库所有补丁的MOS文档ID 1922396.1下载地址:https://support.oracle.com/epmos/faces/DocContentDisplay?_afrLoop=242245405602967&id=1577380.1&_afrWindowMode=0&_adf.ctrl-state=zv36z4hoo_53这个下载需要有MOS账号
Oracle数据库的补丁有几种:PSU、SPU、CPU等,这次打的PSU24006111 (11.2.0.4.161018)
平台:OS Linux6.7 x86-64+Oracle 11.2.0.4.0单实例
升级方法已经在补丁包里的README.html文档里写的很清楚了,这里只是做个演示。
1、下载最新的的PSU包和最新的OPatch包,上传到服务器上
p24006111_112040_Linux-x86-64.zip
p6880880_112000_Linux-x86-64.zip
2、解压压缩包,并把OPatch替换原ORACLE_HOME里的OPatch目录
[oracle@rhel6 psu]$ unzip p24006111_112040_Linux-x86-64.zip
[oracle@rhel6 psu]$ unzip p6880880_112000_Linux-x86-64.zip
[oracle@rhel6 psu]$ ls -l |grep ^d
drwxrwxr-x 14 oracle oinstall 4096 Aug 26 21:56 24006111
drwxr-x--- 10 oracle oinstall 4096 Aug 18 2015 OPatch
[oracle@rhel6 psu]$ mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch_bak
[oracle@rhel6 psu]$ mv OPatch/ $ORACLE_HOME
3、配置OPatch的环境变量
[oracle@rhel6 psu]$ vi ~/.bash_profile
#添加
export PATH=$PATH:$ORACLE_HOME/OPatch
[oracle@rhel6 psu]$ source ~/.bash_profile
[oracle@rhel6 psu]$ which opatch
/u02/app/oracle/product/11.2.4/db1/OPatch/opatch
#查看当前数据库的补丁情况
[oracle@rhel6 psu]$ opatch lsinventory
Oracle Interim Patch Installer version 11.2.0.3.12
Copyright (c) 2016, Oracle Corporation. All rights reserved.
Oracle Home : /u02/app/oracle/product/11.2.4/db1
Central Inventory : /u01/app/oraInventory
from : /u02/app/oracle/product/11.2.4/db1/oraInst.loc
OPatch version : 11.2.0.3.12
OUI version : 11.2.0.4.0
Log file location : /u02/app/oracle/product/11.2.4/db1/cfgtoollogs/opatch/opatch2016-12-20_10-45-47AM_1.log
Lsinventory Output file location : /u02/app/oracle/product/11.2.4/db1/cfgtoollogs/opatch/lsinv/lsinventory2016-12-20_10-45-47AM.txt
--------------------------------------------------------------------------------
Local Machine Information::
Hostname: rhel6
ARU platform id: 226
ARU platform description:: Linux x86-64
Installed Top-level Products (1):
Oracle Database 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.
--------------------------------------------------------------------------------
OPatch succeeded.
4、升级前检查是否有冲突
[oracle@rhel6 psu]$ cd 24006111/
[oracle@rhel6 24006111]$ opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 11.2.0.3.12
Copyright (c) 2016, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u02/app/oracle/product/11.2.4/db1
Central Inventory : /u01/app/oraInventory
from : /u02/app/oracle/product/11.2.4/db1/oraInst.loc
OPatch version : 11.2.0.3.12
OUI version : 11.2.0.4.0
Log file location : /u02/app/oracle/product/11.2.4/db1/cfgtoollogs/opatch/opatch2016-12-20_10-49-53AM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
5、安装Patch包,单实例的数据库按如下方法打patch就可以了,如果是RAC则需要详细查看README.html
[oracle@rhel6 psu]$ cd 24006111/
[oracle@rhel6 24006111]$ opatch apply
Oracle Interim Patch Installer version 11.2.0.3.12
Copyright (c) 2016, Oracle Corporation. All rights reserved.
Oracle Home : /u02/app/oracle/product/11.2.4/db1
Central Inventory : /u01/app/oraInventory
from : /u02/app/oracle/product/11.2.4/db1/oraInst.loc
OPatch version : 11.2.0.3.12
OUI version : 11.2.0.4.0
Log file location : /u02/app/oracle/product/11.2.4/db1/cfgtoollogs/opatch/opatch2016-12-20_10-53-13AM_1.log
Verifying environment and performing prerequisite checks...
Prerequisite check "CheckActiveFilesAndExecutables" failed.
The details are:
Following executables are active :
/u02/app/oracle/product/11.2.4/db1/bin/oracle
/u02/app/oracle/product/11.2.4/db1/lib/libclntsh.so.11.1
UtilSession failed: Prerequisite check "CheckActiveFilesAndExecutables" failed.
Log file location: /u02/app/oracle/product/11.2.4/db1/cfgtoollogs/opatch/opatch2016-12-20_10-53-13AM_1.log
OPatch failed with error code 73
#打补丁报错,查看日志
[oracle@rhel6 24006111]$ more /u02/app/oracle/product/11.2.4/db1/cfgtoollogs/opatch/opatch2016-12-20_10-53-13AM_1.log
......
[Dec 20, 2016 10:53:21 AM] Following executables are active :
/u02/app/oracle/product/11.2.4/db1/bin/oracle
/u02/app/oracle/product/11.2.4/db1/lib/libclntsh.so.11.1
[Dec 20, 2016 10:53:21 AM] Prerequisite check "CheckActiveFilesAndExecutables" failed.
The details are:
Following executables are active :
/u02/app/oracle/product/11.2.4/db1/bin/oracle
/u02/app/oracle/product/11.2.4/db1/lib/libclntsh.so.11.1
......
#这个错误的意思是检测到有命令正在运行,不能进行升级,停止数据库和监听
[oracle@rhel6 24006111]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Dec 20 10:57:16 2016
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, OLAP, Data Mining and Real Application Testing options
sys@ORCL>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@ORCL>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@rhel6 24006111]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 20-DEC-2016 10:58:32
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The command completed successfully
[oracle@rhel6 24006111]$ ps -ef |grep ora
root 2361 2342 0 10:11 pts/0 00:00:00 su - oracle
oracle 2362 2361 0 10:11 pts/0 00:00:01 -bash
oracle 3409 2362 0 10:59 pts/0 00:00:00 ps -ef
oracle 3410 2362 0 10:59 pts/0 00:00:00 grep ora
#重新打补丁
[oracle@rhel6 24006111]$ opatch apply
Oracle Interim Patch Installer version 11.2.0.3.12
Copyright (c) 2016, Oracle Corporation. All rights reserved.
Oracle Home : /u02/app/oracle/product/11.2.4/db1
Central Inventory : /u01/app/oraInventory
from : /u02/app/oracle/product/11.2.4/db1/oraInst.loc
OPatch version : 11.2.0.3.12
OUI version : 11.2.0.4.0
Log file location : /u02/app/oracle/product/11.2.4/db1/cfgtoollogs/opatch/opatch2016-12-20_11-18-32AM_1.log
Verifying environment and performing prerequisite checks...
OPatch continues with these patches: 17478514 18031668 18522509 19121551 19769489 20299013 20760982 21352635 21948347 22502456 23054359 24006111
Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.
Provide your email address to be informed of security issues, install and
initiate Oracle Configuration Manager. Easier for you if you use your My
Oracle Support Email address/User Name.
Visit for details.
Email address/User Name:
You have not provided an email address for notification of security issues.
Do you wish to remain uninformed of security issues ([Y]es, [N]o) [N]: y
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u02/app/oracle/product/11.2.4/db1')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying sub-patch '17478514' to OH '/u02/app/oracle/product/11.2.4/db1'
......
Composite patch 24006111 successfully applied.
Log file location: /u02/app/oracle/product/11.2.4/db1/cfgtoollogs/opatch/opatch2016-12-20_11-18-32AM_1.log
OPatch succeeded.
6、升级数据字典并重新编译无效对象