--- 主库操作
alter system archive log current;
alter system checkpoint;
select switchover_status from v$database;
alter database commit to switchover to physical standby with session shutdown;
startup mount;
--- 备库操作
select switchover_status from v$database;
alter database commit to switchover to primary with session shutdown;
alter database open;
--- 切换后备库操作
alter database open;
alter database recover managed standby database using current logfile disconnect from session;
--- 下面为切换输出过程
sys@DBPOD> alter system archive log current;
System altered.
sys@DBPOD> alter system checkpoint;
System altered.
sys@DBPOD> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO STANDBY
sys@DBPOD> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
ERROR:
ORA-01034: ORACLE not available
Process ID: 13037
Session ID: 21 Serial number: 543
Database altered.
sys@DBPOD> select status from v$instance;
select status from v$instance
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 13037
Session ID: 21 Serial number: 543
ERROR:
ORA-01034: ORACLE not available
Process ID: 13037
Session ID: 21 Serial number: 543
sys@DBPOD> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
[oracle@dbtest5 dbpod]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Jul 22 14:52:13 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
idle> startup mount;
ORACLE instance started.
Total System Global Area 3290345472 bytes
Fixed Size 2257720 bytes
Variable Size 2113932488 bytes
Database Buffers 1157627904 bytes
Redo Buffers 16527360 bytes
Database mounted.
sys@DBPOD> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
sys@DBPOD> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
Database altered.
sys@DBPOD> ALTER DATABASE OPEN;
Database altered.
sys@DBPOD> select status from v$instance;
STATUS
------------
OPEN
sys@DBPOD> select open_mode from V$DATABASE;
OPEN_MODE
--------------------
READ WRITE
idle> alter database open;
Database altered.
idle> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
Database altered.