Switchover 切换步骤
1、 查询主从数据库数据是否已经同步
SQL> select max(sequence#) from v$archived_log;
SQL> select sequence#,applied from v$archived_log order by sequence#;
2、在主库
SQL> select switchover_status from v$database;
SQL> alter database commit to switchover to standby with session shutdown;
(switchover_status的值入股是To standby,可以直接switchover,如果是sessions active,
则需要在switchover的命令后面加上with session shutdown;)
SQL> shutdown immediate;
3、在从库
SQL> select switchover_status from v$database;
SQL> alter database commit to switchover to primary with session shutdown;
(switchover_status的值入股是To standby,可以直接switchover,如果是sessions active,
则需要在switchover的命令后面加上with session shutdown;)
4、修改主从库tnsnames.ora文件的对应关系
5、切换后的主库
SQL> startup
SQL> alter system set log_archive_dest_2='service=standby mandatory reopen=60';
切换后的从库
SQL> startup nomount;
SQL> alter database mount standby database;
SQL> alter database recover managed standby database disconnect from session;
切换后的主库
SQL> alter system switch logfile;
6、查询切换后的主从数据库数据是否已经同步
SQL> select max(sequence#) from v$archived_log;
SQL> select sequence#,applied from v$archived_log order by sequence#;