--正确打开备库 startup mount; alter database recover managed standby database disconnect from session; --应用重做日志 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE; --正确关闭备库 alter database recover managed standby database cancel; alter database open; shutdown immediate; --查看主备库 select name,open_mode,database_role,db_unique_name from v$database; --主库查看当前日志状况 select sequence#,status from v$log; --备库接收日志情况 select process,status,thread#,sequence#,blocks from v$managed_standby; select archived_thread#,archived_seq#,applied_thread#,applied_seq# from v$archive_dest_status; --查看备库已经应用的redo select thread#,sequence#,first_change#,next_change# from v$log_history; select dest_name,status,destination,target,archiver,schedule,valid_type,valid_role,db_unique_name from v$archive_dest; select thread#,group#,sequence#,status,arcived,first_change#,first_time,last_change#,last_time from v$standby_log; select thread#,low_sequence#,high_sequence# from v$archive_gap; select * from v$dataguard_status; select sequence#,standby_dest,archived,applied from v$archived_log order by sequence# desc; select * from v$archive_dest_status; --角色切换,switchover --主库处理 --如果switch_status的值为to standby则可以正常切换,如果为session active 则表示牌active则不允许切换 select switchover_status from v$database; --如果switch_status的值为to standby则: alter database commit to switchover to physical standby; --如果switch_status的值为session active则: alter database commit to switchover to physical standby with session shutdown; --重启先前的主库 shutdown immediate; startup mount; select name,open_mode,database_role,db_unique_name from v$database; --备库处理 --将目标备库转换为主库 select switchover_status from v$database; --如果switch_status的值为to primary则: alter database commit to switchover to primary; --如果switch_status的值为session active则: alter database commit to switchover to primary with session shutdown; alter database open;