C:\Users\Administrator> lsnrctl status
主库
备库
主库
SQL> select database_role, switchover_status from v$database;
SQL> select name, database_role, open_mode from gv$database;
备库
SQL> select database_role, switchover_status from v$database;
SQL> select name, database_role, open_mode from gv$database;
MOUNT状态或者REDA ONLY都是正常状态
主库
SQL> select thread#, sequence#, applied from v$archived_log order by sequence#;
备库
SQL> select thread#, sequence#, applied from v$archived_log order by sequence#;
主库切换日志
SQL> alter system archive log current;
主库查看日志情况
SQL> select thread#, sequence#, applied from v$archived_log order by sequence#;
备库查看日志情况
SQL> select thread#, sequence#, applied from v$archived_log order by sequence#;
主库和备库都增加一条日志记录,并且备库的日志是IN-MEMORY或者YES证明ADG正常,如果是NO的,可能是业务量大,需要等待一点时间,时间长短结合实际情况具体分析。
SQL> alter system set log_archive_dest_state_2= 'defer';
SQL> alter database recover managed standby database cancel;
SQL> shutdown immediate
SQL> shutdown immediate
接下来服务器就可以断电
SQL> select instance_name,status,database_status from gv$instance;
主库
备库
如未启动,执行startup启动数据库,备库使用startup命令会启动到只读状态。
C:\Users\Administrator> lsnrctl status
主库
备库
如果与示例不符,则需要启动或等待,直到与示例相同
SQL> alter system set log_archive_dest_state_2 = 'enable';
SQL> alter database recover managed standby database disconnect;
采用下面的方法直接强制激活物理standby为主库 –activate方式
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
RECOVER STANDBY DATABASE UNTIL CANCEL;
ALTER DATABASE ACTIVATE STANDBY DATABASE;
SHUTDOWN IMMEDIATE;
STARTUP
Failover本身属于灾难恢复,当发生后基于现有系统情况,只能重建整个DG环境。