温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

SQL Server数据库镜像搭建(无见证无域控)

发布时间:2020-07-01 10:56:46 来源:网络 阅读:3010 作者:易语随风去 栏目:关系型数据库

1. 环境配置
服务器1:sqlmirror01
IP:192.168.10.176
服务器2:sqlmirror02
IP:192.168.10.177
操作系统:Windows 2012 R2
安装 .Net Framework 3.5/4.0
关闭服务器防火墙或设置白名单
数据库版本:SQL Server 2014
2. 创建主密钥(非必需)
use master
go
create master key encryption by password='zaq12WSX'
go
3. 创建证书
sqlmirror01执行
use master
go
create certificate sqlmirror01_cert with subject='sqlmirror01 certificate',expiry_date='2099-1-1'
go
sqlmirror02执行
use master
go
create certificate sqlmirror02_cert with subject='sqlmirror02 certificate',expiry_date='2099-1-1'
go
4. 创建镜像端点
sqlmirror01执行
use master
go
create endpoint Endpoint_Mirroring
state=started
as tcp ( listener_port = 5022,listener_ip = all )
for database_mirroring ( authentication = certificate sqlmirror01_cert, encryption = required algorithm aes, role = all )
go
sqlmirror02执行
use master
go
create endpoint Endpoint_Mirroring
state=started
as tcp ( listener_port = 5022,listener_ip = all )
for database_mirroring ( authentication = certificate sqlmirror02_cert, encryption = required algorithm aes, role = all )
go
5. 备份证书
sqlmirror01执行
use master
go
backup certificate sqlmirror01_cert to file = 'C:\Certificate_files\sqlmirror01_cert.cer'
go
sqlmirror02执行
use master
go
backup certificate sqlmirror02_cert to file = 'C:\Certificate_files\sqlmirror02_cert.cer'
go
6. 拷贝证书
将sqlmirror01_cert.cer拷贝至sqlmirror02的C:\Certificate_files\
将sqlmirror02_cert.cer拷贝至sqlmirror01的C:\Certificate_files\
7. 创建登录名
sqlmirror01执行
use master
go
create login sqlmirror02_login with password='abc@123456'
go
sqlmirror02执行
use master
go
create login sqlmirror01_login with password='abc@123456'
go
8. 创建使用该登录名的用户
sqlmirror01执行
use master
go
create user sqlmirror02_user for login sqlmirror02_login
go
sqlmirror02执行
use master
go
create user sqlmirror01_user for login sqlmirror01_login
go
9. 证书与用户关联
sqlmirror01执行
use master
go
create certificate sqlmirror02_cert
authorization sqlmirror02_user
from file='c:\Certificate_files\sqlmirror02_cert.cer'
go
sqlmirror02执行
use master
go
create certificate sqlmirror01_cert
authorization sqlmirror01_user
from file='c:\Certificate_files\sqlmirror01_cert.cer'
go
10. 授予对远程镜像端点的登录名的 CONNECT 权限
sqlmirror01执行
use master
go
GRANT CONNECT ON ENDPOINT::Endpoint_Mirroring TO [sqlmirror02_login];
go
sqlmirror02执行
use master
go
GRANT CONNECT ON ENDPOINT::Endpoint_Mirroring TO [sqlmirror01_login];
go
11. 配置镜像伙伴
sqlmirror01执行
创建数据库
CREATE DATABASE [Mirror_test_1]
ON PRIMARY
( NAME = N'Mirror_test_1', FILENAME = N'C:\dbdata\Mirror_test_1.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'Mirror_test_1_log', FILENAME = N'C:\dbdata\Mirror_test_1_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
备份数据库
backup database Mirror_test_1 to disk='C:\backup\Mirror_test_1.bak' with compression,checksum
将备份拷贝至sqlmirror02
sqlmirror02执行
restore database Mirror_test_1 from disk='C:\backup\Mirror_test_1.bak' with norecovery
连接镜像
sqlmirror02执行
use master
go
ALTER DATABASE Mirror_test_1 SET PARTNER = 'TCP://sqlmirror01:5022';
go
sqlmirror01执行
use master
go
ALTER DATABASE Mirror_test_1 SET PARTNER = 'TCP://sqlmirror02:5022';
go
SQL Server数据库镜像搭建(无见证无域控)
SQL Server数据库镜像搭建(无见证无域控)
更改为高性能模式
镜像主体sqlmirror01执行
use master
go
ALTER DATABASE Mirror_test_1 SET PARTNER SAFETY OFF
go
SQL Server数据库镜像搭建(无见证无域控)

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI