oracle Physical Standby failover step

paulyibinyi發表於2015-12-28

 Performing a Failover to a Physical Standby Database

以下是failover步驟


Step 1   Flush any unsent redo from the primary database to the target standby database.


在主庫執行以下命令

ALTER SYSTEM FLUSH REDO TO target_db_name

Step 2   Verify that the standby database has the most recently archived redo log file for each primary database redo thread.

查詢V$ARCHIVED_LOG檢視看最近的歸檔有沒傳送到備庫

For example:

SQL> SELECT UNIQUE THREAD# AS THREAD, MAX(SEQUENCE#) -
OVER (PARTITION BY thread#) AS LAST from V$ARCHIVED_LOG;
    
THREAD       LAST
---------- ----------        
 1        100

如果沒有應用,則手工應用

For example:

SQL> ALTER DATABASE REGISTER PHYSICAL LOGFILE 'filespec1';

Step 3   Identify and resolve any archived redo log gaps.
檢視有沒丟失相關歸檔,然後手工註冊

Query the V$ARCHIVE_GAP view on the target standby database to determine if there are any redo gaps on the target standby database.

For example:

SQL> SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP; THREAD#    LOW_SEQUENCE# HIGH_SEQUENCE#---------- ------------- --------------         1            90             92

For example:

SQL> ALTER DATABASE REGISTER PHYSICAL LOGFILE 'filespec1';

Step 4   Repeat Step 3 until all gaps are resolved.

重複上面的檢查

Step 5   Stop Redo Apply.

備庫停止日誌應用

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Step 6   Finish applying all received redo data.
備庫完全日誌應用

Issue the following SQL statement on the target standby database:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;

Step 7   Verify that the target standby database is ready to become a primary database.
檢查相關狀態

Query the SWITCHOVER_STATUS column of the V$DATABASE view on the target standby database.

For example:

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE; SWITCHOVER_STATUS-----------------
TO PRIMARY1 row selected


Step 8   Switch the physical standby database to the primary role.

failover成主庫

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;

Note:

The WITH SESSION SHUTDOWN clause can be omitted from the switchover statement if the query of the SWITCHOVER_STATUS column performed in the previous step returned a value of TO PRIMARY.

Step 9   Open the new primary database.

SQL> ALTER DATABASE OPEN;
開啟資料庫

Step 10   Back up the new primary database.

Oracle recommends that a full backup be taken of the new primary database.

對開啟的主庫進行備份。


If the error condition cannot be resolved, a failover can still be performed (with some data loss) by issuing the following SQL statement on the target standby database:
如果有相關歸檔丟失等,則丟失部分資料,直接啟用standby 資料庫即可

SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;



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

相關文章