Oracle - 数据库打补丁实践

打印 上一主题 下一主题

主题 549|帖子 549|积分 1647

原文:https://www.cnblogs.com/ddzj01/p/12097467.html

  一、概述

   本文将先容怎样给oracle数据库打最新补丁,数据库版本为11.2.0.4单实例,操作体系为redhat6.5
  二、下载相关升级包

1. 登录MOS,查阅(ID 2118136.2),下载最新补丁包


   PSU (Patch Set Update),数据库补丁
  2. 搜索"atch 6880880",下载最新opatch


   opatch是安装补丁的程序,数据库软件安装完成后,就自带了opatch,但是版本太旧了,所以这里下载最新的opatch
  
  至此已下载两个文件
p6880880_112000_Linux-x86-64.zip:opatch升级包
p29913194_112040_Linux-x86-64.zip:数据库补丁
  三、升级opatch

opatch的升级比较简单,就是个文件覆盖
3. 查看原始opatch信息

3.1.查看版本信息
  1. [oracle@orasingle ~]$ cd $ORACLE_HOME/OPatch
  2. [oracle@orasingle OPatch]$ ./opatch version  # 查看版本信息
  3. OPatch Version: 11.2.0.3.4
  4. OPatch succeeded.
复制代码
3.2.查看打补丁的情况
  1. [oracle@orasingle OPatch]$ ./opatch lsinventory  # 查看打补丁的情况
  2. Oracle Interim Patch Installer version 11.2.0.3.4
  3. Copyright (c) 2012, Oracle Corporation.  All rights reserved.
  4. Oracle Home       : /u01/app/oracle/product/11.2.0/db_1
  5. Central Inventory : /u01/app/oraInventory
  6.    from           : /u01/app/oracle/product/11.2.0/db_1/oraInst.loc
  7. OPatch version    : 11.2.0.3.4
  8. OUI version       : 11.2.0.4.0
  9. Log file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2019-12-25_14-26-47PM_1.log
  10. Lsinventory Output file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2019-12-25_14-26-47PM.txt
  11. --------------------------------------------------------------------------------
  12. Installed Top-level Products (1):
  13. Oracle Database 11g                                                  11.2.0.4.0
  14. There are 1 products installed in this Oracle Home.
  15. There are no Interim patches installed in this Oracle Home.
  16. --------------------------------------------------------------------------------
  17. OPatch succeeded.
复制代码
4. 备份原opatch

  1. [oracle@orasingle ~]$ cd $ORACLE_HOME
  2. [oracle@orasingle db_1]$ mv OPatch OPatch.bak
复制代码
5. 解压新下载的opatch包

将下载的opatch包上传到oracle的家目录
  1. [oracle@orasingle ~]$ cd ~
  2. [oracle@orasingle ~]$ sz
  3. [oracle@orasingle ~]$ ls p6880880_112000_Linux-x86-64.zip
  4. p6880880_112000_Linux-x86-64.zip
  5. # 文件上传成功
复制代码
解压新下载的opatch包
  1. [oracle@orasingle db_1]$ cd ~
  2. [oracle@orasingle ~]$ unzip p6880880_112000_Linux-x86-64.zip -d $ORACLE_HOME
复制代码

6. 再来查看opatch信息

  1. [oracle@orasingle ~]$ cd $ORACLE_HOME/OPatch
  2. [oracle@orasingle OPatch]$ ./opatch version  # 查看版本信息
  3. OPatch Version: 11.2.0.3.21
  4. OPatch succeeded.
复制代码
  至此 opatch 升级完毕
  四、打数据库补丁

7. 关闭em、监听、数据库

  1. [oracle@orasingle ~]$ emctl stop dbconsole  # 如果没有开启em,这步可以跳过
  2. [oracle@orasingle ~]$ lsnrctl stop
  3. [oracle@orasingle ~]$ sqlplus / as sysdba
  4. SQL> shutdown immediate
  5. SQL> exit
复制代码
8. 解压新下载的补丁包

将下载的补丁包上传到oracle的家目录
  1. [oracle@orasingle ~]$ cd ~
  2. [oracle@orasingle ~]$ ls p29913194_112040_Linux-x86-64.zip
  3. p29913194_112040_Linux-x86-64.zip
  4. [oracle@orasingle ~]$ unzip p29913194_112040_Linux-x86-64.zip
