#查看切换状态以及角色
select open_mode,database_role,protection_mode,protection_level,switchover_status from v$database;
#查看adg进程信息
select process,status,thread#,sequence# from v$managed_standby;
#切换日志
alter system switch logfile;
#归档当前日志
alter system archive log current;
#切换成备库并当前关闭会话
alter database commit to switchover to physical standby with session shutdown;
#强制停止数据库
shutdown abort
#启动到mount状态
startup mount
#查询切换状态以及数据库角色
select switchover_status,database_role from v$database;
#开启数据库,此时应是read only
alter database open;
原备库10.10.11.2
#查看是否存在gap(若存在,自行寻找解决办法)
SELECT thread#, low_sequence#, high_sequence# FROM v$archive_gap;
#查看状态以及角色
select open_mode,database_role,protection_mode,protection_level,switchover_status from v$database;
#切换成新主库
alter database commit to switchover to primary with session shutdown;
#打开数据库(read write)
alter database open;
#查看adg进程信息
select process,status,thread#,sequence# from v$managed_standby;
#查询切换状态以及数据库角色
select switchover_status,database_role from v$database;
原主库,新备库
#新备库上查看(READ ONLY)
select open_mode from v$database;
#新备库上执行日志应用
alter database recover managed standby database using current logfile disconnect from session;
#查看新备库切换状态
select open_mode,database_role,protection_mode,protection_level,switchover_status from v$database;
#查看进程信息,关注mpr进程是否启动
select process,status,thread#,sequence# from v$managed_standby;
#再次查看主备延迟信息(apply finsh time可能为空,等待一段时间就可以了)
select * from v$dataguard_stats;