Oracle 更新Opatch、打补丁

1.更新Opatch;
2.打补丁;
3.grid 打补丁;

1.更新Opatch(实验版本:oracle:11.2.0.3.0):
默认安装数据库后,在ORACLE_HOME 下会有个OPatch 文件夹,更新前先检查当前Opatch 版本:

   1:  [oracle@sywu2 OPatch]$ ./opatch lsinventory
   2:   Invoking OPatch 11.2.0.1.7
   3:   
   4:  Oracle 中间补丁程序安装程序版本 11.2.0.1.7
   5:  版权所有 (c) 2011, Oracle Corporation。保留所有权利。
   6:   
   7:   
   8:  Oracle Home       : /s01/app/oracle/product/11.2.0/dbhome_1
   9:  Central Inventory : /g01/oraInventory
  10:     from           : /etc/oraInst.loc
  11:  OPatch version    : 11.2.0.1.7
  12:  OUI version       : 11.2.0.3.0
  13:  Log file location : /s01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2014-06-27_23-03-26下午.log

注:有些时候产品清单加载失败,会导致打补丁时出错

   1:  [sywu@sywu OPatch]$ ./opatch lsinventory
   2:  Invoking OPatch 11.1.0.6.6
   3:   
   4:  Oracle 中间补丁程序安装程序版本 11.1.0.6.6
   5:  版权所有 (c) 2009, Oracle Corporation。保留所有权利。
   6:   
   7:   
   8:  Oracle 主目录       : /u01/app/product/11.2.0/db_1
   9:  主产品清单: /g01/oraInventory
  10:     从           : /etc/oraInst.loc
  11:  OPatch 版本    : 11.1.0.6.6
  12:  OUI 版本       : 11.2.0.1.0
  13:  OUI 位置      : /u01/app/product/11.2.0/db_1/oui
  14:  日志文件位置 : /u01/app/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2014-06-27_21-51-13下午.log
  15:   
  16:  Patch history file: /u01/app/product/11.2.0/db_1/cfgtoollogs/opatch/opatch_history.txt
  17:   
  18:  List of Homes on this system:
  19:   
  20:    Home name= Ora11g_gridinfrahome1, Location= "/g01/11ggrid/11.2.0/grid"
  21:    Home name= OraDb11g_home1, Location= "/s01/app/oracle/product/11.2.0/dbhome_1"
  22:  产品清单加载失败... OPatch cannot load inventory for the given Oracle Home.
  23:  Possible causes are:
  24:     Oracle Home dir. path does not exist in Central Inventory
  25:     Oracle Home is a symbolic link
  26:     Oracle Home inventory is corrupted
  27:  LsInventorySession 失败: OracleHomeInventory gets null oracleHomeInfo
  28:   
  29:  OPatch failed with error code 73

解决方法:
1)找到产品清单文件,默认安装成功后会在 /etc/oraInst.loc 和oracle 根目录 oraInventory 文件夹下,如果/etc/下没有就到ORACLE 安装根目录找到文件夹:oraInventory,里面有oraInst.loc;复制一个到 /etc下;
2)到$ORACLE_HOME/oui/bin/ 执行如下脚本加载清单:

   1:  ./runInstaller -silent -attachHome \
   2:   ORACLE_HOME=$ORACLE_HOME \
   3:   ORACLE_HOME_NAME="ORACLE_HOME"

3) 加载成功后再次到OPatch目录下执行 ./opatch lsinventory 确认产品清单加载是否成功;

有些时候你打过补丁,然后删除过$ORACLE_HOME/.patch_storage 下的文件,下次重新再打补丁是可能会报:"OracleHomeInventory 无法创建锁文件",怎么处理都不行,也并不是操作权限问题:

   1:  [grid@sywu2 shared]$ opatch lsinventory
   2:   
   3:  Oracle 中间补丁程序安装程序版本 11.2.0.3.3
   4:  版权所有 (c) 2012, Oracle Corporation。保留所有权利。
   5:   
   6:   
   7:  Oracle Home       : /g01/11ggrid/11.2.0/grid
   8:  Central Inventory : /g01/oraInventory
   9:     from           : /g01/11ggrid/11.2.0/grid/oraInst.loc
  10:  OPatch version    : 11.2.0.3.3
  11:  OUI version       : 11.2.0.3.0
  12:  Log file location : /g01/11ggrid/11.2.0/grid/cfgtoollogs/opatch/opatch2014-06-28_16-51-09下午_1.log
  13:   
  14:  OracleHomeInventory 无法创建锁文件, 可能是由于 OPatch 会话失败。加载的产品清单可能无法正确显示 Oracle 主目录中的内容。
  15:  Lsinventory Output file location : /g01/11ggrid/11.2.0/grid/cfgtoollogs/opatch/lsinv/lsinventory2014-06-28_16-51-09下午.txt
