最近做了一个安装11.2.0.4.180116补丁的实验,突然想起之前和同事讨论的一个问题:如何检查数据库安装补丁的版本,之前搜到的是去查dba_registry_history,有的说在操作系统中执行./opatch lspatches查看。就做了一个实验:

前提:本系统曾前后安装了 171017和180116版本补丁,但180116补丁已回退!!

1.1 首先检查opatch工具版本:

以oracle用户登录,验证opatch 工具版本。安装补丁11.2.0.4.180116所需最低opatch版本为11.2.0.3.6。

 [root@localhost ~]# su - oracle

[oracle@localhost ~]$ cd $ORACLE_HOME/OPatch

[oracle@localhost OPatch]$ ./opatch version

OPatch Version: 11.2.0.3.18

OPatch succeeded.

如果检查结果不满足,则需要升级opatch工具。若OPatch Version大于等于11.2.0.3.6则略过1.2节步骤 opatch工具版本升级。

1.2  升级opatch工具版本

以oracle用户登录,将opatch备份:

[root@localhost ~]# su - oracle

[oracle@localhost ~]$ cd $ORACLE_HOME

[oracle@localhost dbhome_1]$ pwd

/oracle/app/oracle/product/11.2.0/dbhome_1

[oracle@localhost dbhome_1]$ mv OPatch OPatch.bak

将下载的OPatch工具包p6880880_112000_Linux-x86-64.zip上传至/home/oracle目录,进行解压缩。

[root@localhost ~]# su - oracle

[oracle@localhost ~]$ unzip p6880880_112000_Linux-x86-64.zip -d $ORACLE_HOME/

重新验证OPatch工具包版本:

[oracle@localhost ~]$ cd $ORACLE_HOME

[oracle@localhost dbhome_1]$ cd OPatch

[oracle@localhost OPatch]$ ./opatch version

OPatch Version: 11.2.0.3.18

OPatch succeeded.

1.3   安装11.2.0.4.180116补丁包

1.3.1  上传并解压缩补丁包p26925576_112040_Linux-x86-64.zip

将下载的psu补丁p26925576_112040_Linux-x86-64.zip上传至/soft目录,进行解压缩。

[root@localhost ~]# su – oracle

[oracle@localhost ~]$ mkdir soft/  -- 若已存在该目录,则忽略该步骤

[oracle@localhost ~]$ cd soft/

 [oracle@localhost soft]$ unzip p26925576_112040_Linux-x86-64.zip

1.3.2  停止EM

[root@localhost ~]# su - oracle

[oracle@whf ~]$ emctl status dbconsole

Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0

Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.

https://rac1.localdomain:1158/em/console/aboutApplication

Oracle Enterprise Manager 11g is running.

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

Logs are generated in directory /u01/app/oracle/product/11.2.0/dbhome_1/rac1.localdomain_orcl/sysman/log

[oracle@rac1 ~]$ emctl stop dbconsole

Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0

Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.

https://rac1.localdomain:1158/em/console/aboutApplication

Stopping Oracle Enterprise Manager 11g Database Control ...

 ...  Stopped.

1.3.3  停数据库、监听

[root@localhost ~]# su - oracle

[oracle@localhost ~]$ sqlplus / as sysdba

SQL> shutdown immediate

SQL> exit

[oracle@localhost ~]$ lsnrctl stop

1.3.4  opatch apply安装

opatch apply命令需要使用oracle用户,进入补丁包所在目录后执行。

[root@localhost ~]# su – oracle

[oracle@localhost ~]$ cd soft/26925576/

[oracle@localhost 26925576]$ $ORACLE_HOME/OPatch/opatch apply

Oracle Interim Patch Installer version 11.2.0.3.18

Copyright (c) 2018, Oracle Corporation.  All rights reserved.

Oracle Home       : /oracle/app/oracle/product/11.2.0/dbhome_1

Central Inventory : /oracle/app/oraInventory

   from           : /oracle/app/oracle/product/11.2.0/dbhome_1/oraInst.loc

OPatch version    : 11.2.0.3.18

