Dataguard物理备库switchover

本文详细介绍了Oracle DataGuard中switchover与failover的区别,并提供了switchover的具体步骤,包括准备工作如测试环境验证、确保数据库状态正常及redolog同步等,最后给出了快速切换的操作流程。

一: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. 1. Initiate the switchover on the primary database:  
  2. SQL>connect / as sysdba  
  3. Connected.  
  4. SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;  
  5. Database altered.  
  6.  
  7. 2. After step 1 finishes, Switch the original physical standby db to primary role;  
  8. SQL> connect / as sysdba  
  9. Connected.  
  10. SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;  
  11. Database altered  
  12.  
  13. 3. Immediately after issuing command in step 2, shut down and restart the former primary instance PRIM:  
  14. SQL> shutdown immediate  
  15. ORA-01507: database not mounted  
  16. ORACLE instance shut down  
  17. SQL> startup mount  
  18. ORACLE instance started.  
  19. Total System Global Area  167772160 bytes  
  20. Fixed Size                  1218316 bytes  
  21. Variable Size              92276980 bytes  
  22. Database Buffers           71303168 bytes  
  23. Redo Buffers                2973696 bytes  
  24. Database mounted.  
  25.  
  26. 4. After step 3 completes:  
  27. SQL> shutdown immediate  
  28. ORA-01507: database not mounted  
  29. ORACLE instance shut down.  
  30. SQL> startup  
  31. ORACLE instance started.  
  32. Total System Global Area  167772160 bytes  
  33. Fixed Size                  1218316 bytes  
  34. Variable Size              96471284 bytes  
  35. Database Buffers           67108864 bytes  
  36. Redo Buffers                2973696 bytes  
  37. Database mounted.  
  38. Database opened.   
  39.  
  40. SQL> alter system switch logfile;  
  41. 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值