SQLServer数据库镜像搭建(无见证无域控)
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
更改为高性能模式
镜像主体sqlmirror01执行
use master
go
ALTER DATABASE Mirror_test_1 SET PARTNER SAFETY OFF
go
成都创新互联长期为数千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为吉阳企业提供专业的做网站、成都网站建设,吉阳网站改版等技术服务。拥有10多年丰富建站经验和众多成功案例,为您定制开发。
当前标题:SQLServer数据库镜像搭建(无见证无域控)
转载来于:http://scyanting.com/article/piscoe.html