鏡像的相關 T-SQL 指令。
//刪掉某個ENDPOINT
DROP ENDPOINT [NAME];
//創造ENDPOINT
CREATE ENDPOINT [Mirroring]
AS TCP (LISTENER_PORT = 5022)
FOR DATA_MIRRORING (ROLE = PARTNER, ENCRYPTION=DISABLED)
//修改ENDPOINT
ALTER ENDPOINT [Mirroring]
STATE = STARTED
AS TCP (LISTENER_PORT = 5022)
FOR database_mirroring (ROLE = PARTNER);
//設定Partner的IP位置與Port
ALTER DATABASE [NAME] SET PARTNER ='TCP://IP:5022';
//主要資料庫壞掉時,在鏡像資料庫上執行這段命令即可使用鏡像的資料庫
ALTER DATABASE [NAME] SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS;
//去除鏡像
ALTER DATABASE [NAME] SET PARTNER OFF;
//將資料庫改成普通狀態
RESTORE DATABASE [NAME] WITH RECOVERY;
//從主要資料庫上容錯移轉到鏡像
ALTER DATABASE SET PARTNER FAILOVER
全站熱搜
留言列表