标签:对话框 高可用方案 load tar 实现 ati 读写 指示 stat
BACKUP DATABASE [mydb] TO DISK = N‘D:\backup\mydb.bak‘ WITH NOFORMAT, NOINIT, NAME = N‘mydb-完整数据库备份 ‘, SKIP, NOREWIND, NOUNLOAD, STATS = 10 GO BACKUP LOG [mydb] TO DISK = N‘D:\backup\mydb.trn‘ WITH NOFORMAT, NOINIT, NAME = N‘mydb-事务日志 备份‘ , SKIP , NOREWIND , NOUNLOAD , STATS = 10 GO
将备份拷贝到镜像服务器上,在镜像服务器上恢复备份,需要指定RESTORE WITH NORECOVERY
RESTORE DATABASE [mydb] FROM DISK = N‘D:\backup\mydb.bak‘ WITH FILE = 1, NORECOVERY , NOUNLOAD , STATS = 10 GO RESTORE LOG [mydb] FROM DISK = N‘D:\backup\mydb.trn‘ WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10 GO
主体数据库配置如下:
--创建密钥 CREATE MASTER KEY ENCRYPTION BY PASSWORD = ‘password‘ SELECT * FROM sys.symmetric_keys --创建证书 CREATE CERTIFICATE cert_3_100 WITH SUBJECT = ‘HOST_A certificate for database mirroring‘, EXPIRY_DATE = ‘1/1/2020‘ SELECT * FROM sys.certificates ; --创建端点 CREATE ENDPOINT master_instance STATE = STARTED AS TCP ( LISTENER_PORT=5022 , LISTENER_IP = ALL ) FOR DATABASE_MIRRORING ( AUTHENTICATION = CERTIFICATE cert_3_100 , ENCRYPTION = REQUIRED ALGORITHM AES , ROLE = ALL ) SELECT name , role_desc , state_desc , connection_auth_desc , encryption_algorithm_desc FROM sys.database_mirroring_endpoints --备份证书到其他系统 BACKUP CERTIFICATE cert_3_101 TO FILE = ‘d:\cert_3_100.cer‘; GO
镜像数据库配置如下:
--创建密钥 CREATE MASTER KEY ENCRYPTION BY PASSWORD = ‘password‘ SELECT * FROM sys.symmetric_keys --创建证书 CREATE CERTIFICATE cert_3_101 WITH SUBJECT = ‘HOST_A certificate for database mirroring‘, EXPIRY_DATE = ‘1/1/2020‘ SELECT * FROM sys.certificates ; --创建端点 CREATE ENDPOINT backup_instance STATE = STARTED AS TCP ( LISTENER_PORT=5022 , LISTENER_IP = ALL ) FOR DATABASE_MIRRORING ( AUTHENTICATION = CERTIFICATE cert_3_101 , ENCRYPTION = REQUIRED ALGORITHM AES , ROLE = ALL ) SELECT name , role_desc , state_desc , connection_auth_desc , encryption_algorithm_desc FROM sys.database_mirroring_endpoints --备份证书到其他系统 BACKUP CERTIFICATE cert_3_101 TO FILE = ‘d:\cert_3_101.cer‘; GO
主体数据库配置如下:
USE master --为其他系统创建登录名 CREATE LOGIN login_3_101 WITH PASSWORD = ‘password‘; SELECT * FROM sys.server_principals --创建一个使用该登录名的用户 CREATE USER user_3_101 FOR LOGIN login_3_101 SELECT * FROM sys.sysusers --将证书与用户关联,并将镜像库生成的证书文件放到指定目录中 CREATE CERTIFICATE cert_3_101 AUTHORIZATION user_3_101 FROM FILE = ‘d:\cert_3_101.cer‘ SELECT * FROM sys.certificates --授权对远程镜像端点的登录名的 CONNECT权限,授权完成后,完成对登录到所需的证书身份验证的设置 GRANT CONNECT ON ENDPOINT::master_instance TO login_3_101
镜像数据库配置如下:
USE master --为其他系统创建登录名 CREATE LOGIN login_3_100 WITH PASSWORD = ‘password‘; SELECT * FROM sys.server_principals --创建一个使用该登录名的用户,并将主体库生成的证书文件放到指定目录中 CREATE USER user_3_100 FOR LOGIN login_3_100 SELECT * FROM sys.sysusers --将证书与用户关联 CREATE CERTIFICATE cert_3_100 AUTHORIZATION user_3_100 FROM FILE = ‘d:\cert_3_100.cer‘ SELECT * FROM sys.certificates --授权对远程镜像端点的登录名的 CONNECT权限,授权完成后,完成对登录到所需的证书身份验证的设置 GRANT CONNECT ON ENDPOINT::backup_instance TO login_3_100
选择主体数据库mydb数据库对象右键->任务->镜像->配置安全性
因为要采用高性能方式,所以不需要见证服务器
当同步完成后,主体数据库会显示“(主体,已同步)”,镜像数据库会显示(已同步,正在还原)
步骤2:配置分发服务器
点击添加
如果要发布的数据库非常大,建议选择业务空闲期进行初始化快照
输入代理名称,取消勾选“仅显示次配置文件中使用的参数”,指定 –PublisherFailoverPartner 代理参数的镜像名称WIN-3-100
USE mydb INSERT INTO Admin( user_name) VALUES(‘master‘ ) SELECT * FROM admin WHERE user_name=‘master‘
连接订阅库,查询插入数据
USE mydb SELECT * FROM admin WHERE user_name=‘master‘
use master ; alter database mydb set partner FORCE_SERVICE_ALLOW_DATA_LOSS; --强制接收
USE mydb INSERT INTO Admin( user_name) VALUES(‘mirror‘ ) SELECT * FROM admin WHERE user_name=‘mirror‘
在订阅服务器查看:
USE mydb SELECT * FROM admin WHERE user_name=‘mirror‘
use master ; alter database mydb set partner resume;
标签:对话框 高可用方案 load tar 实现 ati 读写 指示 stat
原文地址:http://www.cnblogs.com/datazhang/p/6142349.html