Oracle Data Guard (四) Failover
1.检查Standby数据库上有遗漏掉Log
用下列命令检查是否有漏掉的log:
SQL> select thread#,log_sequence#,high_sequence# from v$archive_gap;
把漏掉的log文件从primary 数据库拷贝到standby数据库指定的log目录,用以下命令注册进standby数据库:
SQL> alter database register physical logfile ‘filespec1’;SQL> alter database recover managed standby database cancel;
SQL> alter database recover managed standby database finish;
SQL> select switchover_status from v$database;
只有状态为 "TO PRIMARY" 或者 "SESSIONS ACTIVE" 才能对Standby数据库进行角色切换。SQL> alter database commit to switchover to primary with session shutdown;
SQL> alter database open;得到新Primary 角色的standby数据库的SCN:
SQL> select to_char(standby_became_primary_scn) from v$database;
}
切换primary数据库为physical standby角色:
SQL> alter database covert to physical standby;
SQL> shutdown immediate;SQL> startup mount;
打开为只读方式同步log file,然后再重启动:
SQL> alter database open read only;
SQL> shutdown immediate;SQL> startup mount;
SQL> alter database recover managed standby database using current logfile disconnect;
另外可以从当前Primary角色的standby数据库的备份去重建primary数据库,或者重复standby执行过程,通过RMAN脚本重建primary数据库。