OUI version       : 11.2.0.4.0

Log file location : /oracle/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2018-02-20_20-42-25PM_1.log

Verifying environment and performing prerequisite checks...

OPatch continues with these patches:   26925576 

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 http://www.oracle.com/support/policies.html 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 = '/oracle/app/oracle/product/11.2.0/dbhome_1')

Is the local system ready for patching? [y|n]

y

User Responded with: Y

Backing up files...

Applying sub-patch '' to OH '/oracle/app/oracle/product/11.2.0/dbhome_1'

Patching component oracle.rdbms, 11.2.0.4.0...

Patching component oracle.rdbms.dbscripts, 11.2.0.4.0...

Patching component oracle.rdbms.rman, 11.2.0.4.0...

Patching component oracle.rdbms.rsf, 11.2.0.4.0...

Composite patch 26925576 successfully applied.

Log file location: /oracle/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2018-02-20_20-42-25PM_1.log

OPatch succeeded.

1.3.5  起数据库、监听、EM

[root@localhost ~]# su - oracle

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Feb 20 20:46:18 2018

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup

SQL> exit

[oracle@localhost ~]$ lsnrctl start

[oracle@localhost ~]$ emctl start dbconsole

1.3.6 将升级信息写入数据库

为了验证数据库补丁如何查看,暂时先不写入数据库,依次查看dba_registry_history和opatch lspatches版本

本系统曾前后安装了 171017和180116版本补丁,但180116补丁已回退):

SQL> col action_time for a32
SQL> col action for a10
SQL> col namespace for a10
SQL> col version for a10
SQL> col BUNDLE_SERIES for a10
SQL> col comments for a30
SQL> set lin 200
SQL>
SQL> select * from dba_registry_history; ACTION_TIME ACTION NAMESPACE VERSION ID BUNDLE_SER COMMENTS
-------------------------------- ---------- ---------- ---------- ---------- ---------- ------------------------------
24-AUG-13 12.03.45.119862 PM APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
15-NOV-17 03.36.44.541274 PM APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
20-FEB-18 07.17.09.603021 PM APPLY SERVER 11.2.0.4 171017 PSU PSU 11.2.0.4.171017
20-FEB-18 08.48.39.212321 PM APPLY SERVER 11.2.0.4 180116 PSU PSU 11.2.0.4.180116
20-FEB-18 09.06.56.276322 PM ROLLBACK SERVER 11.2.0.4 180116 PSU PSU 11.2.0.4.180116
20-FEB-18 09.07.15.512282 PM APPLY SERVER 11.2.0.4 171017 PSU PSU 11.2.0.4.171017 6 rows selected.

查看opatch lapatches版本:

[oracle@localhost ~]$ cd $ORACLE_HOME/OPatch
[oracle@localhost OPatch]$ ./opatch lspatches
26925576;Database Patch Set Update : 11.2.0.4.180116 (26925576) OPatch succeeded.

故说明使用./opatch lspatches只能查看系统安装补丁版本,但不意味着数据库应用的版本信息,数据库应用的版本需使用dba_registry_history查看。

为验证说明,进行将升级信息写入数据库:

[oracle@localhost ~]$ sqlplus / as sysdba
SQL> @?/rdbms/admin/catbundle.sql psu apply 修复无效对象
SQL> @?/rdbms/admin/utlrp.sql

再次查看dba_registry_history和opatch lspatches版本:

