1、检验主数据库是执行切换的前提条件
1.1 主库上运行
ALTER SYSTEM ARCHIVE LOG CURRENT;
select THREAD#,sequence#,FIRST_TIME, NEXT_TIME from v$archived_log where DEST_ID=1 order by FIRST_TIME;
1.2 备库上运行
Set linesize 200
select THREAD#,SEQUENCE#,ARCHIVED,APPLIED ,FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG order by FIRST_TIME;
1.3 核对以上输出结果一致后,关闭主、备库第二节点(Oracle19C不用关闭第二节点)
1.4 主库上运行
SELECT SWITCHOVER_STATUS FROM V$DATABASE;期望输出结果为:TO STANDBY或SESSION ACTIVE
1.5 备库上运行
SELECT SWITCHOVER_STATUS FROM V$DATABASE;期望输出结果为:NOT ALLOWED
2、主库上发起切换
2.1 主库上运行
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
2.2 重启实例:
startup nomount;
alter database mount standby database;
alter database add standby logfile THREAD 1 group 21 ‘+DATA’ size 100m;
alter database add standby logfile THREAD 2 group 22 ‘+DATA’ size 100m