博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
镜像三机
阅读量:6041 次
发布时间:2019-06-20

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

--主体

USE master;

--DROP MASTER KEY;

--统一主密钥

CREATE MASTER KEY ENCRYPTION BY PASSWORD = ;

GO

--统一的登录密码

CREATE LOGIN MIR_M_LOGIN WITH PASSWORD = ;

GO

--统一的登录用户名

CREATE USER MIR_M_USER FOR LOGIN MIR_M_LOGIN;

GO

 

---------------------------

USE master;

CREATE CERTIFICATE Cert_001

   WITH SUBJECT = 'Cert_001 certificate for database mirroring',

      start_date = '01/01/2008',EXPIRY_DATE = '10/31/2099' ;

GO

--建立出站端点

CREATE ENDPOINT EMP_001

   STATE = STARTED

   AS TCP (LISTENER_PORT=5025, LISTENER_IP = ALL )

   FOR DATABASE_MIRRORING (

      AUTHENTICATION = CERTIFICATE Cert_001

      , ENCRYPTION = REQUIRED ALGORITHM RC4

      , ROLE = ALL

   );

GO

 

--配置端点

GRANT CONNECT ON ENDPOINT::EMP_001 TO [MIR_M_LOGIN];

GO

--激活端点

ALTER ENDPOINT EMP_001 STATE=STARTED

GO

 

--保存导出证书,拷贝到主服务器,将需要在主服务器导入

BACKUP CERTIFICATE Cert_001 TO FILE = 'c:\share\Cert_001.cer';

GO

 

---------------------

USE master;

CREATE CERTIFICATE Cert_002

   AUTHORIZATION MIR_M_USER

   FROM FILE = 'c:\share\Cert_002.cer'

GO

CREATE CERTIFICATE Cert_003

   AUTHORIZATION MIR_M_USER

   FROM FILE = 'c:\share\Cert_003.cer'

GO

---------------------

USE MASTER;

ALTER DATABASE test

SET PARTNER = 'TCP://192.168.1.170:5025'

GO

ALTER DATABASE test

SET WITNESS = 'TCP://192.168.1.171:5025'

GO

 

/*

USE MASTER;

ALTER DATABASE test

SET PARTNER off

GO

*/

--查看是否成功

SELECT * FROM sys.database_mirroring WHERE database_id=(

 SELECT database_id FROM sys.databases WHERE name='test')

 

select *   from 费用表

update 费用表 set 金额=444566

select *   from 费用表

 

---------------------------------------------------------------------------------------------------------------------

 

--镜像

USE master;

--DROP MASTER KEY;

--统一主密钥

CREATE MASTER KEY ENCRYPTION BY PASSWORD = ;

GO

--统一的登录密码

CREATE LOGIN MIR_M_LOGIN WITH PASSWORD = ;

GO

--统一的登录用户名

CREATE USER MIR_M_USER FOR LOGIN MIR_M_LOGIN;

GO

----------------------------------
USE master;

CREATE CERTIFICATE Cert_002

   WITH SUBJECT = 'Cert_002 certificate for database mirroring',

      start_date = '01/01/2008',EXPIRY_DATE = '10/31/2099' ;

GO

CREATE ENDPOINT EMP_002

   STATE = STARTED

   AS TCP (LISTENER_PORT=5025, LISTENER_IP = ALL )

   FOR DATABASE_MIRRORING (

      AUTHENTICATION = CERTIFICATE Cert_002

      , ENCRYPTION = REQUIRED ALGORITHM RC4

      , ROLE = ALL

   );

GO

 

--配置端点

GRANT CONNECT ON ENDPOINT::EMP_002 TO [MIR_M_LOGIN];

GO

--激活端点

ALTER ENDPOINT EMP_002 STATE=STARTED

GO

 

--保存导出证书,拷贝到主服务器,将需要在主服务器导入

BACKUP CERTIFICATE Cert_002 TO FILE = 'c:\share\Cert_002.cer';

GO

----------------------

--使指定证书与指定用户相关联

USE master;

