Opatch打补丁

本文档详细介绍了如何在Oracle数据库中安装和卸载CPU补丁。包括RAC环境和非RAC环境的安装步骤,以及补丁安装后的SQL文件加载和数据库检查。在安装过程中,需确保正确执行OPatch utility,并根据环境关闭实例和监听器。在卸载补丁时,需要执行特定的回滚脚本,并检查日志文件以确认无错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、下载了oracle的一个cpu的补丁,想打一下这个补丁
cpu的自许文件中有安装的步骤:

3.2.1 Patch Installation Instructions

Follow these steps:

  1. If you are using a Data Guard Physical Standby database, you must install this patch on both the primary database and the physical standby database, as described by My Oracle Support Note 278641.1.

  2. Do one of the following, depending on whether this is a RAC environment:

    • If this is a RAC environment, choose one of the patch installation methods provided by OPatch (rolling, all node, or minimum downtime), and shutdown instances and listeners as appropriate for the installation method selected.

      This CPU patch is rolling RAC installable. Refer to My Oracle Support Note 244241.1 Rolling Patch - OPatch Support for RAC.

    • If this is not a RAC environment, shut down all instances and listeners associated with the Oracle home that you are updating. For more information, see Oracle Database Administrator's Guide.

  3. Ensure that the $PATH has the following executables: makearld, and nm.

    The location of these executables depends on your operating system. On many operating systems, they are located in /usr/ccs/bin, in which case you can set your PATH as follows:

    export PATH=$PATH:/usr/ccs/bin
    
  4. Set your current directory to the directory where the patch is located and then run the OPatch utility by entering the following commands:

    unzip p13632717_112030_<platform>.zip
    cd 13632717
    opatch napply -skip_subset -skip_duplicate
    

    Should OPatch return conflicts or subsets, refer to Section 3.1.1, "n-Apply CPUs and Patch Conflict Checking" for additional options.

  5. If there are errors, refer to Section 4, "Known Issues".

3.2.2 Patch Post-Installation Instructions

After installing the patch, load modified SQL files into the database, as explained in Section 3.2.2.1.

3.2.2.1 Loading Modified SQL Files into the Database

The following steps load modified SQL files into the database. For a RAC environment, perform these steps on only one node.

  1. For each database instance running on the Oracle home being patched, connect to the database using SQL*Plus. Connect as SYSDBA and run the catbundle.sql script as follows:

    cd $ORACLE_HOME/rdbms/admin
    sqlplus /nolog
    SQL> CONNECT / AS SYSDBA
    SQL> STARTUP
    SQL> @catbundle.sql cpu apply
    SQL> QUIT
    

    The catbundle.sql execution is reflected in the dba_registry_history view by a row associated with bundle series CPU.

    For information about the catbundle.sql script, see My Oracle Support Note 605795.1 Introduction to Oracle Database catbundle.sql.

  2. Check the following log files in $ORACLE_BASE/cfgtoollogs/catbundle for any errors:

    catbundle_CPU_<database SID>_APPLY_<TIMESTAMP>.log
    catbundle_CPU_<database SID>_GENERATE_<TIMESTAMP>.log
    

    where TIMESTAMP is of the form YYYYMMMDD_HH_MM_SS. If there are errors, refer to Section 4, "Known Issues".

3.2.3 Patch Post-Installation Instructions for Databases Created or Upgraded after Installation of CPUApr2012 in the Oracle Home

These instructions are for a database that is created or upgraded after the installation of CPUApr2012.

You must execute the steps in Section 3.2.2.1, "Loading Modified SQL Files into the Database" for any new database only if it was created by any of the following methods:

  • Using DBCA (Database Configuration Assistant) to select a sample database (General, Data Warehouse, Transaction Processing)

  • Using a script that was created by DBCA that creates a database from a sample database

There are no actions required for databases that have been upgraded.

3.3 Patch Deinstallation Instructions for Oracle Database Release 11.2.0.3

These instructions apply if you need to deinstall the patch.

3.3.1 Patch Deinstallation Instructions for a Non-RAC Environment

