SQLServer2012映象主庫掛掉如何切換到映象備庫

ywxj_001發表於2019-12-18
故障現象:
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部落格 ” ,連結:http://blog.itpub.net/22996654/viewspace-2669343/,如需轉載,請註明出處,否則將追究法律責任。

相關文章