單節點DG的failover切換介紹

龍山游龍發表於2015-07-12
一般我們在搭建DG的過程中,通常都會進行switchover和failover切換演練,不過對於客戶來說,他們更加註重failover切換演練,關心的東西才會關注。本章就簡單介紹下failover切換介紹
1、當生產庫異常當機了,在備庫上檢視是否有日誌GAP
1) 檢視是否有日誌GAP:
SQL> SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;
no rows selected
2) 如果有,則複製過來
3) 手工的註冊這些日誌:
SQL>  ALTER DATABASE REGISTER LOGFILE '路徑';
注:如果返回的有記錄,按照返回資訊對應的複製歸檔檔案到待轉換的standby伺服器。這一步非常重要,必須確保所有已生成的歸檔檔案均已存在於standby 伺服器,不然可能會資料不一致造成轉換時報錯
2、結束日誌apply
SQL>  alter database recover managed standby database cancel; #停止歸檔日誌應用
3、停止接收日誌
SQL>  alter database recover managed standby database finish force; #停止日誌接收,結束備庫活動著的RFS程式,以便執行failover切換
4、切換資料庫為primary
SQL>  alter database commit to switchover to primary with session shutdown;
5、open資料庫
SQL> alter database open;
注:恢復備庫:recover standby database until cancel;啟用備庫:alter database activate standby database;

具體操作筆記:
SQL> SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;

no rows selected

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database recover managed standby database finish force;

Database altered.

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY TO PRIMARY

SQL> alter database commit to switchover to primary with session shutdown;

Database altered.

SQL> alter database open;

Database altered.

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS
---------------- --------------------
PRIMARY          FAILED DESTINATION

SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
beiku            OPEN

SQL> select NAME,RESETLOGS_TIME,LOG_MODE,OPEN_MODE,PROTECTION_MODE,REMOTE_ARCHIVE,DATABASE_ROLE,SWITCHOVER_STATUS,FORCE_LOGGING  from v$database;

NAME      RESETLOGS LOG_MODE     OPEN_MODE            PROTECTION_MODE      REMOTE_A DATABASE_ROLE    SWITCHOVER_STATUS    FOR
--------- --------- ------------ -------------------- -------------------- -------- ---------------- -------------------- ---
XUH       12-JUL-15 ARCHIVELOG   READ WRITE           MAXIMUM PERFORMANCE  ENABLED  PRIMARY          FAILED DESTINATION   YES

SQL>


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

相關文章