解决方法:
1)首先查看 $ORACLE_HOME/.patch_storage 目录下是否有patch_locked 文件:
   1:  [grid@sywu2 shared]$ ls -las $ORACLE_HOME/.patch_storage
   2:  总用量 32
   3:  4 drwxr-x---  4 grid oinstall 4096 6月  28 16:55 .
   4:  4 drwxr-xr-x 68 grid oinstall 4096 6月  28 16:55 ..
   5:  4 drwxr-xr-x  5 grid oinstall 4096 6月  28 11:18 15876003_Jan_11_2013_06_19_07
   6:  4 -rw-r--r--  1 grid oinstall 1949 6月  28 11:18 interim_inventory.txt
   7:  4 -rw-r--r--  1 grid oinstall   93 6月  28 11:18 LatestOPatchSession.properties
   8:  4 drwxr-xr-x  3 grid oinstall 4096 6月  28 11:17 NApply
   9:  4 -rw-r--r--  1 grid oinstall   56 6月  28 11:18 patch_locked
  10:  4 -rw-r--r--  1 grid oinstall   52 6月  28 11:18 record_inventory.txt
2)如果有,将patch_locked 文件命名为其它名或移走,然后再次尝试 opatch lsinventory:
   1:  [grid@sywu2 shared]$ mv /g01/11ggrid/11.2.0/grid/.patch_storage/patch_locked  /g01/11ggrid/11.2.0/grid/.patch_storage/patch_locked_bkp
   2:  [grid@sywu2 shared]$ opatch lsinventory

1.1 更新前先备份原来的Opatch:

   1: [oracle@sywu2 dbhome_1]$ tar -cvf Opatch_20140627.tar OPatch

1.2 解压新版Opatch 文件到$ORACLE_HOME 目录下:

   1:  [oracle@sywu2 dbhome_1]$ /tmp/unzip p6880880_112000_Linux-x86-64.zip -d $ORACLE_HOME
   2:  Archive:  p6880880_112000_Linux-x86-64.zip
   3:     creating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/
   4:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/README.html  
   5:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/README.txt  
   6:     creating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/
   7:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/oplan.jar  
   8:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/oracle.oplan.classpath.jar  
   9:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/automation.jar  
  10:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/OsysModel.jar  
  11:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/EMrepoDrivers.jar  
  12:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/Validation.jar  
  13:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/ValidationRules.jar  
  14:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/osysmodel-utils.jar  
  15:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/CRSProductDriver.jar  
  16:     creating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/apache-commons/
  17:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/apache-commons/commons-cli-1.0.jar  
  18:     creating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/jaxb/
  19:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/jaxb/activation.jar  
  20:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/jaxb/jaxb-api.jar  
  21:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/jaxb/jaxb-impl.jar  
  22:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/jlib/jaxb/jsr173_1.0_api.jar  
  23:    inflating: /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/oplan/oplan  
  24:  replace /s01/app/oracle/product/11.2.0/dbhome_1/OPatch/docs/FAQ? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
  25:  .............
1.3 确认OPatch 更新是否成功:
   1:  [oracle@sywu2 OPatch]$ ./opatch version
   2:  OPatch Version: 11.2.0.3.3
   3:   
   4:  OPatch succeeded.

可能会有未知错误,如版本问题,操作前一定记得备份原来的OPatch;
 
2.打补丁:
打补丁前要关闭数据库实例、监听程序,补丁要与更新的OPatch对应:
2.1 解压补丁文件到$ORACLE_HOME 目录下:

   1:  [oracle@sywu2 OPatch]$ unzip /tmp/p14727310_112030_Linux-x86-64.zip -d $ORACLE_HOME 
   2:  [oracle@sywu2 dbhome_1]$ cd 14727310/
   3:  [oracle@sywu2 14727310]$ ls
   4:  13343438  13696216  13923374  14275605  14727310  patchmd.xml  README.html  README.txt

  README.html 文件上有介绍打补丁方法,打补丁前先查看一下;
开始打补丁:

   1:  [oracle@sywu2 14727310]$ $ORACLE_HOME/OPatch/opatch apply

