激活同步
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=defer;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=enable;
查看打开状态及切换状态。
select name,open_mode,switchover_status from v$database;
备库取消应用归档和重做日志
alter database recover managed standby database cancel;
备库开启应用归档和重做日志
alter database recover managed standby database disconnect from session;
实时应用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
查看进程
select pid,process,thread#,status,SEQUENCE# from gv$managed_standby order by 1,2;
查看最大归档号是否一致
SELECT max(sequence#) from v$archived_log where applied='YES';
查看归档应用情况
select sequence#,standby_dest,archived,applied,status from v$archived_log;
在进行主备切换时备库状态为not allowed
1.先查看日志是否有报错
cd /u01/app/oracle/diag/rdbms/std/std/alert
tail -n 30 log.xml
如果没有报错继续排查
2.查看当前备库状态
如果open_mode状态是read only 而不是read only with apply,则说明没有开启日志应用,输入一下命令开启
alter database recover managed standby database using current logfile disconnect;
3.查看归档是否应用
select sequence#,standby_dest,archived,applied,status from v$archived_log;
主库
说明此时归档已经应用。如果不一致就开启日志应用
4.主库,将所有未传送的redo传送给从库
## target_db_name使用DB_UNIQUE_NAME
ALTER SYSTEM FLUSH REDO TO target_db_name;
此时再查看发现备库的状态变为了to primary