主備庫切換原因:
1. switch:用戶主動(dòng)切換;
2. failover:主庫出現(xiàn)故障,強(qiáng)行切換;
switch切換過程:先主庫再備庫
主庫
1. 查看switchover_status:select database_role, switchover_status from v$database;
如果switchover_status為:to standby 則:
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY
否則用:ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
2. 重啟數(shù)據(jù)庫:
shutdown immediate;
startup nomount;
3. 以備庫mount
alter database mount standby database;
備庫
1. 應(yīng)用redo:alter database recover managed standby database disconnect from session;
2. 查看switchover_status:select database_role, switchover_status from v$database;
如果switchover_status為:to primary 則:ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY
否則用:ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
3. 重啟數(shù)據(jù)庫
shutdown immediate;
startup;
failover 主備庫切換
1.. 停止日志應(yīng)用
alter database recover managed standby database cancel;
2. 關(guān)閉standby日志傳輸
alter database recover managed standby database finish force;
3. 切換到primary
alter database commit to switchover to primary with session shutdown;
做這一步的時(shí)候,若存在gap,則會(huì)報(bào)ORA-16139:Switchover: Media recovery required - standby not in limbo 錯(cuò)誤。
做測(cè)試的時(shí)候,若先起主庫再起備庫,且未等待備庫相關(guān)日志傳輸完畢,就會(huì)出現(xiàn)這個(gè)問題。此時(shí)需要強(qiáng)制切換
alter database activate physical standby database;
4. 重啟數(shù)據(jù)庫到open狀態(tài)
當(dāng)前題目:ORACLEDataGuard主備庫角色切換
網(wǎng)站網(wǎng)址:
http://weahome.cn/article/gogcco.html