一: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
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:
ORACLE instance shut down.
SQL> startup
Variable Size 96471284 bytes
Database Buffers 67108864 bytes
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
切換後的備庫:
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