When copying a certificate to another system, use a secure copy method. Be extremely careful to keep all of your certificates secure.
The following example demonstrates what must be done on one partner that resides on HOST_A. In this example, the two partners are the default server instances on three computer systems. The two server instances run in nontrusted Windows domains, so certificate-based authentication is required.
The initial principal role is taken by HOST_A, and the mirror role is taken by HOST_B.
Setting up database mirroring using certificates involves four general stages, of which three stages—1, 2, and 4—are demonstrated by this example. These stages are as follows:
- Configuring Outbound Connections
This example shows the steps for:
- Configuring Host_A for outbound connections.
- Configuring Host_B for outbound connections.
- Configuring Host_A for outbound connections.
- Configuring Inbound Connections
This example shows the steps for:
- Configuring Host_A for inbound connections.
- Configuring Host_B for inbound connections.
- Configuring Host_A for inbound connections.
- Creating the Mirror Database
- Configuring the Mirroring Partners
Configuring Outbound Connections
To configure Host_A for outbound connections
- On the master database, create the database master key, if needed.
2. Make a certificate for this server instance.
Create a mirroring endpoint for server instance using the certificate.
Back up the HOST_A certificate, and copy it to other system, HOST_B.
Using any secure copy method, copy C:\HOST_A_cert.cer to HOST_B.
To configure Host_B for outbound connections
- On the master database, create the database master key, if needed.
Make a certificate on the HOST_B server instance.
|
|
- Create a mirroring endpoint for the server instance on HOST_B.
- Back up HOST_B certificate.
Configuring Inbound Connections
To configure Host_A for inbound connections
- Create a login on HOST_A for HOST_B.
- --Create a user for that login.
- --Associate the certificate with the user.
CREATE CERTIFICATE HOST_B_cert AUTHORIZATION HOST_B_user FROM FILE = 'C:\HOST_B_cert.cer' GO
- Grant CONNECT permission on the login for the remote mirroring endpoint.
To configure Host_B for inbound connections
- Create a login on HOST_B for HOST_A.
USE master; CREATE LOGIN HOST_A_login WITH PASSWORD = '=Sample#2_Strong_Password2'; GO
- Create a user for that login.
CREATE USER HOST_A_user FOR LOGIN HOST_A_login; GO
- Associate the certificate with the user.
CREATE CERTIFICATE HOST_A_cert AUTHORIZATION HOST_A_user FROM FILE = 'C:\HOST_A_cert.cer' GO
- Grant CONNECT permission on the login for the remote mirroring endpoint.
GRANT CONNECT ON ENDPOINT::Endpoint_Mirroring TO [HOST_A_login]; GO
Creating the Mirror Database
Configuring the Mirroring Partners
- On the mirror server instance on HOST_B, set the server instance on HOST_A as the partner (making it the initial principal server instance). Substitute a valid network address for
TCP://HOST_A.Mydomain.Corp.Adventure-Works
.com:7024
.--At HOST_B, set server instance on HOST_A as partner (principal server): ALTER DATABASE AdventureWorks SET PARTNER = 'TCP://HOST_A.Mydomain.Corp.Adventure-Works.com:7024'; GO
- On the principal server instance on HOST_A, set the server instance on HOST_B as the partner (making it the initial mirror server instance). Substitute a valid network address for
TCP://HOST_B.Mydomain.Corp.Adventure-Works.com:7024
.
--At HOST_A, set server instance on HOST_B as partner (mirror server). ALTER DATABASE AdventureWorks SET PARTNER = 'TCP://HOST_B.Mydomain.Corp.Adventure-Works.com:7024'; GO
- This example assumes that the session will be running in high-performance mode. To configure this session for high-performance mode, on the principal server instance (on HOST_A), set transaction safety to OFF.
--Change to high-performance mode by turning off transacton safety. ALTER DATABASE AdventureWorks SET PARTNER SAFETY OFF GO