先将主库切换成备库,然后将原主库启动到物理库的状态
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO STANDBY
SQL> Alter database commit to switchover to physical standby with session shutdown;
Database altered.
SQL> shut immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2212856 bytes
Variable Size 176163848 bytes
Database Buffers 121634816 bytes
Redo Buffers 4796416 bytes
SQL> alter database mount standby database;
Database altered.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered.
然后将备库切换成主库
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
NOT ALLOWED
SQL> select * from v$version where rownum<2;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
Database altered.
SQL> shut immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> starutp
SP2-0042: unknown command "starutp" - rest of line ignored.
SQL> startup
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2212856 bytes
Variable Size 138415112 bytes
Database Buffers 159383552 bytes
Redo Buffers 4796416 bytes
Database mounted.
Database opened.
切换日志进行检查
SQL> select max(sequence#) from v$log;
MAX(SEQUENCE#)
--------------
108
SQL> alter system switch logfile;
System altered.
参考:
http://blog.csdn.net/leishifei/article/details/6240464