************************************************ * 一、主備庫升級前檢查及相關操作 * ************************************************ 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.