非計畫的容錯移轉

容錯移轉是假設主要資料庫遺失的非計畫事件。套用來自主要資料庫的所有可用 redo 資料之後,待命資料庫就會立即轉換成主要資料庫。

復原未計畫的容錯移轉

容錯移轉是非計畫性事件或中斷,可能包括資料遺失。容錯移轉之後,必須將原始主要資料庫恢復為實體待命資料庫。當您有倒溯資料庫和 Oracle Data Guard Broker 時,便可輕鬆恢復原始的主要資料庫。

在此範例中,ORCLCDB 是內部部署資料庫的名稱,而 orclcdb_iad1s3 是雲端中資料庫執行處理的名稱。此範例中的步驟 3 會關閉主要內部部署資料庫,以模擬未計畫的中斷。
  1. sys 使用者和密碼身分登入內部部署主要資料庫上的 DGMGRL 階段作業。
    DGMRGL> connect
  2. 顯示內部部署資料庫的組態。
    DGMGRL> show configuration;
    輸出看起來應該類似於下列內容:
    Configuration - onpremdr
    
      Protection Mode: MaxPerformance
      Members:
      orclcdb        - Primary database
        orclcdb_iad1s3 - Physical standby database 
    
    Fast-Start Failover:  Disabled
    
    Configuration Status:
    SUCCESS(status updated 32 seconds ago)
  3. 連線主要資料庫執行處理並執行關閉,以模擬非計畫性中斷。
    bash-4.2$ sqlplus / as sysdba
    SQL> shutdown abort;
    輸出看起來應該類似於下列內容:
    ORACLE instance shut down.
  4. 顯示 Oracle Cloud Infrastructure (OCI) 中待命資料庫執行處理的組態。
    DGMGRL> show configuration;
    輸出看起來應該類似於下列內容:
    Configuration - onpremdr
      Protection Mode: MaxPerformance
      Members:
      orclcdb        - Primary database
        Error: ORA-1034: ORACLE not available
    
        orclcdb_iad1s3 - Physical standby database 
    
    Fast-Start Failover:  Disabled
    
    Configuration Status:
    ERROR   (status updated 0 seconds ago)
  5. 起始容錯移轉。
    DGMGRL> > failover to ORCLCDB_iad1s3;
    輸出看起來應該類似於下列內容:
    Performing failover NOW, please wait...
    Failover succeeded, new primary is "orclcdb_iad1s3"
  6. 顯示 Oracle Cloud Infrastructure (OCI) 中資料庫執行處理的組態。
    DGMGRL> show configuration;
    輸出看起來應該類似於下列內容:
    Configuration - onpremdr
    
      Protection Mode: MaxPerformance
      Members:
      orclcdb_iad1s3 - Primary database
        orclcdb        - Physical standby database (disabled)
          ORA-16661: the standby database needs to be reinstated
    
    Fast-Start Failover:  Disabled
    
    Configuration Status:
    SUCCESS   (status updated 48 seconds ago)
  7. 恢復原始的內部部署主要資料庫 (此範例中的 ORCLCDB)。
    恢復會讓舊的主要資料庫停止作用,讓它能夠接收來自新主要 (啟動的待命資料庫) 的 redo 資料。

    如果您想要讓原始主要資料庫成為主要資料庫執行處理 (容錯移轉時),請在恢復之前,先在原始主要資料庫的一個執行處理上執行 startup mount

    SQL> startup mount;
  8. 在雲端的資料庫執行處理 (此範例中的 orclcdb_iad1s3) 上,使用 reinstate database 命令復原原始的內部部署主要資料庫。
    DGMGRL> reinstate database ORCLCDB;
    輸出看起來應該類似於下列內容:
    Reinstating database
            "orclcdb", please wait...Reinstatement of database
            "orclcdb" succeeded
  9. 顯示 Oracle Cloud Infrastructure (OCI) 中待命資料庫執行處理的組態。
    DGMGRL> show configuration;
    輸出看起來應該類似於下列內容:
    Configuration - onpremdr
    
      Protection Mode: MaxPerformance
      Members:
      orclcdb_iad1s3 - Primary database
        orclcdb        - Physical standby database 
    
    Fast-Start Failover:  Disabled
    
    Configuration Status:
    SUCCESS   (status updated 47 seconds ago