Follow these steps:

  1. Verify that an $ORACLE_HOME/rdbms/admin/catbundle_CPU_<database SID>_ROLLBACK.sql file exists for each database associated with this ORACLE_HOME. If this is not the case, you must execute the steps in Section 3.2.2.1, "Loading Modified SQL Files into the Database" against the database before deinstalling the CPU.

  2. Shut down all instances and listeners associated with the Oracle home that you are updating. For more information, see Oracle Database Administrator's Guide.

  3. Run the OPatch utility using the specified rollback argument to rollback all molecule patches included in CPUApr2012. If a molecule is not installed in the Oracle Home, the rollback will ignore it. If a molecule is installed as part of a merge patch, it will not be rolled back. If it is desired to rollback merge patches that have been applied to your Oracle Home, the rollback needs to be issued separately.

    opatch nrollback -idFile $ORACLE_HOME/cpu/CPUApr2012/rollback_all.lst
    

    If you have applied CPUApr2012 on top of a previous CPU, you may instead want to rollback only the molecule patches that are new in CPUApr2012. To do so, use the following command:

    opatch nrollback -idFile $ORACLE_HOME/cpu/CPUApr2012/rollback_new.lst
    

    You may also rollback individual molecules or a list of molecules, as needed. Refer to the OPatch documentation on the nrollback command.

  4. For information on the content of molecules when doing a rollback of CPUApr2012, refer to My Oracle Support Note 1399148.1 "Critical Patch Update April 2012 Database Patch Security Vulnerability Molecule Mapping.

  5. If there are errors, refer to Section 4, "Known Issues".

3.3.2 Patch Post-Deinstallation Instructions for a Non-RAC Environment

Follow these steps:

  1. Start all database instances running from the Oracle home. (For more information, see Oracle Database Administrator's Guide.)

  2. For each database instance running out of the ORACLE_HOME, connect to the database using SQL*Plus as SYSDBA and run the rollback script as follows:

    cd $ORACLE_HOME/rdbms/admin
    sqlplus /nolog
    SQL> CONNECT / AS SYSDBA
    SQL> STARTUP
    SQL> @catbundle_CPU_<database SID>_ROLLBACK.sql
    SQL> QUIT
    
  3. Check the log file for any errors. The log file is found in $ORACLE_BASE/cfgtoollogs/catbundle and is named catbundle_CPU_<database SID>_ROLLBACK_<TIMESTAMP>.log where TIMESTAMP is of the form YYYYMMMDD_HH_MM_SS. If there are errors, refer to Section 4, "Known Issues".

但是我在执行
[oracle@oracle11 13632717]$ opatch napply -skip_subset -skip_duplicate
bash: opatch: command not found
明显是opatch命令没有在执行路径下,但是optch不在oracle_home/bin下吗??去查确实不在....
那在那????
[root@oracle11 OPatch]# pwd
/home/oracle/app/product/11.2.0.3/OPatch
执行的时候需要修改一下path才行了:)
export PATH=$PATH:$ORACLE_HOME/OPatch
再执行没有问题了,但是心的问题又来了

[oracle@oracle11 13632717]$ export LANG=C
[oracle@oracle11 13632717]$ opatch napply -skip_subset -skip_duplicate
Invoking OPatch 11.2.0.1.7


Oracle Interim Patch Installer version 11.2.0.1.7
Copyright (c) 2011, Oracle Corporation.  All rights reserved.


UTIL session


Oracle Home       : /home/oracle/app/product/11.2.0.3
Central Inventory : /home/oracle/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 11.2.0.1.7
OUI version       : 11.2.0.3.0
Log file location : /home/oracle/app/product/11.2.0.3/cfgtoollogs/opatch/opatch2012-05-30_01-37-18AM.log


List of Homes on this system:


  Home name= OraDb11g_home1, Location= "/home/oracle/app/product/11.2.0.1"
OPatchSession cannot load inventory for the given Oracle Home /home/oracle/app/product/11.2.0.3. Possible causes are:
   No read or write permission to ORACLE_HOME/.patch_storage
   Central Inventory is locked by another OUI instance
   No read permission to Central Inventory
   The lock file exists in ORACLE_HOME/.patch_storage
   The Oracle Home does not exist in Central Inventory
UtilSession failed: OracleHomeInventory gets null oracleHomeInfo
Log file location: /home/oracle/app/product/11.2.0.3/cfgtoollogs/opatch/opatch2012-05-30_01-37-18AM.log
OPatch failed with error code 73
路径权限肯定没有问题啊,唯一有疑问的是 The Oracle Home does not exist in Central Inventory-----去查看该文件

[oracle@oracle11 ContentsXML]$ pwd
/home/oracle/oraInventory/ContentsXML
[oracle@oracle11 ContentsXML]$ more inventory.xml
<?xml version="1.0" standalone="yes" ?>
<!-- Copyright (c) 1999, 2009, Oracle. All rights reserved. -->
<!-- Do not modify the contents of this file by hand. -->
<INVENTORY>
<VERSION_INFO>
   <SAVED_WITH>11.2.0.1.0</SAVED_WITH>
   <MINIMUM_VER>2.1.0.6.0</MINIMUM_VER>