2.2 将变更的 SQL Files 导入数据库:

   1:  [oracle@sywu2 ~]$ cd $ORACLE_HOME/rdbms/admin
   2:  [oracle@sywu2 admin]$ sqlplus / as sysdba
   3:  SQL> @catbundle.sql psu apply
打补丁信息在 V$version 视图中是查询不到的,要通过 dba_registry_history 视图查询:
   1:  SQL>  select action_time,action,namespace,version,bundle_series,comments from dba_registry_history;
   2:   
   3:  ACTION_TIME                                                                 ACTION     NAMESPACE  VERSION
   4:  --------------------------------------------------------------------------- ---------- ---------- ------------------------------
   5:  BUNDLE_SERIES                  COMMENTS
   6:  ------------------------------ --------------------
   7:  02-MAY-14 11.12.11.444913 PM                                                APPLY      SERVER     11.2.0.3
   8:  PSU                            Patchset 11.2.0.2.0
   9:   
  10:  27-JUN-14 11.42.54.320914 PM                                                APPLY      SERVER     11.2.0.3
查询具体的Opatch 版本信息和补丁信息
   1:  [oracle@sywu OPatch]$ cd $ORACLE_HOME/OPatch
   2:  [oracle@sywu OPatch]$ ./opatch lsinventory  
   3:   
   4:  Oracle 中间补丁程序安装程序版本 11.2.0.3.3
   5:  版权所有 (c) 2012, Oracle Corporation。保留所有权利。
   6:   
   7:   
   8:  Oracle Home       : /s01/app/oracle/product/11.2.0/dbhome_1
   9:  Central Inventory : /g01/oraInventory
  10:     from           : /s01/app/oracle/product/11.2.0/dbhome_1/oraInst.loc
  11:  OPatch version    : 11.2.0.3.3
  12:  OUI version       : 11.2.0.3.0
  13:  Log file location : /s01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2014-06-28_00-03-04上午_1.log
  14:   
  15:  Lsinventory Output file location : /s01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2014-06-28_00-03-04上午.txt
  16:   
  17:  --------------------------------------------------------------------------------
  18:  已安装的顶级产品 (1):
  19:   
  20:  Oracle Database 11g                                                  11.2.0.3.0
  21:  此 Oracle 主目录中已安装 1 个产品。
  22:   
  23:   
  24:  中间补丁程序 (1) :
  25:   
  26:  Patch  14727310     : applied on Fri Jun 27 22:35:15 CST 2014
  27:  Unique Patch ID:  15663328
  28:  Patch description:  "Database Patch Set Update : 11.2.0.3.5 (14727310)"
  29:     Created on 27 Dec 2012, 00:06:30 hrs PST8PDT
  30:  Sub-patch  14275605; "Database Patch Set Update : 11.2.0.3.4 (14275605)"
  31:  Sub-patch  13923374; "Database Patch Set Update : 11.2.0.3.3 (13923374)"
  32:  Sub-patch  13696216; "Database Patch Set Update : 11.2.0.3.2 (13696216)"
  33:  Sub-patch  13343438; "Database Patch Set Update : 11.2.0.3.1 (13343438)"
  34:     Bugs fixed:
  35:       13566938, 13593999, 10350832, 14138130, 12919564, 13624984, 13588248
  36:       13080778, 13804294, 14258925, 12873183, 13645875, 12880299, 14664355
  37:       14409183, 12998795, 14469008, 13719081, 13492735, 12857027, 14263036
  38:       14263073, 13742433, 13732226, 12905058, 13742434, 12849688, 12950644
  39:       13742435, 13464002, 12879027, 13534412, 14613900, 12585543, 12535346
  40:       12588744, 11877623, 12847466, 13649031, 13981051, 12582664, 12797765
  41:       14262913, 12923168, 13612575, 13384182, 13466801, 13484963, 11063191
  42:       13772618, 13070939, 12797420, 13041324, 12976376, 11708510, 13742437
  43:       13026410, 13737746, 13742438, 13326736, 13001379, 13099577, 14275605
  44:       13742436, 9873405, 9858539, 14040433, 12662040, 9703627, 12617123
  45:       12845115, 12764337, 13354082, 13397104, 12964067, 13550185, 12780983
  46:       12583611, 14546575, 13476583, 15862016, 11840910, 13903046, 15862017
  47:       13572659, 13718279, 13657605, 13448206, 13419660, 14480676, 13632717
  48:       14063281, 13430938, 13467683, 13420224, 14548763, 12646784, 14035825
  49:       12861463, 12834027, 15862021, 13377816, 13036331, 14727310, 13685544
  50:       13499128, 15862018, 12829021, 15862019, 12794305, 14546673, 12791981
  51:       13503598, 13787482, 10133521, 12718090, 13399435, 14023636, 12401111
  52:       13257247, 13362079, 12917230, 13923374, 14480675, 13524899, 13559697
  53:       14480674, 13916709, 14076523, 13773133, 13340388, 13366202, 13528551
  54:       12894807, 13343438, 13454210, 12748240, 14205448, 13385346, 15853081
  55:       12971775, 13035804, 13544396, 13035360, 14062795, 12693626, 13332439
  56:       14038787, 14062796, 12913474, 14841409, 14390252, 13370330, 14062797
  57:       13059165, 14062794, 12959852, 13358781, 12345082, 12960925, 9659614
  58:       13699124, 14546638, 13936424, 13338048, 12938841, 12658411, 12620823
  59:       12656535, 14062793, 12678920, 13038684, 14062792, 13807411, 12594032
  60:       13250244, 15862022, 9761357, 12612118, 13742464, 14052474, 13457582
  61:       13527323, 15862020, 12780098, 13502183, 13705338, 13696216, 10263668
  62:       15862023, 13554409, 15862024, 13103913, 13645917, 14063280, 13011409

