博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SQL Server数据库镜像搭建(无见证无域控)
阅读量:6757 次
发布时间:2019-06-26

本文共 3230 字,大约阅读时间需要 10 分钟。

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数据库镜像搭建(无见证无域控)

转载于:https://blog.51cto.com/aimax/2122535

你可能感兴趣的文章
Leetcode Word Break II
查看>>
java 8 in action
查看>>
计算机容量及计算分析
查看>>
javascript闭包
查看>>
腻子脚本polyfill
查看>>
IIS与ASP.NET中的线程池
查看>>
win8系统安装.net Framework3.5
查看>>
Shel脚本-初步入门之《04》
查看>>
Nginx入门之两种handler函数的挂载方式
查看>>
polygonZM---> poliygon
查看>>
LINQ to SQL:创建你的第一个程序
查看>>
K 班1-7,alpha,beta 作业成绩汇总
查看>>
select 的问题
查看>>
Fiddler如何添加ServerIP显示
查看>>
Android瀑布流优化,解决Recyclerview展示大批量图片时Item自动切换、闪烁、空白等问题...
查看>>
《c程序设计语言》读书笔记-5.4-指针实现strend
查看>>
Android 系统默认音量和最大音量
查看>>
MPlayer-ww 增加边看边剪切功能
查看>>
vim利器:vundle 管理器和NERDTree插件
查看>>
系统虚拟机
查看>>