Microsoft SQL Server 2005數據庫鏡像語句:
SERVER 1
CREATE ENDPOINT DbMirroring
STATE=STARTED
AS TCP(LISTENER_PORT=5023)
FOR DATABASE_MIRRORING(ROLE=PARTNER,ENCRYPTION=SUPPORTED)
ALTER DATABASE AdventureWorks SET PARTNER='TCP://192.168.5.106:5022'
SERVER 2
CREATE ENDPOINT DbMirroring
STATE=STARTED
AS TCP(LISTENER_PORT=5022)
FOR DATABASE_MIRRORING (ROLE=PARTNER,ENCRYPTION=SUPPORTED)
ALTER DATABASE AdventureWorks SET PARTNER='TCP://192.168.5.106:5023'
見證服務器
CREATE ENDPOINT DbMirroring
STATE=STARTED
AS TCP (LISTENER_PORT=5033)
FOR DATABASE_MIRRORING (ROLE=WITNESS,ENCRYPTION=SUPPORTED)
ALTER DATABASE AdventureWorks SET PARTNER='TCP://192.168.5.106:5033'
執行下面的代碼就可以將鏡像服務器設為主體服務器,主體服務器設置為鏡像 服務器:
USE MASTER
Go
ALTER DATABASE AdventureWorks SET PARTNER FAILOVER
Go