-----主库defer 日志传输alter system set log_archive_dest_2=defer;---enable 日志传输:alter system set log_archive_dest_2=enable;-----备库(mount)配置 flashback database:STANDBY DATABASE: Stop redo apply, configure flashback retention,start flashback database, open the database and start redo apply (Is active DG).---检查备库是否启用flashback database:select flashback_on from v$database;注意这里需要确认下备库打开模式: mount看readonly with apply看在11g 环境下备库可能启用了 ADG 特性 备库日志处于实时应用,数据库模式为 readonly with apply这时需要重启数据库到mount状态修改flashback database 模式;如果备库处于mount 状态,可以先取消日志apply ,直接打开闪回数据库特性;---取消备库日志应用:ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;---需要配置一下两个参数来打开flashback database 特性:ALTER SYSTEM SET db_recover_file_dest='/lixora/lixora/lixora/';ALTER SYSTEM SET db_recover_file_dest_size=100G;ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=240; ---4hoursALTER DATABASE FLASHBACK ON;--手工创建还原点(该步骤没有测试过):Creating Restore point in Physical Standby:CREATE RESTORE POINT before_damage GUARANTEE FLASHBACK DATABASE-------备库failover to primary db 应急切换步骤:(注:模拟主库由于故障无法正常switchover,需要执行failover,强制备库->pridb并接管业务)1.备库:由于是failover,所以理解主库这时候已经无法正常使用,只需备库切换至pridb【前提主库还是可用的:可选】查询没有应用的日志:SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;select distinct thread#,max(sequence#) over(partition by thread#) a from v$archived_log;该语句取得当前数据库各线程已归档文件最大序号,如果primary 与standby 最大序号不相同,必须将多出的序号对应的归档文件复制到待转换的standby服务器。Cp过来并registerALTER DATABASE REGISTER PHYSICAL LOGFILE 'filespec1'停止应用恢复模式alter database recover managed standby database finish;orALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH FORCE;转换standbydb为primary dbalter database commit to switchover to primary;重启数据库,恢复正常业务alter database open;数据库角色查看:select open_mode,database_role from v$database;OPEN_MODE DATABASE_ROLE---------- ----------------OPEN PRIMARY------恢复failover 的备库:C. Using SQL*PLUSStep 1 Determine the Standby Became Primary SCN.Step 2 Flashback the Failed Primary Database.Step 3 Convert to physical standby database.Step 4 Restart Redo Transport.Step 5 Start Redo Apply.Step 1 Determine the SCN at which the old standby database became the primary database.SQL> SELECT TO_CHAR(STANDBY_BECAME_PRIMARY_SCN) FROM V$DATABASE;Step 2 Flashback the Failed Primary Database to SCN standby_became_primary_scn.SQL> SHUTDOWN IMMEDIATE;SQL> startup mountSQL> FLASHBACK DATABASE TO SCN ;Step 3 Convert the database to a physical standby database and Restart database in mount stage.SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;SQL> SHUTDOWN IMMEDIATE;SQL> STARTUP MOUNT;Step 4 Restart Redo Transport to the New Physical Standby Database.1. If you have not set the remote archive destination on current primary then set remote archive destination:SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_2 = 'SERVICE=lixora VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=lixora' SCOPE=BOTH;2. Enable the destinationSQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;3. Perform a log switch to ensure that standby database begins receiving redo data from the new primary databaseSQL> ALTER SYSTEM SWITCH LOGFILE;SQL> SELECT DEST_ID, STATUS, ERROR FROM V$ARCHIVE_DEST WHERE DEST_ID=2;