Oracle dataguard 正常切换和应急切换

oracle dataguard提供异地容灾方案,能有效的防止单点故障和提供高可用技术,这里介绍dataguard正常主备切换和应急切换(应急切换模拟主库出现问题无法还原,备库脱离dataguard接管主库对外提供服务)
 
 
1)Oracle dataguard环境搭建
 
传送门:Linux 安装oracle10g 配置dataguard 介绍和步骤 http://blog.csdn.net/w63667329/article/details/7890417
续上节环境:
pridb 172.25.56.149
stydb 172.25.56.150
 
2)正常主备切换(switchover)
 
 
主库pridb:
 
select switchover_status from v$database;(查询当前状态)
 
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE
 
alter database commit to switchover to physical standby with session shutdown;(切换至standby模式)
 
重新启动数据库至mount状态;
shutdown immediate
startup mount
 
select switchover_status from v$database;(再检查状态)
 
SWITCHOVER_STATUS
--------------------
TO PRIMARY
 
alter database recover managed standby databasedisconnect;(开启standby应用恢复模式)
 
检查状态
select open_mode,database_role from v$database;
OPEN_MODE  DATABASE_ROLE
----------             ----------------
MOUNTED       PHYSICAL STANDBY
 
备库stydb:
 
select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE
 
alter database commit to switchover to primary;
重新启动数据库open
shutdown immediate
startup
 
select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE
 
select open_mode,database_role from v$database;
OPEN_MODE  DATABASE_ROLE
----------             ----------------
OPEN     PRIMARY
 
至此原主库切换至备库,原备库切换至主库了
 
 
同步测试:
pridb(new):
select sequence#,applied from v$archived_log;
stydb(new):
select sequence#,applied from v$archived_log;
PS:图片偷懒了,不过测试原理是一样的,只需要保证2边sequence序列号一致且最新的app返回YES了,就说明备库接收到应用且恢复了。

 
 
3)应急切换
(注:模拟主库由于故障无法正常switchover,需要执行failover,强制备库->pridb并接管业务)
 
1.备库:
由于是failover,所以理解主库这时候已经无法正常使用,只需备库切换至pridb
 
停止应用恢复模式
alter database recover managed standby database finish;
转换standbydbprimary db
alter database commit to switchover to primary;
重启数据库,恢复正常业务
shutdown immediate
startup
 

select open_mode,database_role from v$database;

OPEN_MODE       DATABASE_ROLE
----------             ----------------
OPEN                 PRIMARY

PS:failover将破坏dataguard模式,需要重新配置dataguard,听说可以不用重新配置,不过本人未实验成功,有方法的可以大家一起沟通下.
 
posted @ 2013-12-03 17:45  胡.杰  阅读(770)  评论(0编辑  收藏  举报