即把原来的主库重建为当前库的Standby库。常规做法是重来一遍备份,拷贝,恢复等耗时操作。
不过这里介绍的是利用Flashback Database来快速完成恢复。
前提Failover之前,在旧的Primary数据库上已开启过闪回.
a. alter system set db_recovery_file_dest_size=2g scope=both;
b. alter sysetem set db_recovery_file_dest=‘/u01/app/oracle/oradata/xcldb/fra‘ scope=both;
c. shutdown immediate;
d. startup mount;
e. alter database flashback on;
f. alter database open;
Step 1 Determine the SCN which the old standby database became the primary database
即得到Failover之后,新的主库的生成时的scn.
SELECT to_char(standby_became_primary_scn) FROM v$database;
Step 2. Flash back the failed primary database.
Shut down the old primary database(if necessary),mount it,and flash it back to the
value for STANDBY_BECAME_PRIMARY_SCN that was determined in Step 1.
在旧主库上,利用闪回库功能把旧的主库回滚到这个scn上
2.1 关闭旧主库
shutdown immediate;
2.2 启动到mount状态,执行闪回
startup mount;
flashback database to scn xxx; -- xxx 即查出来的standby_became_primary_scn的值
转换旧的primary为staneby状态
3.1 Issue the following statement on the old primary database:
alter database convert to physical staneby;
3.2 Shut down and restart the database:
shutdown immediate;
startup mount;
现在可以开始主备间同步了。
4.1 重要,查询并确认归档参数设置是否正确. 因为以前是主库。现在要作为备库,要检查是否 要调整参数或Standby log之类是否有建。
SELECT dest_id,dest_name,status,protection_mode,destination,error,srl FROM V$ARCHIVE_DEST_STATUS;
4.2 如没问题,将其激活
alter system set log_archive_dest_state_n=enable;
4.3 通过在主库做日志切换,检查下日志配置是否生效。
alter system switch logfile;
--如果切换后,发现standby库恢复操作中止,再执行一次同步命令就行了。
SELECT dest_id,dest_name,status,protection_mode,destination,error,srl FROM V$ARCHIVE_DEST_STATUS;
Step 5 Start Redo Apply on the new physical standby database.
开始数据同步
alter database recover managed standby database using current logfile disconnect from session;
整理自Oracle官方文档.
MAIL: xcl_168@aliyun.com
BLOG: http://blog.csdn.net/xcl168
DG(2)Flashing Back a Failed Primary Database into a Physical Standby Database,布布扣,bubuko.com
DG(2)Flashing Back a Failed Primary Database into a Physical Standby Database