--==================================================================
--该文档主要用于内部配置模板
---------------------------------------------------------------------
--为partner创建证书
USE
master;
GO
--=========================================================================================================
--创建Master
key
IF NOT EXISTS(SELECT 1 FROM sys.symmetric_keys k WHERE
k.Name=‘##MS_DatabaseMasterKey##‘)
BEGIN
CREATE MASTER KEY ENCRYPTION BY
PASSWORD =‘master@key123‘
END
GO
IF NOT
EXISTS(SELECT 1 FROM sys.databases db WHERE
db.[is_master_key_encrypted_by_server]=1)
BEGIN
ALTER MASTER KEY ADD
ENCRYPTION BY SERVICE MASTER
KEY
END
GO
--=========================================================================================================
--创建和备份证书
IF
NOT EXISTS (SELECT 1 FROM sys.certificates C WHERE C.Name=‘HOST_3_32_cert‘
)
BEGIN
CREATE CERTIFICATE HOST_3_32_cert WITH SUBJECT
=‘HOST_3_32_cert‘,
START_DATE = ‘01/01/2010‘ , EXPIRY_DATE =
‘01/01/2199‘;
END
GO
BACKUP CERTIFICATE HOST_3_32_cert TO
FILE=‘D:\HOST_3_32_cert.cer‘
GO
--=========================================================================================================
--创建镜像专用的端点,并使用证书加密
--同一个实例上只能存在一个镜像端点
IF
NOT EXISTS(SELECT * FROM sys.endpoints e WHERE e.[Type]=4)
BEGIN
CREATE
ENDPOINT [Endpoint_Mirroring]
STATE=STARTED
AS
TCP(LISTENER_PORT=5022)
FOR
DATABASE_MIRRORING(AUTHENTICATION=CERTIFICATE HOST_3_32_cert,
ENCRYPTION=REQUIRED,ROLE=ALL)
END
GO
---------------------------------------------------------------------
--为partnert创建login和user,and
grant the right of connection
USE master;
GO
IF NOT
EXISTS(SELECT 1 FROM sys.syslogins l WHERE l.[Name]
=‘HOST_3_32_login‘)
BEGIN
CREATE LOGIN HOST_3_32_login
WITH PASSWORD =‘Auto@sql‘
END
GO
IF
NOT EXISTS(SELECT 1 FROM sys.sysusers u WHERE u.[Name]=
‘HOST_3_32_User‘)
BEGIN
CREATE USER HOST_3_32_User FOR
LOGIN HOST_3_32_login
END
GO
IF NOT
EXISTS(SELECT 1 FROM sys.certificates c WHERE c.[Name]=
‘HOST_3_32_cert‘)
BEGIN
CREATE CERTIFICATE
HOST_3_32_cert AUTHORIZATION HOST_3_32_User FROM
FILE=‘D:\HOST_3_32_cert.cer‘
END
GO
GRANT
CONNECT ON ENDPOINT::[Endpoint_Mirroring] TO
HOST_3_32_login
GO
------------------------------------------------------------------
--从服务器设置镜像
USE
[master]
GO
ALTER DATABASE promotion_datacenter SET
PARTNER=‘TCP://192.168.3.32:5022‘
GO
------------------------------------------------------------------
--主服务器设置镜像
USE
[master]
GO
ALTER DATABASE promotion_datacenter SET
PARTNER=‘TCP://192.168.3.32:5022‘
GO
USE [master]
GO
ALTER DATABASE
promotion_datacenter SET PARTNER SAFETY OFF
GO
相关文章
- 10-23Appium下的WDA使用个人开发者证书配置
- 10-23Appium下的WDA使用个人开发者证书配置
- 10-23AWS使用自签名证书配置EBL负载均衡器
- 10-23Mybatis-eclipse使用配置文件模板
- 10-23关于k8s集群证书1年过期后,使用kubadm重新生成证书及kubeconfig配置文件的变化
- 10-23nginx配置SSL证书,让http和https都可以使用
- 10-23Maven的安装与配置+使用+镜像配置
- 10-23使用 docker buildx 构建多 cpu 架构镜像 - 环境配置篇
- 10-23Tomcat服务器配置https双向认证,使用JDK的keytool生成证书(适用于web、安卓、IOS)
- 10-23docker的使用-01配置国内镜像仓库提高加快拉取镜像的速度