DG物理standby,Failover之後原primary重回DG

panpong發表於2014-09-09

DG物理standbyFailover之後原primary重回DG

       如果failover之前,主備都開了flashback,當原主庫恢復正常後,則可透過以下步驟重回DG

步驟1.在新主庫上查詢failover時的SCN

SQL> SELECT TO_CHAR(STANDBY_BECAME_PRIMARY_SCN) FROM V$DATABASE;

 

步驟2.在原主庫上flashback failover時的scn

SQL> SHUTDOWN IMMEDIATE;

SQL> STARTUP MOUNT;

SQL> FLASHBACK DATABASE TO SCN standby_became_primary_scn;

 

步驟3.轉換原主庫到備庫狀態

SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;

SQL> SHUTDOWN IMMEDIATE;

SQL> STARTUP MOUNT;

 

步驟4.同步、應用日誌

 原主庫:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;

 

在原主庫上flashback failover時的scn時報錯的處理:

由於原主庫沒有開flashback,以至於flashback失敗,然後透過recover database

SQL> select checkpoint_change# from v$database;

 

CHECKPOINT_CHANGE#

------------------

          20359173

 

SQL> flashback database to scn 20359173;

flashback database to scn 20359173

*

ERROR at line 1:

ORA-38729: Not enough flashback database log data to do FLASHBACK.

查詢一下能閃回的最早scn

SQL> select oldest_flashback_scn,

     to_char(oldest_flashback_time,'YYYY-MM-DD HH24:MI:SS')

    from v$flashback_database_log;

OLDEST_FLASHBACK_SCN TO_CHAR(OLDEST_FLAS

-------------------- -------------------

            20382748 2014-03-05 15:24:16

 

這個明顯是flashback開的太遲,沒有足夠的日誌;為了能使資料庫回到scn20359173的點上,做一次不完全恢復;

Rman>run{

Startup force mount;

Set until scn=20359173; # SET UNTIL SCN ;

Restore database;

Recover database;

}

執行過程中仍然報錯ORA-38729,查詢了CHECKPOINT_CHANGE#仍是20382748,以為沒有成功,然後又做了一次不完全恢復

RMAN>shutdown immediate

RMAN>startup mount

RMAN>restore database until scn 20359173;

RMAN>recover database until scn 20359173;

查詢了CHECKPOINT_CHANGE#仍是20382748,於是再一次做不完全恢復:

SQL>recover database until change 20359173;

Media recovery complete.

很快就完成了恢復;此時,嘗試如下操作:

SQL> select switchover_status from v$database;

 

SWITCHOVER_STATUS

--------------------

NOT ALLOWED

 

SQL> alter database open read only;

alter database open read only

*

ERROR at line 1:

ORA-16005: database requires recovery

 

最後直接執行主庫轉備庫操作,順利完成;

SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;

 

Database altered.

查詢日誌,新主庫已經開始傳日誌檔案,日誌檔案傳完後啟動備庫的日誌用也可以順利進行,一直到實時同步;

 

透過以上的操作,可以推測不完全恢復應該是成功的推到了指定SCN處,只是查詢SCN地方不對;現在猜測應該查詢v$databasecurrent_scn欄位,有待日後考證;

 

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

相關文章