1. 程式人生 > >Data Guard 主備庫角色轉換

Data Guard 主備庫角色轉換

1.5 total abort ase required using art gap edi

1. switchover操作

1.1 備庫先關閉實時日誌應用

standby>alter database recover managed standby database cancel;

1.2 主庫先判斷是否可以支持switchover操作

primary> select switchover_status from v$database;

該值為:TO STANDBY;表示支持。
該值為:SESSION ACTIVE;表示主庫有激活會話。不妨礙switchover操作。

1.3 啟動switchover;主庫轉換physical standby。

若上值為第二種情況;後面需加 with shutdown session
即 alter database commit to switchover to physical standby with shutdown session;

primary> alter database commit to switchover to physical standby;
Database altered.

1.4 重啟原primary庫

Primary> shutdown immediate;

ORA- 01507 : database not mounted
ORACLE instance shut down.
Primary> startup
ORACLE instance started.

Total System Global Area 1.5132E+10 bytes
Fixed Size            
2243112 bytes Variable Size 2013267416 bytes Database Buffers 1.3086E+10 bytes Redo Buffers 30552064 bytes Database mounted. Database opened.

1.5 物理standby切換為primary

standby>alter database commit to switchover to primary;
alter database commit to switchover to primary
*
ERROR at line 
1: ORA-16139: media recovery required standby>alter database recover managed standby database disconnect from session; Database altered. standby>alter database commit to switchover to primary; Database altered.

1.6 重啟新primary

standby> alter database open;
Database altered.

1.7 新physical standby啟動實時日誌應用

Primary> alter database recover managed standby database using current logfile disconnect from session;

2.failover操作

模擬主庫掛掉

Primary> shutdown abort;
ORACLE instance shut down.

2.1 檢查歸檔文件是否連續

查詢待轉換standby 數據庫的V$ARCHIVE_GAP 視圖,確認歸檔文件是否連接

StandBy>  SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP; 
no rows selected

如果有,則拷貝過來;
手工的註冊這些日誌:
StandBy> ALTER DATABASE REGISTER LOGFILE ‘路徑‘;

2.2 啟動failover,備庫切換主庫操作。

StandBy> alter database recover managed standby database finish force;
Database altered.

StandBy> alter database commit to switchover to primary;
Database altered.

StandBy> alter database open;
Database altered.

2.3 將原primary庫重建備庫操作

參考博客:http://www.cnblogs.com/lottu/p/7054731.html;http://www.cnblogs.com/lottu/p/7058774.html

實施數據庫克隆(輔助實例啟動到nomount狀態後)

應用redo日誌操作;或者 啟動實時應用redo日誌操作。

參考文獻:《三思筆記第10.2.4章節》

Data Guard 主備庫角色轉換