一:switchover同failover的区别
A switchover allows the primary database to switch roles with its standby database. There is no data loss during a switchover. You can switch back to the original Primary database later by performing another switchover.
In case of primary database failure, you will need to perform failover to transition the standby database to the primary role. After a failover, the original primary database can no longer participate in the Data Guard configuration. So if the original Primary database is still accessible, you should always consider a switchover first.
以上概况来讲就是可以自由的主库和备库间进行switchover切换,期间不会有数据的丢失;faliover只有在主库故障的情况下,才需要去执行,当执行过failover,原先的主库将不再参与data guard的配置,所以在主库可用的情况下,应当先进行switchover
二:Before Switchover:
1. test the Switchover first on your testing systems before working on Production.
2. Verify the primary database instance is open and the standby database instance is mounted.
3. Verify there are no active users connected to the databases.
4. Make sure the last redo data transmitted from the Primary database was applied on the standby database.
Issue the following commands on Primary database and Standby database to find out:
Perform SWITCH LOGFILE if necessary.
SQL>select sequence#, applied from v$archvied_log;
In order to apply redo data to the standby database as soon as it is received, use Real-time apply.
在执行switchover切换前应当进行测试,验证主库是否处在open状态,备库是否处在mount状态,保证没有用户连接到数据库,确定所有从主库传送过来redolog在备库上都应经成功应用,可以使用实时应用redolog来提高备库应用redolog的实时性!
三:Quick Switchover Steps
- 1. Initiate the switchover on the primary database:
- SQL>connect / as sysdba
- Connected.
- SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
- Database altered.
- 2. After step 1 finishes, Switch the original physical standby db to primary role;
- SQL> connect / as sysdba
- Connected.
- SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
- Database altered
- 3. Immediately after issuing command in step 2, shut down and restart the former primary instance PRIM:
- SQL> shutdown immediate
- ORA-01507: database not mounted
- ORACLE instance shut down
- SQL> startup mount
- ORACLE instance started.
- Total System Global Area 167772160 bytes
- Fixed Size 1218316 bytes
- Variable Size 92276980 bytes
- Database Buffers 71303168 bytes
- Redo Buffers 2973696 bytes
- Database mounted.
- 4. After step 3 completes:
- SQL> shutdown immediate
- ORA-01507: database not mounted
- ORACLE instance shut down.
- SQL> startup
- ORACLE instance started.
- Total System Global Area 167772160 bytes
- Fixed Size 1218316 bytes
- Variable Size 96471284 bytes
- Database Buffers 67108864 bytes
- Redo Buffers 2973696 bytes
- Database mounted.
- Database opened.
- SQL> alter system switch logfile;
- System altered.
切换后的主库:
SQL> select name,database_role,switchover_status from v$database;
NAME DATABASE_ROLE SWITCHOVER_STATUS
--------- ---------------- --------------------
ORCL PRIMARY SESSIONS ACTIVE
切换后的备库:
SQL> select name,database_role,switchover_status from v$database;
NAME DATABASE_ROLE SWITCHOVER_STATUS
--------- ---------------- --------------------
ORCL PHYSICAL STANDBY TO PRIMARY
SQL> alter database recover managed standby database disconnect from session;
Database altered.
本文转自斩月博客51CTO博客,原文链接http://blog.51cto.com/ylw6006/661228如需转载请自行联系原作者
ylw6006