GO
create certificate HOST_A_cert with subject = 'HOST_A certificate', start_date = '2007/11/01', expiry_date = '2020/11/01';
GO
Create endpoint endpoint_mirroring state = started
as tcp(listener_port = 7024, listener_ip = all)
for database_mirroring (authentication = certificate HOST_A_cert, encryption = disabled, role = all);
GO
Backup certificate HOST_A_cert to file = 'd:\HOST_A_cert.cer';
GO
大概意思就是创建证书,然后创建镜像端点,然后保存证书到硬盘上。这里请根据实际情况修改backup file,然后修改一下密码吧。然后注意,监听端口可以自己设置,只要不冲突就可以了,还要注意在防火墙要允许访问。其他的可以不用修改
GO
create certificate HOST_B_cert with subject = 'HOST_B certificate', start_date = '2007/11/01', expiry_date = '2020/11/01';
GO
Create endpoint endpoint_mirroring state = started
as tcp(listener_port = 7024, listener_ip = all)
for database_mirroring (authentication = certificate HOST_B_cert, encryption = disabled, role = all);
GO
Backup certificate HOST_B_cert to file = 'd:\HOST_B_cert.cer';
GO
和上面的意思一样,只不过是在镜像服务器罢了
GO
create certificate HOST_W_cert with subject = 'HOST_W certificate', start_date = '2007/11/01', expiry_date = '2020/11/01';
GO
Create endpoint endpoint_mirroring state = started
as tcp(listener_port = 7024, listener_ip = all)
for database_mirroring (authentication = certificate HOST_W_cert, encryption = disabled, role = witness);
GO
Backup certificate HOST_W_cert to file = 'd:\HOST_W_cert.cer';
GO
执行完以后,分别拷贝3个证书文件到每个服务器,也就是说每个服务器都有这3个证书。这个时候可以在服务器对象---端点---数据库镜像里面看到新建立的端点了。
create login HOST_B_login with PASSWORD = 'abc123!!';
GO
create user HOST_B_user from login HOST_B_login;
GO
Create certificate HOST_B_cert
Authorization HOST_B_user
From file = 'D:\HOST_B_cert.cer';
GO
Grant CONNECT ON Endpoint::endpoint_mirroring to [HOST_B_login];
GO
------
create login HOST_W_login with PASSWORD = 'abc123!!';
GO
create user HOST_W_user from login HOST_W_login;
GO
Create certificate HOST_W_cert
Authorization HOST_W_user
From file = 'D:\HOST_W_cert.cer';
GO
Grant CONNECT ON Endpoint::endpoint_mirroring to [HOST_W_login];
GO
-- HOST B again
create login HOST_A_login with PASSWORD = 'abc123!!';
GO
create user HOST_A_user from login HOST_A_login;
GO
Create certificate HOST_A_cert
Authorization HOST_A_user
From file = 'D:\HOST_A_cert.cer';
GO
Grant CONNECT ON Endpoint::Endpoint_mirroring to [HOST_A_login];
GO
-------
create login HOST_W_login with PASSWORD = 'abc123!!';
GO
create user HOST_W_user from login HOST_W_login;
GO
Create certificate HOST_W_cert
Authorization HOST_W_user
From file = 'D:\HOST_W_cert.cer';
GO
Grant CONNECT ON Endpoint::Endpoint_mirroring to [HOST_W_login];
GO
-- HOST
GO
create user HOST_A_user from login HOST_A_login;
GO
Create certificate HOST_A_cert
Authorization HOST_A_user
From file = 'D:\HOST_A_cert.cer';
GO
Grant CONNECT ON Endpoint::Endpoint_mirroring to [HOST_A_login];
GO
-------
create login HOST_B_login with PASSWORD = 'abc123!!';
GO
create user HOST_B_user from login HOST_B_login;
GO
Create certificate HOST_B_cert
Authorization HOST_B_user
From file = 'D:\HOST_B_cert.cer';
GO
Grant CONNECT ON Endpoint::endpoint_mirroring to [HOST_B_login];
GO
GO
alter database good set partner = 'TCP://server2.ace.local:7024';
GO
alter database good set witness = 'TCP://mc.ace.local:7024';
GO