3.grid 打补丁:
打补丁前同样的先关掉实例、监听程序,停止相关服务释放资源:

   1:  [grid@sywu2 15876003]$ su -l root
   2:  密码:
   3:  [root@sywu2 install]# cd $GRID_HOME/crs/install
   4:  [root@sywu2 install]# ./rootcrs.pl -unlock

切换到grid 用户下解压补丁、打补丁(补丁文件:p14727347_112030_Linux-x86-64.zip,该补丁文件包含了db补丁和grid补丁):

   1:  [grid@sywu2 shared]$ unzip p14727347_112030_Linux-x86-64.zip -d /tmp/
   2:  [grid@sywu2 tmp]$ cd 15876003/
   3:  [grid@sywu2 15876003]$ ls
   4:  14727310  15876003  bundle.xml  README.html  README.txt
   5:  [grid@sywu2 15876003]$ opatch napply -oh $GRID_HOME -local /tmp/15876003/14727310/
然后根据相关提示操作;14打完再打15876003 grid 补丁:
   1:  [grid@sywu2 15876003]$ opatch napply -oh $GRID_HOME -local /tmp/15876003/15876003/
打完grid 补丁后切换到oracle 用户下打db补丁:
   1:  [grid@sywu2 ~]$ su -l oracle
   2:  [oracle@sywu2 ~]$  /tmp/15876003/15876003/custom/server/15876003/custom/scripts/prepatch.sh -dbhome $ORACLE_HOME
   3:  /tmp/15876003/15876003/custom/server/15876003/custom/scripts/prepatch.sh completed successfully.
   4:   
   5:  [oracle@sywu2 ~]$ opatch napply -oh $ORACLE_HOME -local /tmp/15876003/15876003/custom/server/15876003/
   6:   
   7:  [oracle@sywu2 ~]$ opatch napply -oh $ORACLE_HOME -local /tmp/15876003/14727310/
   8:   
   9:   
  10:  [oracle@sywu2 ~]$ /tmp/15876003/15876003/custom/scripts/postpatch.sh -dbhome $ORACLE_HOME
打完db补丁后切换到root用户,完成后续操作和启动相关服务:
   1:  [oracle@sywu2 ~]$ su -l root
   2:  [root@sywu2 ~]# /g01/11ggrid/11.2.0/grid/rdbms/install/rootadd_rdbms.sh 
   3:  [root@sywu2 ~]# /g01/11ggrid/11.2.0/grid/crs/install/rootcrs.pl -patch
检查相关服务是否启动;
   1:  [root@sywu2 ~]#  crsctl check crs
   2:  [root@sywu2 ~]#   crsctl stat res -t
这样补丁打完:
   1:  [grid@sywu grid]$ opatch lspatches
   2:  15876003;Grid Infrastructure Patch Set Update : 11.2.0.3.5 (14727347)
   3:  14727310;Database Patch Set Update : 11.2.0.3.5 (14727310)
最后启动数据库将变更的 SQL Files 导入数据库:
   1:  [oracle@sywu2 ~]$ cd $ORACLE_HOME/rdbms/admin
   2:  [oracle@sywu2 admin]$ sqlplus / as sysdba
   3:  SQL> @catbundle.sql psu apply

Oracle 更新Opatch、打补丁,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。