1.检查主库的状态:
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO STANDBY
2.将主库设置为standby role
alter database commit to switchover to physical standby;
shutdown immediate;
startup mount;
3.将standby转为primary
SQL> select NAME ,DB_UNIQUE_NAME ,open_mode,DATABASE_ROLE from v$database;
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE
--------- ------------------------------ -------------------- ----------------
ORCL sty MOUNTED PHYSICAL STANDBY
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
alter database commit to switchover to primary;
alter database open;
SQL> select NAME ,DB_UNIQUE_NAME ,open_mode,DATABASE_ROLE from v$database;
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE
--------- ------------------------------ -------------------- ----------------
ORCL sty READ WRITE PRIMARY
4.原来的primary库上执行:
alter database recover managed standby database disconnect from session;
SQL> select NAME ,DB_UNIQUE_NAME ,open_mode,DATABASE_ROLE from v$database;
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE
--------- ------------------------------ -------------------- ----------------
ORCL pri MOUNTED PHYSICAL STANDBY