SQL> col action_time for a32
SQL> col action for a10
SQL> col namespace for a10
SQL> col version for a10
SQL> col BUNDLE_SERIES for a10
SQL> col comments for a30
SQL> set lin 200
SQL>
SQL> select * from dba_registry_history; ACTION_TIME ACTION NAMESPACE VERSION ID BUNDLE_SER COMMENTS
-------------------------------- ---------- ---------- ---------- ---------- ---------- ------------------------------
24-AUG-13 12.03.45.119862 PM APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
15-NOV-17 03.36.44.541274 PM APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
20-FEB-18 07.17.09.603021 PM APPLY SERVER 11.2.0.4 171017 PSU PSU 11.2.0.4.171017
20-FEB-18 08.48.39.212321 PM APPLY SERVER 11.2.0.4 180116 PSU PSU 11.2.0.4.180116
20-FEB-18 09.06.56.276322 PM ROLLBACK SERVER 11.2.0.4 180116 PSU PSU 11.2.0.4.180116
20-FEB-18 09.07.15.512282 PM APPLY SERVER 11.2.0.4 171017 PSU PSU 11.2.0.4.171017
22-FEB-18 01.09.06.899587 AM APPLY SERVER 11.2.0.4 180116 PSU PSU 11.2.0.4.180116 7 rows selected.
SQL> !
[oracle@localhost ~]$ cd $ORACLE_HOME/OPatch
[oracle@localhost OPatch]$ ./opatch lspatches
26925576;Database Patch Set Update : 11.2.0.4.180116 (26925576) OPatch succeeded.

验证无误。就此补丁也已安装完毕。

2.1   补丁回退

2.1.1  关闭数据库

[root@localhost ~]# su - oracle

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Feb 20 20:53:00 2018

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

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> 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@localhost ~]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 20-FEB-2018 20:54:52

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))

The command completed successfully

2.1.2  回退操作

[root@localhost ~]# su - oracle

[oracle@localhost ~]$ $ORACLE_HOME/OPatch/opatch rollback -id 26925576

Oracle Interim Patch Installer version 11.2.0.3.18

Copyright (c) 2018, Oracle Corporation.  All rights reserved.

Oracle Home       : /oracle/app/oracle/product/11.2.0/dbhome_1

Central Inventory : /oracle/app/oraInventory

   from           : /oracle/app/oracle/product/11.2.0/dbhome_1/oraInst.loc

OPatch version    : 11.2.0.3.18

OUI version       : 11.2.0.4.0

Log file location : /oracle/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2018-02-20_20-56-38PM_1.log

Patches will be rolled back in the following order:

   26925576

The following patch(es) will be rolled back: 26925576 

Sub-patches of a composite series are being rolled back. The system will be returned to a state where 17478514,18031668,18522509,19121551,19769489,20299013,20760982,21352635,21948347,22502456,23054359,24006111,24732075,25869727,26609445,26392168 and all its fixes will still remain, because the patch(es) were installed before patch(es) 26925576 were applied.

The following bug fixes will be removed: 26910644,21641760,24570598,22809871,22465352,21142837,16756406,27053456,21174504,23003979,20513399,25897615,21795111,26569225,21354456,25764020,20671094,20717359,21629064,18090142,24835538,21380789,21422580,19475971,24717859,18948177,20860659,20598042,21172913,20031873,20324049,23007241,25165496,19174430

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.

(Oracle Home = '/oracle/app/oracle/product/11.2.0/dbhome_1')

Is the local system ready for patching? [y|n]

y

User Responded with: Y

Rolling back patch 26925576...

RollbackSession rolling back interim patch '' from OH '/oracle/app/oracle/product/11.2.0/dbhome_1'

Patching component oracle.rdbms, 11.2.0.4.0...

Patching component oracle.rdbms.dbscripts, 11.2.0.4.0...

Patching component oracle.rdbms.rman, 11.2.0.4.0...

Patching component oracle.rdbms.rsf, 11.2.0.4.0...

RollbackSession removing interim patch '' from inventory

Log file location: /oracle/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2018-02-20_20-56-38PM_1.log

OPatch succeeded. 

若执行了1.3.6将升级信息写入数据库操作,则还需执行以下操作:

[oracle@localhost ~]$ [oracle@localhost admin]$ ls|grep catbundle_PSU_

catbundle_PSU_MYDB_APPLY.sql    -- <连接数据库后需运行该脚本!>

catbundle_PSU_MYDB_ROLLBACK.sql