CREATE CERTIFICATE Cert_001

   AUTHORIZATION MIR_M_USER

   FROM FILE = 'c:\share\Cert_001.cer'

GO

CREATE CERTIFICATE Cert_003

   AUTHORIZATION MIR_M_USER

   FROM FILE = 'c:\share\Cert_003.cer'

GO

 --------------------------

 
USE MASTER;

ALTER DATABASE test

SET PARTNER = 'TCP://192.168.1.169:5025'

GO

/*

USE MASTER;

ALTER DATABASE test

SET PARTNER off

GO

*/

 

CREATE DATABASE test_ss_new ON (  

 NAME = test,

  FILENAME = 'C:\test_ss_new.ss' ) AS SNAPSHOT OF test ;

--查询刚才修改的记录

  SELECT *  FROM   test_ss_new.dbo.费用表

 

 

 

----------------------------------------------------------------------------------------------------------------

 

--见证

USE master;

--DROP MASTER KEY;

--统一主密钥

CREATE MASTER KEY ENCRYPTION BY PASSWORD = ;

GO

--统一的登录密码

CREATE LOGIN MIR_M_LOGIN WITH PASSWORD = ;

GO

--统一的登录用户名

CREATE USER MIR_M_USER FOR LOGIN MIR_M_LOGIN;

GO

-----------

USE master;

CREATE CERTIFICATE Cert_003

   WITH SUBJECT = 'Cert_003 certificate for database mirroring',

      start_date = '01/01/2008',EXPIRY_DATE = '10/31/2099' ;

GO

CREATE ENDPOINT EMP_003

   STATE = STARTED

   AS TCP (LISTENER_PORT=5025, LISTENER_IP = ALL )

   FOR DATABASE_MIRRORING (

      AUTHENTICATION = CERTIFICATE Cert_003

      , ENCRYPTION = REQUIRED ALGORITHM RC4

      , ROLE = ALL

   );

GO

 

--配置端点

GRANT CONNECT ON ENDPOINT::EMP_003 TO [MIR_M_LOGIN];

GO

--激活端点

ALTER ENDPOINT EMP_003 STATE=STARTED

GO

 

--保存导出证书,拷贝到主服务器,将需要在主服务器导入

BACKUP CERTIFICATE Cert_003 TO FILE = 'c:\share\Cert_003.cer';

GO

--------------------------

USE master;

CREATE CERTIFICATE Cert_001

   AUTHORIZATION MIR_M_USER

   FROM FILE = 'c:\share\Cert_001.cer'

GO

CREATE CERTIFICATE Cert_002

   AUTHORIZATION MIR_M_USER

   FROM FILE = 'c:\share\Cert_002.cer'

GO

 

转载地址:http://furhx.baihongyu.com/

你可能感兴趣的文章
自定义key解决zabbix端口监听取值不准确的问题
查看>>
Go语言标准库之JSON编解码
查看>>
linux上架设l2tp+ipsec ***服务器
查看>>
curl指令的使用
查看>>
LNAMP第二版(nginx 1.2.0+apache 2.4.2+php 5.4)
查看>>
css3中变形与动画(一)
查看>>
正则与sed,grep,awk三剑客
查看>>
诊断一句SQL不走索引的原因
查看>>
Linux pipe函数
查看>>
(原創) 如何設計一個數位相框? (SOC) (Quartus II) (SOPC Builder) (Nios II) (TRDB-LTM) (DE2-70)...
查看>>
/etc/profile文件内容
查看>>
一页纸IT项目管理:大道至简的实用管理沟通工具
查看>>
IE6 7下绝对定位引发浮动元素神秘消失
查看>>
浏览器的回流和重绘及其优化方式
查看>>
2.4 salt grains与pillar jinja的模板
查看>>
VDI序曲二十 桌面虚拟化和RemoteApp集成到SharePoint 2010里
查看>>
移动互联网,入口生死战
查看>>
JAVA多线程深度解析
查看>>
Kafka High Level Consumer 会丢失消息
查看>>
时间轴
查看>>