Data Gurad switchover切换(Physical Standby Databases)

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:Data Gurad switchover切换(Physical Standby Databases)

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

一、主库
查看当前数据库状态
select database_role,switchover_status from v$database;

当switchover_status为SESSIONS ACTIVE时
alter database commit to switchover to physical standby with session shutdown;
否则执行
alter database commit to switchover to physical standby;

切换成功关闭数据库
shutdown immediate;

startup mount;
note:11g 可以直接置于 read only 使用命令startup

开启实时应用
alter database recover managed standby database using current logfile disconnect from session;

恢复备库未利用日志
alter database recover managed standby database disconnect from session;

二、备库
查看当前数据库状态
select database_role,switchover_status from v$database;

如果是switchover_status为recovery needed或switchover latent 恢复数据库
alter database recover managed standby database disconnect from session;

切换数据库
alter database commit to switchover to primary with session shutdown;

开启数据库
startup

–查询除自己进程外的其他进程,并kill掉

SELECT 'kill -9 '||p.spid,'alter system kill session '''||v.sid||','||v.SERIAL#||''''
FROM V$SESSION v ,v$process p  
WHERE v.TYPE = 'USER' 
AND v.SID <> (SELECT DISTINCT SID FROM V$MYSTAT) 
AND v.paddr=p.addr;

三、补充11g官方文档处理顺序和操作语句
1、主库切换
SELECT SWITCHOVER_STATUS FROM V$DATABASE;
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
SHUTDOWN ABORT;
STARTUP MOUNT;

2、备库切换
SELECT SWITCHOVER_STATUS FROM V$DATABASE;
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
ALTER DATABASE OPEN;

3、开启应用(新备库–原主库)
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

此条目发表在 Data Guard 分类目录。将固定链接加入收藏夹。

评论功能已关闭。