[oracle@localhost admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Feb 20 21:01:07 2018

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  830930944 bytes

Fixed Size                  2257800 bytes

Variable Size             503319672 bytes

Database Buffers          318767104 bytes

Redo Buffers                6586368 bytes

Database mounted.

Database opened.

SQL> @catbundle_PSU_MYDB_ROLLBACK.sql

SQL> exit

[oracle@localhost admin]$ lsnrctl start

2.1.3  回退检验

[root@localhost ~]# su - oracle

[oracle@localhost ~]$ $ORACLE_HOME/OPatch/opatch lspatches

26392168;Database Patch Set Update : 11.2.0.4.171017 (26392168)

OPatch succeeded.

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Feb 20 21:10:57 2018

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

[oracle@whf admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 16 21:15:00 2017

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

SQL> col action_time for a32

SQL> col action for a10

SQL> col namespace for a10

SQL> col version for a10

SQL> col BUNDLE_SERIES for a10

SQL> col comments for a30

SQL> set lin 220

SQL> select * from dba_registry_history;


ACTION_TIME ACTION NAMESPACE VERSION ID BUNDLE_SER COMMENTS
-------------------------------- ---------- ---------- ---------- ---------- ---------- ------------------------------
24-AUG-13 12.03.45.119862 PM APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
15-NOV-17 03.36.44.541274 PM APPLY SERVER 11.2.0.4 0 PSU Patchset 11.2.0.2.0
20-FEB-18 07.17.09.603021 PM APPLY SERVER 11.2.0.4 171017 PSU PSU 11.2.0.4.171017
20-FEB-18 08.48.39.212321 PM APPLY SERVER 11.2.0.4 180116 PSU PSU 11.2.0.4.180116
20-FEB-18 09.06.56.276322 PM ROLLBACK SERVER 11.2.0.4 180116 PSU PSU 11.2.0.4.180116
20-FEB-18 09.07.15.512282 PM APPLY SERVER 11.2.0.4 171017 PSU PSU 11.2.0.4.171017
22-FEB-18 01.09.06.899587 AM APPLY SERVER 11.2.0.4 180116 PSU PSU 11.2.0.4.180116
22-FEB-18 01.31.12.966611 AM APPLY SERVER 11.2.0.4 180116 PSU PSU 11.2.0.4.180116
22-FEB-18 01.41.03.225433 AM ROLLBACK SERVER 11.2.0.4 180116 PSU PSU 11.2.0.4.180116
22-FEB-18 01.41.23.227214 AM APPLY SERVER 11.2.0.4 171017 PSU PSU 11.2.0.4.171017

Oracle安装11.2.0.4.180116补丁及如何检查数据库安装补丁的更多相关文章

  1. RHEL6.5安装11.2.0.3 RAC并打补丁

    [TOC] 一,主机配置 1.修改hosts文件(两节点) #127.0.0.1 localhost localhost.localdomain localhost4 localhost4.local ...

  2. solaris X86-64下一个ORACLE战斗11.2.0.3.8在一波折叠补丁

    solaris X86-64下一个ORACLE战斗11.2.0.3.8补丁: 正确的步骤: 1.BUG6880880 .OPATCH补丁 2.BUG16902043.11.2.0.3.8补丁 情感是练 ...

  3. Oracle 11.2.0.4.0 Dataguard部署和日常维护(1)-数据库安装篇

    本次测试环境 系统版本 CentOS release 6.8 主机名 ec2t-userdata-01 ec2t-userdata-01 IP地址 10.189.102.118 10.189.100. ...

  4. ORACLE RAC 11.2.0.4 CentOS release 6.9 静默安装1.0版本

    RAC11.2.0.4静默安装 1.0版本,20180613 #本文档IP地址使用X隐藏,个人可按照自己的当前环境IP进行适当修改 1. 清除原环境中的单实例软件 #清除原环境: 删除/etc/ora ...

  5. oracle之 11.2.0.4 bbed安装

    一. bbed安装: 1.ORACLE 11G下安装BBED,需要从ORACLE 10G中复制三个包 sbbdpt.o .ssbbded.o 并将两个文件移到$ORACLE_HOME/rdbms/li ...

  6. 单机 Oracle 11g(11.2.0.4)手动打补丁PSU(11.2.0.4.8)

    环境说明:database : 11.2.0.4 x64os: centos6.7 x64 准备内容:OPatch : p6880880_112000_Linux-x86-64.zipDB PSU : ...

  7. Red Hat Enterprise Linux 6上安装Oracle 11G(11.2.0.4.0)缺少pdksh包的问题

    RHEL 6上安装Oracle 11G警告缺少pdksh包 前言 相信很多刚刚接触学习Oracle的人,在RHEL6上安装11.2.0.3 or 11.2.0.4这两个版本的时候, 都遇到过先决条件检 ...

  8. RHEL7或CentOS7安装11.2.0.4 RAC碰到的问题

    RHEL7或CentOS7安装11.2.0.4 RAC碰到的问题 随着Linux 版本的普及,但Oracle数据库主流版本仍是11gR2, 的支持不很完美,在Linux 上安装会遇到几处问题,以此记录 ...

  9. opatch auto 安装11.2.0.4.20190115 PSU遇到 OUI-67133: Execution of PRE script failed,with returen value 1 报错

    AIX 7.2 下Oracle 11.2.0.4  RAC数据库root用户在使用 /u01/app/11.2.0/grid/OPatch/opatch auto /soft/28813878 -oc ...

随机推荐

  1. 第一次C语言实验报告

    一.实验题目,设计思路,实现方法 实验四4-2-9三个数由小到大输出,要求比较三数大小并按顺序输出.运用穷举法列举所有可能性再对应输出.运用多分支结构. 实验四4-2-4 三天打鱼两天晒网,运用循环结 ...

  2. Angular21 动态绑定CSS样式

    1 需求 在前端开发中通常需要动态对某些元素的样式进行动态设定,传统的CSS绑定分为CSS类绑定和Style样式绑定:在Angular中利用相关指令同样可以完成CSS类绑定和CSS样式绑定 2 内置指 ...

  3. Asp.Net Core轻松入门之WebHost的配置

    在本篇文章中,我来讲一讲如何利用WebHost来加载配置文件和设置启动的Url 在前面的文章中讲过,ASP.Net Core应用程序会自动加载appsettings.json中的配置文件,那么如果配置 ...

  4. 小程序中点击input控件键盘弹出时placeholder文字上移

    最近做的一个小程序项目中,出现了点击input控件键盘弹出时placeholder文字上移,刚开始以为是软键盘弹出布局上移问题是传说中典型的fixed 软键盘顶起问题,因此采纳了网上搜到的" ...

  5. PhotoShop制作简单的文字动画--多媒体技术与应用

    下面是最终实现的效果图: 1.新建图像,设置图像属性如下所示. 2.使用[横排文字工具]在背景图像上打上文字内容 3.[图层]——>[图层式样]——>[渐变叠加] 出现“图层样式”面板 4 ...

  6. Python爬虫之模拟登录微信wechat

    不知何时,微信已经成为我们不可缺少的一部分了,我们的社交圈.关注的新闻或是公众号.还有个人信息或是隐私都被绑定在了一起.既然它这么重要,如果我们可以利用爬虫模拟登录,是不是就意味着我们可以获取这些信息 ...

  7. RobotFramework自动化测试框架-常用断言关键字

    断言关键字 描述 Should Be Empty 判断是否为空,如果不为空,执行失败,示例: ${value} Set Variable Hello Should Be Empty ${value} ...

  8. xshell无法登录阿里云服务器

    1. 现象 a. 使用xshell无法登录服务器 b. 查看sshd服务 c. 不同公网ip的电脑正常登陆 2. 解决方案 a. 不同公网ip可以登录,断定是ip被黑名单,联系阿里云服务,把公网ip加 ...

  9. Keras官方中文文档:函数式模型API

    \ 函数式模型接口 为什么叫"函数式模型",请查看"Keras新手指南"的相关部分 Keras的函数式模型为Model,即广义的拥有输入和输出的模型,我们使用M ...

  10. Educational Codeforces Round 37

    Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...