创建primary和standby的spfile
Primary:
SQL>create spfile from pfile=’d:\initorcl.ora’;
Standby:
SQL>create spfile from pfile=’d:\init.ora’;
1. 验证primary的可切换状态
SQL> select switchover_status from v$database;
2. Switchover to standby
SQL> alter database commit to switchover to physical standby;
如switchover_status为to standby,此操作能正常完成;
如switchover_status为session active,表示此时primary上有活动session,可使用WITH SESSION SHUTDOWN WAIT选项操作或正常关闭活动session;
SQL> alter database commit to switchover to physical standby with session shutdown wait;
如系统为rac,需停止其它所有节点,只保留一个节点时执行切换操作。
3. 关闭primary,启动至mount状态(primary已切换至standby)
SQL>shutdown immediate;
SQL>startup nomount;
SQL>alter database mount standby database;
4. 验证standby的可切换状态
SQL> select switchover_status from v$database;
switchover_status为switchover pending时,需
SQL> alter database recover managed standby database disconnect from session;
应用归档日志恢复数据与primary一致。
5. Switchover to primary
switchover_status为to primary时,可正常切换
SQL>alter database commit to switchover to primary;
6. 关闭standby,启动至open状态(standby已切换至primary)
SQL>shutdown immediate;
SQL>startup;
7. 切换logfile(原standby上)
SQL>alter system switch logfile;
验证此时primary和standby上的数据一致性。
alert_orcl.log中的报错:
Fri Apr 10 22:58:40 2009
Errors in file d:\oracle\product\10.2.0\admin\orcl\udump\orcl_rfs_1932.trc:
ORA-16009: 远程归档日志目标必须为备用数据库
这个错误是因为log_archive_dest_2设置问题,需要在primary和standby两边设置才能解决。
Primary:
SQL> alter system set log_archive_dest_2='service=standby valid_for=(online_logfiles,primary_role) db_unique_name=standby';
Standby:
SQL> alter system set log_archive_dest_2='service=orcl valid_for=(online_logfiles,primary_role) db_unique_name=orcl';
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/17997/viewspace-588838/ ,如需转载,请注明出处,否则将追究法律责任。