ITPub博客

首页 > 数据库 > SQL Server > SQLServer2012镜像主库挂掉如何切换到镜像备库

SQLServer2012镜像主库挂掉如何切换到镜像备库

原创 SQL Server 作者:ywxj_001 时间:2019-12-18 21:15:24 0 删除 编辑
故障现象:
SQLServer2012镜像环境:
主节点1
从节点1


主节点的主库服务挂了,无法启动。

强行启动从库。


在备库执行:

USE master;   

ALTER DATABASE ec SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS;

之后会恢复两分钟,备机的数据库就能用了。


数据库日志:

The mirrored database "ec" is changing roles from "MIRROR" to "PRINCIPAL" because the mirroring session or availability group failed over due to FORCE_SERVICE_ALLOW_DATA_LOSS. This is an informational message only. No user action is required.

Starting up database 'ec'.

1 transactions rolled forward in database 'ec' (7:0). This is an informational message only. No user action is required.

0 transactions rolled back in database 'ec' (7:0). This is an informational message only. No user action is required.

CHECKDB for database 'ec' finished without errors on 2016-09-01 15:33:43.907 (local time). This is an informational message only; no user action is required.


如果主机恢复了就切回去。

--原来的主服务器恢复,可以继续工作,需要重新设定镜像,第一次可能会报个错

在备库执行:

USE master;   

ALTER DATABASE ec SET PARTNER RESUME; --恢复镜像   

ALTER DATABASE ec SET PARTNER FAILOVER; --切换主备


主备切换完成。



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22996654/viewspace-2669343/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
在零售、金融、互联网行业从事数据库相关工作10余年,有丰富的数据库管理和架构的相关经验。 涉及SQLServer、Oracle、MySQL、PostgreSQL等多种数据库。 目前在一家互联网公司担任DBA经理。 负责整个集团数据库的架构设计和管理工作。

注册时间:2010-01-19

  • 博文量
    247
  • 访问量
    436243