复制代码
9. 校验该补丁包是否与之前的补丁有冲突

  1. [oracle@orasingle ~]$ cd 29913194
  2. [oracle@orasingle 29913194]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./
  3. Oracle Interim Patch Installer version 11.2.0.3.21
  4. Copyright (c) 2019, Oracle Corporation.  All rights reserved.
  5. PREREQ session
  6. Oracle Home       : /u01/app/oracle/product/11.2.0/db_1
  7. Central Inventory : /u01/app/oraInventory
  8.    from           : /u01/app/oracle/product/11.2.0/db_1/oraInst.loc
  9. OPatch version    : 11.2.0.3.21
  10. OUI version       : 11.2.0.4.0
  11. Log file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2019-12-25_14-46-26PM_1.log
  12. Invoking prereq "checkconflictagainstohwithdetail"
  13. Prereq "checkConflictAgainstOHWithDetail" passed.
  14. OPatch succeeded.
复制代码
  由于这个测试库之前并没有打什么补丁,所以这里就不可能有补丁冲突的问题,如果这里显示有冲突,再去mos上查找相关办理方案。
  10. 正式升级

  1. [oracle@orasingle 29913194]$ $ORACLE_HOME/OPatch/opatch apply
复制代码

   这里要输入3次y和一次回车,这个是时间耗时比较久的,耐心等候
  

   升级完成后报上面的错误,通过查阅mos(ID 2265726.1),可知这个错误可以被忽略
  11. 再次查看打补丁的情况

  1. [oracle@orasingle 29913194]$ $ORACLE_HOME/OPatch/opatch lsinventory  # 查看打补丁的情况
  2. 内容较多,略
复制代码
12. 启动数据库,并运行sql文件

  1. [oracle@orasingle 29913194]$ cd $ORACLE_HOME/rdbms/admin
  2. [oracle@orasingle admin]$ sqlplus / as sysdba
  3. SQL> startup
  4. SQL> @catbundle.sql psu apply
  5. SQL> quit
复制代码
13. 启动监听、em

  1. [oracle@orasingle ~]$ lsnrctl start
  2. [oracle@orasingle ~]$ emctl start dbconsole  # 如果没有开启em,这步可以跳过
复制代码
  至此数据库打补丁已全部完成!
  五、回退数据库补丁

数据库在做变动时,当然要考虑回退方案了,接下来先容怎样回退数据库补丁

14. 关闭em、监听、数据库

  1. [oracle@orasingle ~]$ emctl stop dbconsole  # 如果没有开启em,这步可以跳过
  2. [oracle@orasingle ~]$ lsnrctl stop
  3. [oracle@orasingle ~]$ sqlplus / as sysdba
  4. SQL> shutdown immediate
  5. SQL> exit
复制代码
15. 回退补丁

  1. [oracle@orasingle ~]$ $ORACLE_HOME/OPatch/opatch rollback -id 29913194
复制代码

   这里要输入一次y,时间比较久,耐心等候
  

   这里提示warning,查阅mos(ID 1448337.1),得知可以忽略
  16. 启动数据库,并运行sql文件

  1. [oracle@orasingle ~]$ cd $ORACLE_HOME/OPatch
  2. [oracle@orasingle OPatch]$ ./opatch lsinventory  # 查看打补丁的情况
  3. OPatch Version: 11.2.0.3.21
  4. OPatch succeeded.
  5. [oracle@orasingle OPatch]$ ./opatch lsinv
  6. Oracle Interim Patch Installer version 11.2.0.3.21
  7. Copyright (c) 2019, Oracle Corporation.  All rights reserved.
  8. Oracle Home       : /u01/app/oracle/product/11.2.0/db_1
  9. Central Inventory : /u01/app/oraInventory
  10.    from           : /u01/app/oracle/product/11.2.0/db_1/oraInst.loc
  11. OPatch version    : 11.2.0.3.21
  12. OUI version       : 11.2.0.4.0
  13. Log file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2019-12-25_16-15-41PM_1.log
  14. Lsinventory Output file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2019-12-25_16-15-41PM.txt
  15. --------------------------------------------------------------------------------
  16. Local Machine Information::
  17. Hostname: orasingle
  18. ARU platform id: 226
  19. ARU platform description:: Linux x86-64
  20. Installed Top-level Products (1):
  21. Oracle Database 11g                                                  11.2.0.4.0
  22. There are 1 products installed in this Oracle Home.
  23. There are no Interim patches installed in this Oracle Home.
  24. --------------------------------------------------------------------------------
  25. OPatch succeeded.
复制代码
  可以看到补丁都被卸载了
  18. 启动监听 和 EM

  1. [oracle@orasingle ~]$ lsnrctl start
  2. [oracle@orasingle ~]$ emctl start dbconsole  # 如果没有开启em,这步可以跳过
复制代码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

美食家大橙子

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表