日期:2014-05-18 浏览次数:20748 次
--=============================================== --主服务器执行 --=============================================== USE master; CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'abc@2010'; go CREATE CERTIFICATE Cert_A WITH SUBJECT = 'HOST_A certificate' , START_DATE = '20110101', EXPIRY_DATE = '20990101' go BACKUP CERTIFICATE Cert_A TO FILE = 'D:\快盘\Cert_A.cer'; go CREATE ENDPOINT Endpoint_Mirroring STATE = STARTED AS TCP ( LISTENER_PORT=5088 , LISTENER_IP = ALL ) FOR DATABASE_MIRRORING ( AUTHENTICATION = CERTIFICATE Cert_A , ENCRYPTION = REQUIRED ALGORITHM AES , ROLE = ALL ); go --=============================================== --镜像服务器执行 --=============================================== USE master; CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'abc@2010'; CREATE CERTIFICATE Cert_B WITH SUBJECT = 'HOST_B certificate' , START_DATE = '20110101', EXPIRY_DATE = '20990101' go BACKUP CERTIFICATE Cert_B TO FILE = 'E:\快盘\Cert_B.cer'; go CREATE ENDPOINT Endpoint_Mirroring STATE = STARTED AS TCP ( LISTENER_PORT=5088 , LISTENER_IP = ALL ) FOR DATABASE_MIRRORING ( AUTHENTICATION = CERTIFICATE Cert_B , ENCRYPTION = REQUIRED ALGORITHM AES , ROLE = ALL ); go --复制Cert_A到镜像服务器,复制Cert_B到主服务器 --=============================================== --主机执行 --=============================================== CREATE CERTIFICATE cert_B FROM FILE = 'D:\快盘\Cert_B.cer'; go CREATE LOGIN loginToB FROM CERTIFICATE cert_B; go GRANT CONNECT ON ENDPOINT::Endpoint_Mirroring TO loginToB; go --=============================================== --镜像服务器执行 --=============================================== CREATE CERTIFICATE cert_A FROM FILE = 'E:\快盘\Cert_A.cer'; go CREATE LOGIN loginToA FROM CERTIFICATE cert_A; go GRANT CONNECT ON ENDPOINT::Endpoint_Mirroring TO loginToA; go --服务器环境配置完毕,下面开始操作数据库 --=============================================== --主服务器执行 --=============================================== --设置数据库完全备份模式 alter database JX set recovery full go --备份 backup database JX to disk=N'D:\快盘\JX.bak' with format go BACKUP LOG JX TO DISK = 'D:\快盘\JX_log.bak' GO --=============================================== --镜像服务器执行 --=============================================== --还原数据库,若路径有修改,需要move RESTORE DATABASE JX FROM DISK='E:\快盘\JX.bak' WITH NORECOVERY, MOVE 'JX' TO