一、OPatch工具检查及升级
OPatch工具包,在安装目录$ORACLE_HOME下,PSU安装升级,都是通过OPatch来完成的。PSU的升级安装对OPatch的版本有一定的要求,关于这一点,可以查看PSU的Readme文档。例如,要安装p26610246_112040_Linux-x86-64_gi814.zip,则必须要11.2.0.3.6或更高版本的OPatch。
1.1、确定当前系统的OPatch版本。
方法如下所示:
[oracle@Oracle11g OPatch]$
$ORACLE_HOME/OPatch/opatch version
OPatch Version: 11.2.0.3.4
OPatch succeeded.
显然,当前系统的OPatch版本不适合安装补丁p26610246_112040_Linux-x86-64_gi814.zip,要先升级OPatch,升级步骤如下:
1.2、备份当前版本的OPatch
cd $ORACLE_HOME
[oracle@Oracle11g db_1]$ tar cvf OPatch.tar OPatch/ # 也可以直接覆盖
[oracle@Oracle11g db_1]$ cd OPatch
[oracle@Oracle11g OPatch]$ rm -rf * --删除文件
1.3、下载对于版本的OPatch解压至$ORACLE_HOME目录下
然后授予执行权限。
[oracle@Oracle11g opatchs]$ cd /home/oracle/ -这个是存放补丁包的目录
-rw-r--r-- 1 oracle oinstall 95M 8月 1 13:33 p6880880_112000_Linux-x86-64.zip –安全漏洞的补丁包
-rw-r--r-- 1 oracle oinstall 724M 8月 1 13:36 p26610246_112040_Linux-x86-64_gi814.zip --升级opatch的补丁包
[oracle@Oracle11g opatchs]$ unzip p6880880_112000_Linux-x86-64.zip -d $ORACLE_HOME
--解压opatch升级包至$ORACLE_HOME目录下
1.4、重新验证OPatch版本
$ORACLE_HOME/OPatch/opatch version
OPatch Version: 11.2.0.3.16
OPatch succeeded.
二、应用补丁
2.1 数据库实例+监听正常关闭
shutdown immediate;
lsnrctl stop
2.2 应用补丁
[oracle@Oracle11g opatchs]$ cd /home/oracle/这是存放补丁包的路径
[oracle@Oracle11g opatchs]$ unzip p26610246_112040_Linux-x86-64_gi814.zip
……
篇幅很长,略
……
cd /home/oracle/26610246/26609445
oracle@otmadg:/home/oracle/26610246/26609445$ $ORACLE_HOME/OPatch/opatch apply
Oracle 中间补丁程序安装程序版本 11.2.0.3.16
版权所有 (c) 2019, Oracle Corporation。保留所有权利。
Oracle Home : /u01/app/oracle/product/11.2.0
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/11.2.0/oraInst.loc
OPatch version : 11.2.0.3.16
OUI version : 11.2.0.4.0
Log file location : /u01/app/oracle/product/11.2.0/cfgtoollogs/opatch/opatch2019-08-01_13-52-14下午_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 24732075 25869727 26609445
尚未提供电子邮件地址以接收有关安全问题的通知。
是否不希望收到有关安全问题 (是 [Y], 否 [N]) [N] 的通知: Y
请关闭本地系统上在此 ORACLE_HOME 之外运行的 Oracle 实例。
(Oracle 主目录 = '/u01/app/oracle/product/11.2.0')
本地系统是否已准备打补丁? [y|n]
y
User Responded with: Y
Backing up files...
Applying sub-patch '17478514' to OH '/u01/app/oracle/product/11.2.0'
正在为组件 oracle.rdbms, 11.2.0.4.0 打补丁...
OPatch 在 make 命令的 stderr 中发现单词 "warning"。
请查看此 stderr。可以重新运行此 make 命令。
Stderr output:
/usr/bin/ld: warning: -z lazyload ignored.
/usr/bin/ld: warning: -z nolazyload ignored.
OPatch 在 make 命令的 stderr 中发现单词 "warning"。
请查看此 stderr。可以重新运行此 make 命令。
Stderr output:
/usr/bin/ld: warning: -z lazyload ignored.
/usr/bin/ld: warning: -z nolazyload ignored.
Composite patch 26609445 successfully applied.
OPatch 会话已完成, 但出现警告。
Log file location: /u01/app/oracle/product/11.2.0/cfgtoollogs/opatch/opatch2019-08-01_13-52-14下午_1.log
OPatch completed with warnings.
三、运行catbundle.sql和utlrp.sql脚本,对于RAC环境,仅需要在一个节点上运行。
3.1 应用补丁到数据字典
catbundle.sql将补丁信息反射到数据库中,使数据库知道你最后一次打了什么补丁或者回滚了哪些补丁。
cd $ORACLE_HOME/rdbms/admin
sqlplus / as sysdba
STARTUP;
@catbundle.sql psu apply
exit
报错文件:
/u01/app/oracle/cfgtoollogs/catbundle/catbundle_PSU_CJOTM_APPLY_2019Aug01_14_12_54.log
3.2 编译无效对象
utlrp.sql脚本可以在数据库运行的状态下编译数据库中的invalid对象,Oracle建议在对数据库进行迁移、升级、降级后都运行一遍utlrp.sql以编译无效对象。
cd $ORACLE_HOME/rdbms/admin
sqlplus / as sysdba
SQL>@utlrp.sql
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2019-08-01 14:15:26
1 row selected.
DOC> The following query reports the number of objects that have compiled
DOC> with errors.
DOC>
DOC> If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
OBJECTS WITH ERRORS
-------------------
0
1 row selected.
DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#
ERRORS DURING RECOMPILATION
---------------------------
0
报错日志:
3.3 查看报错日志
查看 $ORACLE_HOME/cfgtoollogs/catbundle or
$ORACLE_BASE/cfgtoollogs/catbundle目录下的的日志文件是否记录错误。
catbundle_PSU_<database SID>_APPLY_<TIMESTAMP>.log
catbundle_PSU_<database SID>_GENERATE_<TIMESTAMP>.log
cd/u01/app/oracle/cfgtoollogs/catbundle
catbundle_PSU_CJOTM_APPLY_2019Aug01_14_12_54.log catbundle_PSU_CJOTM_GENERATE_2019Aug01_14_12_52.log
至此,本次patch过程结束。
四、确认升级后补丁信息
4.1 通过OPatch的信息库记录,可以看到补丁信息。
oracle@otmadg:/u01/app/oracle/cfgtoollogs/catbundle$ $ORACLE_HOME/OPatch/opatch lsinventory
Oracle 中间补丁程序安装程序版本 11.2.0.3.16
版权所有 (c) 2019, Oracle Corporation。保留所有权利。
Oracle Home : /u01/app/oracle/product/11.2.0
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/11.2.0/oraInst.loc
OPatch version : 11.2.0.3.16
OUI version : 11.2.0.4.0
Log file location : /u01/app/oracle/product/11.2.0/cfgtoollogs/opatch/opatch2019-08-01_14-22-28下午_1.log
Lsinventory Output file location : /u01/app/oracle/product/11.2.0/cfgtoollogs/opatch/lsinv/lsinventory2019-08-01_14-22-28下午.txt
--------------------------------------------------------------------------------
Local Machine Information::
Hostname: otmadg
ARU platform id: 226
ARU platform description:: Linux x86-64
已安装的顶级产品 (1):
Oracle Database 11g 11.2.0.4.0
此 Oracle 主目录中已安装 1 个产品。
中间补丁程序 (1) :
Patch 26609445 : applied on Thu Aug 01 13:59:49 CST 2019
Unique Patch ID: 21482382
Patch description: "Database Patch Set Update : 11.2.0.4.170814 (26609445)"
Created on 10 Aug 2017, 11:59:55 hrs PST8PDT
Sub-patch 25869727; "Database Patch Set Update : 11.2.0.4.170718 (25869727)"
Sub-patch 24732075; "Database Patch Set Update : 11.2.0.4.170418 (24732075)"
Sub-patch 24006111; "Database Patch Set Update : 11.2.0.4.161018 (24006111)"
Sub-patch 23054359; "Database Patch Set Update : 11.2.0.4.160719 (23054359)"
Sub-patch 22502456; "Database Patch Set Update : 11.2.0.4.160419 (22502456)"
Sub-patch 21948347; "Database Patch Set Update : 11.2.0.4.160119 (21948347)"
Sub-patch 21352635; "Database Patch Set Update : 11.2.0.4.8 (21352635)"
Sub-patch 20760982; "Database Patch Set Update : 11.2.0.4.7 (20760982)"
Sub-patch 20299013; "Database Patch Set Update : 11.2.0.4.6 (20299013)"
Sub-patch 19769489; "Database Patch Set Update : 11.2.0.4.5 (19769489)"
Sub-patch 19121551; "Database Patch Set Update : 11.2.0.4.4 (19121551)"
Sub-patch 18522509; "Database Patch Set Update : 11.2.0.4.3 (18522509)"
Sub-patch 18031668; "Database Patch Set Update : 11.2.0.4.2 (18031668)"
Sub-patch 17478514; "Database Patch Set Update : 11.2.0.4.1 (17478514)"
Bugs fixed:
17184721, 21538558, 16091637, 18092127, 17381384, 15979965, 16731148
16314254, 13837378, 18441944, 17835048, 13558557, 17201159, 25427662
17853498, 17246576, 18356166, 18681862, 18440047, 16875449, 20387265
21168487, 16220077, 16929165
OPatch succeeded.
oracle@otmadg:/u01/app/oracle/cfgtoollogs/catbundle$
4.1 执行opatch lspatches 查看已经安装的patch
$ORACLE_HOME/OPatch/opatch lspatches