************************************************ * 一、主备库升级前检查及相关操作 * ************************************************ This patch is Data Guard Standby First Installable - See My Oracle Support Document 1265700.1 Oracle Patch Assurance - Data Guard Standby-First Patch Apply for details on how to remove risk and reduce downtime when applying this patch.
---升级前主库/DG备库执行---- 先主库停止传输日志 alter system set log_archive_dest_state_2=defer;
--备库见检查数据库状态,角色;然后备库修改,停止日志应用,并关闭所有节点(根据所打补丁看是否需要停数据库) select inst_id,host_name,instance_name,status from gv$instance; select inst_id,database_role,switchover_status from gv$database;
recover managed standby database cancel;
shutdown immediate; --根据所打补丁看是否需要停数据库
--主/备应用补丁如下列一二三四五步骤所述进行,注意:备库的补丁升级后注册操作不需要做:
************************************************ * 二、以下步骤依次在RAC的所有节点执行 * ************************************************ 1. 确认opatch版本 su - oracle opatch version ——11.2.0.3.6或以上 su - grid opatch version ——11.2.0.3.6或以上
2. 升级opatch(如果第1步不满足,则执行此步,否则忽略) su - oracle unzip p6880880_112000_Linux-x86-64.zip -d $ORACLE_HOME opatch version su - grid unzip p6880880_112000_Linux-x86-64.zip -d $GI_HOME opatch version
************************************************ * 三、以下步骤依次在RAC的所有节点执行 * ************************************************ 打GI PSU How to Create an OCM Response file to Apply a Patch in Silent Mode - opatch silent (文档 ID 966023.1) 2.1. 创建OCM文件 su - oracle $ORACLE_HOME/OPatch/ocm/bin/emocmrsp -no_banner -output /home/oracle/ocm.rsp chmod 775 /home/oracle/ocm.rsp
2.2 停止EM进程(如果没有安装EM,则忽略) su - oracle emctl stop dbconsole --One-off Patch Conflict Detection and Resolution补丁冲突检测 How to Use the My Oracle Support Conflict Checker Tool for Patches Installed with OPatch [Video] (文档 ID 1091294.1)
2.3 升级PSU (As root user, execute the following command on each node of the cluster:不能并行执行) su - root cd /tmp/patch unzip p26030870_112040_Linux-x86-64.zip opatch auto /tmp/patch/26030870/26030799 -ocmrf /home/oracle/ocm.rsp
*************************************************************************************** * 五、升级成功后,在生产的一个节点上执行(且在主库的一个节点打就行,备库不打 * *************************************************************************************** --For an Oracle RAC environment, perform these steps on only one node.(在主库一个节点执行即可,备库不用执行,且主备库的补丁都已经应用成功) SQL installation is performed after the primary database and all standby databases have the database home binaries patched to the same level。
4.1 大GI PSU升级后脚本 -- 执行catbundle.sql文件 cd $ORACLE_HOME/rdbms/admin sqlplus /nolog SQL> CONNECT / AS SYSDBA SQL> STARTUP SQL> @catbundle.sql psu apply SQL> QUIT --执行重编译 cd $ORACLE_HOME/rdbms/admin sqlplus /nolog SQL> CONNECT / AS SYSDBA SQL> @utlrp.sql -- Check the following log files in $ORACLE_BASE/cfgtoollogs/catbundle for any errors: catbundle_PSU__APPLY_.log catbundle_PSU__GENERATE_.log -- 升级RMAN CATALOG(如果没有用到Oracle Recovery Manager,则忽略) su - oracle rman catalog username/password@alias RMAN> UPGRADE CATALOG; -- 验证:DB和GI下都执行 opatch lspatches 4.2 OJVM补丁升级后注册操作
cd $ORACLE_HOME/sqlpatch/26027154 sqlplus /nolog SQL> CONNECT / AS SYSDBA SQL> STARTUP SQL> alter system set cluster_database=false scope=spfile; SQL> SHUTDOWN SQL> STARTUP UPGRADE SQL> @postinstall.sql SQL> alter system set cluster_database=true scope=spfile; SQL> SHUTDOWN SQL> STARTUP
cd $ORACLE_HOME/rdbms/admin sqlplus /nolog SQL> CONNECT / AS SYSDBA SQL> @utlrp.sql
***************************************************** * 六、如果出现异常,回滚并停止升级,分析原因 * ***************************************************** 回滚(GI PUS) su - root opatch auto /tmp/patch/26030799 -rollback -ocmrf /home/oracle/ocm.rsp
回滚注册:注意需要在当时打补丁完成后注册的那个rac节点上操作 step 1:Start all database instances running from the Oracle home. (For more information, see Oracle Database Administrator's Guide.) step 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_PSU__ROLLBACK.sql SQL> QUIT In an Oracle RAC environment, the name of the rollback script will have the format catbundle_PSU__ROLLBACK.sql.
step 3:If the OJVM PSU was applied for a previous GI PSU patch, you may see invalid Java classes after execution of the catbundle.sql script in the previous step. If this is the case, run utlrp.sql to re-validate these Java classes.
cd $ORACLE_HOME/rdbms/admin sqlplus /nolog SQL> CONNECT / AS SYSDBA SQL> @utlrp.sql step 4:check
$ opatch lsinventory 回滚(OJVM 补丁) crsctl stop crs opatch rollback -id 26027154 crsctl start crs opatch lsinventory 回滚后注册: The following steps load modified SQL files into the database. For an Oracle RAC environment, perform these steps on only one node.
step 1:Install the SQL portion of the patch by running the following command for a single instance environment.
cd $ORACLE_HOME/sqlpatch/26027154 sqlplus /nolog SQL> CONNECT / AS SYSDBA SQL> startup upgrade SQL> @postdeinstall.sql SQL> shutdown SQL> startup
For an Oracle RAC environment, reload the packages on one of the nodes using the following commands. Make sure no other instance of the database is up on the remote nodes. 注意:此步骤需要关闭rac上非跑脚本的其他实例
cd $ORACLE_HOME/sqlpatch/26027154 sqlplus /nolog SQL> CONNECT / AS SYSDBA SQL> STARTUP SQL> alter system set cluster_database=false scope=spfile; SQL> SHUTDOWN SQL> STARTUP UPGRADE SQL> @postdeinstall.sql SQL> alter system set cluster_database=true scope=spfile; SQL> SHUTDOWN SQL> STARTUP step 2:After installing the SQL portion of the patch, some packages could become INVALID. This will get recompiled upon access or you can run utlrp.sql to get them back into a VALID state.
cd $ORACLE_HOME/rdbms/admin sqlplus /nolog SQL> CONNECT / AS SYSDBA SQL> @utlrp.sql
四、打补丁或回滚补丁前应停止EM进程(如果没有安装EM,则忽略)
su - oracle
<ORACLE_HOME>/bin/emctl stop dbconsole
五、升级PSU(As root user, execute the following command on each node of the cluster:不能并行执行)
--As root user, execute the following command on each node of the cluster:
以root用户身份,在集群的每个节点上执行以下命令:
注意:PSU补丁的存放位置应该是GI和db共享的目录,并以GI下的opatch工具去执行
$ cd <UNZIPPED_PATCH_LOCATION>
$ unzip p27107360_112040_<platform>.zip
# opatch auto <UNZIPPED_PATCH_LOCATION>/27107360 -ocmrf <ocm response file>
六、升级后数据库注册,跑脚本:对于rac只需在一个节点上操作即可
--执行脚本catbundle.sql
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle.sql psu apply
SQL> QUIT
The catbundle.sql execution is reflected in the dba_registry_history view by a row associated with bundle series PSU.
--编译失效对象
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> @utlrp.sql
七、回滚PSU:
--root身份执行:
As root user, execute the following command on each node of the cluster.
# opatch auto <UNZIPPED_PATCH_LOCATION>/27107360 -rollback -ocmrf <ocm response file>
八、回滚后注册:在执行打补丁注册后的节点上执行回滚后注册
8.1 Start all database instances running from the Oracle home
8.2 执行脚本
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle_PSU_<database SID PREFIX>_ROLLBACK.sql
SQL> QUIT
8.3 编译失效对象
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> @utlrp.sql
8.4 Check the log file for any errors.
The log file is found in $ORACLE_BASE/cfgtoollogs/catbundle and is named catbundle_PSU_<database SID>_ROLLBACK_<TIMESTAMP>.log where TIMESTAMP is of the form YYYYMMMDD_HH_MM_SS. If there are error.