11G透過物理standby進行滾動升級例項說明及注意

kunlunzhiying發表於2016-12-15
參考文件:<br /> /> <br /> 以下對文件中的例項進行說明:<br /> PROD:primary <br /> PSTBY:物理standby<br /> LSTBY:邏輯standby<br /> <table style="width:70%;" class="" border="1" bordercolor="#000000" cellpadding="0" cellspacing="0"> <tbody> <tr> <td align="center" height="34" width="138"> <strong>源主庫當前角色</strong> </td> <td align="center" width="352"> <strong>操作及說明</strong> </td> <td align="center" width="132"> <strong>源從庫當前角色</strong> </td> <td align="center" width="455"> <strong>操作及說明</strong> </td> </tr> <tr align="center"> <td colspan="4" height="24"> <strong>PREPARATION STEPS(準備項)</strong> </td> </tr> <tr> <td height="41"> PROD </td> <td width="352"> DGMGRL&gt; disable configuration;<br /> 如果有配置dg broker,停掉 </td> <td> PSTBY </td> <td> <br /> </td> </tr> <tr> <td height="54"> PROD </td> <td width="352"> ALTER SYSTEM SET<br /> DG_BROKER_START=FALSE SCOPE=BOTH;<br /> 如果有配置dg broker,停掉 </td> <td> PSTBY </td> <td width="455"> ALTER SYSTEM SET<br /> DG_BROKER_START=FALSE SCOPE=BOTH; </td> </tr> <tr> <td height="72"> PROD </td> <td width="352"> exec dbms_capture_adm.stop_capture<br /> (capture_name<br /> =&gt;'STRMADMIN_CAPTURE');<br /> 如果有用oracle stream,停掉 </td> <td> PSTBY </td> <td> <br /> </td> </tr> <tr> <td height="72"> PROD </td> <td width="352"> ALTER DATABASE ADD STANDBY LOGFILE<br /> (’+PROD’) SIZE 50M;<br /> …<br /> 新增standby logfile </td> <td> PSTBY </td> <td width="455"> ALTER DATABASE ADD STANDBY LOGFILE<br /> (’+PSTBY’) SIZE 50M;<br /> … </td> </tr> <tr> <td height="54"> PROD </td> <td width="352"> SELECT PROTECTION_MODE FROM<br /> V$DATABASE;<br /> 確定dg保護模式,必須為最高可用或最大效能. </td> <td> PSTBY </td> <td width="455"> SELECT PROTECTION_MODE FROM<br /> V$DATABASE; </td> </tr> <tr> <td height="540"> PROD </td> <td width="352"> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_1='<br /> LOCATION=USE_DB_RECOVERY_FILE_DEST<br /> VALID_FOR=(ONLINE_LOGFILES,<br /> ALL_ROLES) DB_UNIQUE_NAME=prod'<br /> SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_2=<br /> 'SERVICE=pstby LGWR ASYNC<br /> NOAFFIRM DELAY=0 OPTIONAL<br /> REOPEN=15 MAX_FAILURE=10<br /> VALID_FOR=(ONLINE_LOGFILES,<br /> PRIMARY_ROLE)<br /> DB_UNIQUE_NAME=pstby' SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_3=<br /> 'LOCATION=USE_DB_RECOVERY_FILE_DES<br /> T VALID_FOR=(STANDBY_LOGFILES,<br /> STANDBY_ROLE)<br /> DB_UNIQUE_NAME=prod' SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_STATE_1=ENABLE<br /> SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_STATE_2=ENABLE<br /> SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_STATE_3=ENABLE<br /> SCOPE=BOTH;<br /> 修改主庫日誌傳輸 </td> <td> PSTBY </td> <td width="455"> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_1='<br /> LOCATION=USE_DB_RECOVERY_FILE_DEST<br /> VALID_FOR=(ONLINE_LOGFILES,<br /> ALL_ROLES) DB_UNIQUE_NAME=pstby'<br /> SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_2=<br /> 'SERVICE=prod LGWR ASYNC NOAFFIRM<br /> DELAY=0 OPTIONAL REOPEN=15<br /> MAX_FAILURE=10<br /> VALID_FOR=(ONLINE_LOGFILES,<br /> PRIMARY_ROLE)<br /> DB_UNIQUE_NAME=prod' SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_3=<br /> 'LOCATION=USE_DB_RECOVERY_FILE_DES<br /> T VALID_FOR=(STANDBY_LOGFILES,<br /> STANDBY_ROLE)<br /> DB_UNIQUE_NAME=pstby' SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_STATE_1=ENABLE<br /> SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_STATE_2=ENABLE<br /> SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_STATE_3=ENABLE<br /> SCOPE=BOTH; </td> </tr> <tr> <td height="198"> PROD </td> <td width="352"> ALTER SYSTEM SET<br /> FAL_SERVER=’pstby’ SCOPE=BOTH;<br /> ALTER SYSTEM SET FAL_CLIENT=’prod’<br /> SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_CONFIG=’dg_config=<br /> (prod,pstby)’ SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> STANDBY_FILE_MANAGEMENT=’AUTO’<br /> SCOPE=BOTH;<br /> 配置歸檔standby引數 </td> <td> PSTBY </td> <td width="455"> ALTER SYSTEM SET FAL_SERVER=’prod’<br /> SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> FAL_CLIENT=’pstby’ SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> LOG_ARCHIVE_CONFIG=’dg_config=<br /> (prod,pstby)’ SCOPE=BOTH;<br /> ALTER SYSTEM SET<br /> STANDBY_FILE_MANAGEMENT=’AUTO’<br /> SCOPE=BOTH; </td> </tr> <tr> <td height="72"> PROD </td> <td width="352"> ALTER SYSTEM SET<br /> LOG_FILE_NAME_CONVERT= ’+PSTBY/’,<br /> ’+PROD/’ SCOPE=SPFILE;<br /> 日誌轉換 </td> <td> PSTBY </td> <td width="455"> ALTER SYSTEM SET<br /> LOG_FILE_NAME_CONVERT= ’+PROD/’,<br /> ’+PSTBY/’ SCOPE=SPFILE; </td> </tr> <tr> <td height="126"> PROD </td> <td width="352"> SHUTDOWN IMMEDIATE<br /> (In an Oracle RAC environment for all instances)<br /> STARTUP MOUNT<br /> ALTER DATABASE FLASHBACK ON;<br /> ALTER DATABASE OPEN;<br /> 開啟閃回資料庫.如果只是測試,可以不開 </td> <td> PSTBY </td> <td width="455"> Optional:<br /> SHUTDOWN IMMEDIATE<br /> STARTUP MOUNT<br /> ALTER DATABASE FLASHBACK ON; </td> </tr> <tr> <td height="90"> PROD </td> <td width="352"> CREATE RESTORE POINT PRE_UPGRADE_1<br /> GUARANTEE FLASHBACK DATABASE;<br /> 建還原點,這個是必須的 </td> <td> PSTBY </td> <td width="455"> Optional:<br /> CREATE RESTORE POINT PRE_UPGRADE_2<br /> GUARANTEE FLASHBACK DATABASE;<br /> RECOVER MANAGED STANDBY DATABASE<br /> USING CURRENT LOGFILE DISCONNECT; </td> </tr> <tr align="center"> <td colspan="4" height="18"> <strong>CONVERSION TO LOGICAL STANDBY STEPS物理standby轉換為邏輯standby</strong> </td> </tr> <tr> <td height="54"> PROD </td> <td> <br /> </td> <td> PSTBY </td> <td width="455"> ALTER DATABASE RECOVER MANAGED<br /> STANDBY DATABASE CANCEL;<br /> 取消日誌應用 </td> </tr> <tr> <td height="66"> PROD </td> <td width="352"> EXECUTE DBMS_LOGSTDBY.BUILD;<br /> 建立logminer字典 </td> <td> PSTBY </td> <td> <br /> </td> </tr> <tr> <td height="142"> PROD </td> <td> <br /> </td> <td> PSTBY </td> <td width="455"> If Oracle RAC then must be mounted exclusive.<br /> ALTER SYSTEM SET<br /> CLUSTER_DATABASE=FALSE<br /> SCOPE=SPFILE;<br /> SHUTDOWN IMMEDIATE<br /> STARTUP MOUNT<br /> 如果是rac,CLUSTER_DATABASE設為false </td> </tr> <tr> <td height="68"> PROD </td> <td> <br /> </td> <td> PSTBY </td> <td width="455"> ALTER DATABASE RECOVER TO LOGICAL<br /> STANDBY KEEP IDENTITY;<br /> 從庫轉換為臨時邏輯standby </td> </tr> <tr> <td height="126"> PROD </td> <td> <br /> </td> <td> PSTBY </td> <td width="455"> If Oracle RAC then reset CLUSTER_DATABASE.<br /> ALTER SYSTEM SET<br /> CLUSTER_DATABASE=TRUE<br /> SCOPE=SPFILE;<br /> SHUTDOWN IMMEDIATE<br /> STARTUP MOUNT<br /> 如果是rac,CLUSTER_DATABASE設為true </td> </tr> <tr> <td height="18"> PROD </td> <td> <br /> </td> <td> PSTBY </td> <td width="455"> ALTER DATABASE OPEN; </td> </tr> <tr> <td height="158"> PROD </td> <td> <br /> </td> <td> PSTBY </td> <td width="455"> Note: If using EDS, skip this step. Do not start<br /> SQL Apply until after the logical standby upgrade and after<br /> the steps for “Configuring EDS Logging Table Triggers” in<br /> Appendix B are run.<br /> ALTER DATABASE START LOGICAL<br /> STANDBY APPLY IMMEDIATE;<br /> 邏輯standby應用sql apply </td> </tr> <tr> <td height="59"> PROD </td> <td> <br /> </td> <td> PSTBY </td> <td width="455"> EXECUTE DBMS_LOGSTDBY.APPLY_SET(<br /> 'LOG_AUTO_DELETE', 'FALSE');<br /> 禁用自動歸檔日誌自動刪除 </td> </tr> <tr> <td height="84"> PROD </td> <td> <br /> </td> <td> PSTBY </td> <td width="455"> Wait for this query to display “IDLE”:<br /> SELECT SESSION_ID, STATE FROM<br /> V$LOGSTDBY_STATE;<br /> 等待邏輯standby狀態為idle </td> </tr> <tr align="center"> <td colspan="4" height="18"> <strong>CREATE AN ARCHIVED REDO LOG REPOSITORY建重做日誌儲存庫(可選)</strong> </td> </tr> <tr align="center"> <td colspan="4" height="18"> <strong>PERFORM PATCH APPLY OR UPGRADE STEPS升級從庫</strong> </td> </tr> <tr> <td height="72"> PROD </td> <td width="352"> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_STATE_2=DEFER<br /> SCOPE=MEMORY;<br /> 停止日誌傳輸 </td> <td> LSTBY </td> <td width="455"> ALTER DATABASE STOP LOGICAL<br /> STANDBY APPLY;<br /> 停止邏輯standby sql apply </td> </tr> <tr> <td height="88"> PROD </td> <td> <br /> </td> <td> LSTBY </td> <td width="455"> CREATE RESTORE POINT PRE_UPGRADE_3<br /> GUARANTEE FLASHBACK DATABASE;<br /> SHUTDOWN IMMEDIATE<br /> 建還原點,用於失敗回退.測試可不用 </td> </tr> <tr> <td height="54"> PROD </td> <td> <br /> </td> <td> PSTBY </td> <td width="455"> RMAN&gt; CATALOG START WITH<br /> '+PSTBY/ALOGREP/ARCHIVELOG/’;<br /> 與重做日誌儲存庫相關 </td> </tr> <tr> <td height="77"> PROD </td> <td width="352"> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_STATE_2=ENABLE<br /> SCOPE=MEMORY;<br /> 開戶日誌傳輸 </td> <td> LSTBY </td> <td width="455"> STARTUP </td> </tr> <tr> <td height="127"> PROD </td> <td> <br /> </td> <td> LSTBY </td> <td width="455"> Note: If using EDS, perform the steps in “Configuring<br /> EDS Logging Table Triggers” in Appendix B before starting<br /> SQL Apply.<br /> ALTER DATABASE START LOGICAL<br /> STANDBY APPLY IMMEDIATE;<br /> 開啟邏輯standby sql apply </td> </tr> <tr align="center"> <td colspan="4" height="18"> <strong>CREATE AN ARCHIVED REDO LOG REPOSITORY建重做日誌儲存庫(可選)</strong> </td> </tr> <tr align="center"> <td colspan="4" height="18"> <strong>SWITCHOVER(主從切換)</strong> </td> </tr> <tr> <td height="116"> PROD </td> <td width="352"> Wait for this query to display “TO STANDBY” or proceed<br /> to switchover with session disconnect<br /> SELECT SWITCHOVER_STATUS FROM<br /> V$DATABASE;<br /> 檢視switchover_status的狀態 </td> <td> LSTBY-&gt;PROD </td> <td> <br /> </td> </tr> <tr> <td height="64"> PROD </td> <td width="352"> ALTER DATABASE COMMIT TO<br /> SWITCHOVER TO LOGICAL STANDBY;<br /> 源主庫切換到邏輯standby </td> <td> LSTBY-&gt;PROD </td> <td> <br /> </td> </tr> <tr> <td height="80"> PROD </td> <td> <br /> </td> <td> LSTBY-&gt;PROD </td> <td width="455"> Wait for this query to display “TO PRIMARY” or proceed<br /> to switchover with session disconnect:<br /> SELECT SWITCHOVER_STATUS FROM<br /> V$DATABASE; </td> </tr> <tr> <td height="54"> PROD </td> <td> <br /> </td> <td> LSTBY-&gt;PROD </td> <td width="455"> ALTER DATABASE COMMIT TO<br /> SWITCHOVER TO LOGICAL PRIMARY;<br /> 源從庫切換為從庫 </td> </tr> <tr> <td height="167"> PROD </td> <td> <br /> </td> <td> LSTBY-&gt;PROD </td> <td width="455"> If using Oracle Streams then start Streams capture. Note<br /> capture will go back in time and mine the redo logs that got<br /> generated while it was down.<br /> exec<br /> dbms_capture_adm.start_capture<br /> ('STRMADMIN_CAPTURE');<br /> 如果有oracle stream,開啟之前停用的 </td> </tr> <tr align="center"> <td colspan="4" height="18"> <strong>RETRANSFORMATION INTO A PHYSICAL STANDBY DATABASE邏輯standby回到物理standby</strong> </td> </tr> <tr> <td height="72"> LSTBY-&gt;PSTBY </td> <td> <br /> </td> <td> PROD </td> <td width="455"> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_STATE_2=DEFER<br /> SCOPE=MEMORY;<br /> 停用日誌傳輸 </td> </tr> <tr> <td height="90"> LSTBY-&gt;PSTBY </td> <td width="352"> SHUTDOWN IMMEDIATE;<br /> STARTUP MOUNT;<br /> FLASHBACK DATABASE TO RESTORE<br /> POINT PRE_UPGRADE_1;<br /> 透過還原點,閃回到還原點. </td> <td> PROD </td> <td> <br /> </td> </tr> <tr> <td height="18"> LSTBY-&gt;PSTBY </td> <td> SHUTDOWN IMMEDIATE; </td> <td> PROD </td> <td> <br /> </td> </tr> <tr> <td height="40"> LSTBY-&gt;PSTBY </td> <td width="352"> Switch to the new ORACLE_HOME<br /> 切換到軟體升級後的ORACLE_HOM </td> <td> PROD </td> <td> <br /> </td> </tr> <tr> <td height="72"> LSTBY-&gt;PSTBY </td> <td width="352"> STARTUP MOUNT;<br /> ALTER DATABASE CONVERT TO PHYSICAL<br /> STANDBY;<br /> 切換邏輯standby為物理standby </td> <td> PROD </td> <td> <br /> </td> </tr> <tr> <td height="36"> PSTBY </td> <td width="352"> SHUTDOWN IMMEDIATE<br /> STARTUP MOUNT; </td> <td> PROD </td> <td> <br /> </td> </tr> <tr> <td height="89"> PSTBY </td> <td width="352"> ALTER SYSTEM SET COMPATIBLE=’...’<br /> SCOPE=SPFILE;<br /> SHUTDOWN IMMEDIATE<br /> STARTUP MOUNT;<br /> 修改相容性引數 </td> <td> PROD </td> <td> <br /> </td> </tr> <tr> <td height="46"> PSTBY </td> <td width="352"> RMAN&gt; CATALOG START WITH<br /> '+PROD/ALOGREP/ARCHIVELOG/’;<br /> 與重做日誌儲存庫相關 </td> <td> PROD </td> <td> <br /> </td> </tr> <tr> <td height="61"> PSTBY </td> <td width="352"> RECOVER MANAGED STANDBY DATABASE<br /> USING CURRENT LOGFILE DISCONNECT;<br /> 開啟物理standby實時應用 </td> <td> PROD </td> <td width="455"> ALTER SYSTEM SET<br /> LOG_ARCHIVE_DEST_STATE_2=ENABLE;<br /> 開啟日誌傳輸 </td> </tr> <tr align="center"> <td colspan="4" height="18"> <strong>SWITCHBACK STEPS(主從切回)</strong> </td> </tr> <tr> <td height="75"> PSTBY-&gt;PROD </td> <td> <br /> </td> <td> PROD-&gt;PSTBY </td> <td width="455"> Wait for this query to display “TO STANDBY” or proceed<br /> to switchover with session disconnect:<br /> SELECT SWITCHOVER_STATUS<br /> FROM V$DATABASE; </td> </tr> <tr> <td height="70"> PSTBY-&gt;PROD </td> <td> <br /> </td> <td> PROD-&gt;PSTBY </td> <td width="455"> ALTER DATABASE COMMIT TO<br /> SWITCHOVER TO STANDBY WITH SESSION<br /> SHUTDOWN;<br /> 切換回物理standby </td> </tr> <tr> <td height="90"> PSTBY-&gt;PROD </td> <td width="352"> Wait for this query to display “TO PRIMARY” or proceed<br /> to switchover with session disconnect:<br /> SELECT SWITCHOVER_STATUS FROM<br /> V$DATABASE; </td> <td> PROD-&gt;PSTBY </td> <td> <br /> </td> </tr> <tr> <td height="54"> PSTBY-&gt;PROD </td> <td width="352"> ALTER DATABASE COMMIT TO<br /> SWITCHOVER TO PRIMARY;<br /> 切換回主庫 </td> <td> PROD-&gt;PSTBY </td> <td> <br /> </td> </tr> <tr> <td height="44"> PSTBY-&gt;PROD </td> <td width="352"> ALTER DATABASE OPEN; </td> <td> PROD-&gt;PSTBY </td> <td width="455"> SHUTDOWN IMMEDIATE;<br /> STARTUP MOUNT; </td> </tr> <tr> <td height="51"> PSTBY-&gt;PROD </td> <td> <br /> </td> <td> PROD-&gt;PSTBY </td> <td width="455"> RECOVER MANAGED STANDBY DATABASE<br /> USING CURRENT LOGFILE DISCONNECT;<br /> 開啟物理standby 實時應用 </td> </tr> <tr> <td height="54"> PROD </td> <td width="352"> SELECT NAME FROM V$RESTORE_POINT<br /> WHERE GUARANTEE_FLASHBACK_DATABASE<br /> =’YES’; </td> <td> PSTBY </td> <td width="455"> SELECT NAME FROM V$RESTORE_POINT<br /> WHERE GUARANTEE_FLASHBACK_DATABASE<br /> =’YES’; </td> </tr> <tr> <td height="45"> PROD </td> <td width="352"> DROP RESTORE POINT PRE_UPGRADE_1;<br /> 刪除之前建的還原點 </td> <td> PSTBY </td> <td width="455"> DROP RESTORE POINT &lt;name&gt;; </td> </tr> <tr> <td height="49"> PROD </td> <td width="352"> ALTER SYSTEM SET<br /> DG_BROKER_START=TRUE SCOPE=BOTH;<br /> 開啟之前關閉的dg broker </td> <td> PSTBY </td> <td width="455"> ALTER SYSTEM SET<br /> DG_BROKER_START=TRUE SCOPE=BOTH; </td> </tr> <tr> <td height="18"> PROD </td> <td width="352"> DGMGRL&gt; enable configuration; </td> <td> <br /> </td> <td> <br /> </td> </tr> </tbody> </table> <br /> <br /> 注意:<br /> 1.轉換為邏輯standby時,要關注不被支援的資料型別,透過dba_logstdby_unsupported檢視.<br /> 2.這種物理standby藉助臨時邏輯standby滾動升級,源從庫升級軟體和資料庫,源主庫升級軟體.源主庫的資料庫升級是透過物理standby以日誌的方式傳過去的.而正常的邏輯standby滾動升級是主從都要進行軟體和資料庫升級的.<br /> 3.在測試環境,主庫的還原點是必須的,就是透過這個還原點把邏輯standby返回到物理standby的.<br /> 4.滾動升級還要考慮主從切換時,客戶端的連線方案.<br /> 5.源從庫升級後,考慮透過database replay,sql performance analyzer,sql plan management進行升級後的效能測試. <br /> <br /> <br /> <br /> <br />

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28211342/viewspace-2130721/,如需轉載,請註明出處,否則將追究法律責任。

相關文章