</VERSION_INFO>
<HOME_LIST>
<HOME NAME="OraDb11g_home1" LOC="/home/oracle/app/product/11.2.0.1" TYPE="O" IDX="1"/>
</HOME_LIST>
</INVENTORY>

晕,果然是路径有问题,这个路径是升级之前的路径了,升级后没有改过来,现在联想到升级方式才知道安装新的11.2.0.3的时候的安装方式不对啊,应该把11.2.0.1的这个orainventor这个路径给改名,从新生成一个新的就对了,当时为了方便没改....
修改完成之后没有问题
[oracle@oracle11 13632717]$ opatch napply -skip_subset -skip_duplicate
Invoking OPatch 11.2.0.1.7


Oracle 中间补丁程序安装程序版本 11.2.0.1.7
版权所有 (c) 2011, Oracle Corporation。保留所有权利。


UTIL session


Oracle Home       : /home/oracle/app/product/11.2.0.3
Central Inventory : /home/oracle/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 11.2.0.1.7
OUI version       : 11.2.0.3.0
Log file location : /home/oracle/app/product/11.2.0.3/cfgtoollogs/opatch/opatch2012-05-30_17-45-42下午.log


Verifying environment and performing prerequisite checks...
Checking skip_duplicate
Checking skip_subset
OPatch continues with these patches:   13632717  13742433  13742434  13742435  13742436  13742437  13742438  13742464  13772618  


是否继续? [y|n]
y
User Responded with: Y
All checks passed.


请关闭本地系统上在此 ORACLE_HOME 之外运行的 Oracle 实例。
(Oracle 主目录 = '/home/oracle/app/product/11.2.0.3')




本地系统是否已准备打补丁? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '13632717' to OH '/home/oracle/app/product/11.2.0.3'


正在为组件 oracle.rdbms.rsf, 11.2.0.3.0 打补丁...
将文件复制到 "/home/oracle/app/product/11.2.0.3/cpu/CPUApr2012/rollback_all.lst"
将文件复制到 "/home/oracle/app/product/11.2.0.3/cpu/CPUApr2012/rollback_new.lst"
...............................
按照自许文件上的步骤接着往下做

The catbundle.sql execution is reflected in the dba_registry_history view by a row associated with bundle series CPU.
[oracle@oracle11 admin]$ sqlplus '/as sysdba'


SQL*Plus: Release 11.2.0.3.0 Production on Wed May 30 18:07:28 2012


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




Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> @?/rdbms/admin/catbundle.sql cpu apply


PL/SQL procedure successfully completed.




PL/SQL procedure successfully completed.




PL/SQL procedure successfully completed.




















Generating apply and rollback scripts...
Check the following file for errors:
/home/oracle/app/cfgtoollogs/catbundle/catbundle_CPU_ORAL1_GENERATE_2012May30_18_09_05.log


Apply script: /home/oracle/app/product/11.2.0.3/rdbms/admin/catbundle_CPU_ORAL1_APPLY.sql
Rollback script: /home/oracle/app/product/11.2.0.3/rdbms/admin/catbundle_CPU_ORAL1_ROLLBACK.sql


PL/SQL procedure successfully completed.


Executing script file...








SQL> COLUMN spool_file NEW_VALUE spool_file NOPRINT
SQL> SELECT '/home/oracle/app/cfgtoollogs/catbundle/' || 'catbundle_CPU_' || name || '_APPLY_' || TO_CHAR(SYSDATE, 'YYYYMonDD_hh24_mi_ss', 'NLS_DATE_LANGUAGE=''AMERICAN''') || '.log' AS spool_file FROM v$database;








SQL> SPOOL &spool_file
SQL> exec dbms_registry.set_session_namespace('SERVER')


PL/SQL procedure successfully completed.


SQL> ALTER SESSION SET current_schema = SYS;


Session altered.


SQL> PROMPT Updating registry...
Updating registry...
SQL> INSERT INTO registry$history
  2    (action_time, action,
  3     namespace, version, id,
  4     bundle_series, comments)
  5  VALUES
  6    (SYSTIMESTAMP, 'APPLY',
  7     SYS_CONTEXT('REGISTRY$CTX','NAMESPACE'),
  8     '11.2.0.3',
  9     2,
 10     'CPU',
 11     'CPUApr2012');


1 row created.


SQL> COMMIT;


Commit complete.


SQL> SPOOL off
SQL> SET echo off
Check the following log file for errors:
/home/oracle/app/cfgtoollogs/catbundle/catbundle_CPU_ORAL1_APPLY_2012May30_18_09_50.log
SQL> SQL> 
到此cpu的安装就结束了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值