SQL Server Mirroring
This topic describes the process of configuring Secret Server and SQL Server for a high-availability environment using Mirroring. The contents of this paper include:
- Configuring SQL Server 2016 for database mirroring with a failover partner and a witness
- The encryption used between the primary database and the mirror database
- Configuring Secret Server to use mirroring to achieve high availability
Introduction
Three different SQL Server instances are required to implement this scenario:
- Primary database: The main application database
- Mirror database: Replicates all of the data on the primary database in a transactional manner
- Witness database: Monitors the health of the primary and mirror databases and initiates failover if necessary
In the setup described here, mirroring operates in synchronous mode, which means that a transaction does not commit on the primary database until it has committed on the mirror.
Procedures
Setting up Databases for Mirroring
To initiate database mirroring, the databases on the primary and secondary machines must have the same name. We recommend doing this before installation. To initially set up mirroring, in Microsoft SQL Server Management Studio, take a full backup of the database on the primary and then restore it onto the database on the secondary. When restoring the database, the "RESTORE WITH NORECOVERY" option must be selected.
SQL Server Configuration
The three SQL Server instances should all be running under the same domain account. It is possible to run under different accounts but the configuration is more complex and not supported by Delinea technical support. Each SQL Server instance should be configured to listen on TCP.
Configuring Mirroring
To configure mirroring:
-
In Microsoft SQL Server Management Studio, drill down to the primary database in the Object Explorer.
-
Right click the primary database and select Properties. The Database Properties window appears.
-
Select the Mirror page.
-
Click on the Configure Security button. The Configure Database Mirroring Security Wizard appears on the introduction page.
-
Click the Next button. The Include Witness Server page appears.
-
Click to select the Yes selection button.
-
Click the Next button. The Choose Server to Configure page appears.
-
Click to select all three interface check boxes (principal, mirror, and witness servers).
-
Click the Next button. The Principal Server Instance page appears.
-
Click the Principal server instance dropdown list to select the current (primary) server.
-
Type a port number for connecting to the other servers in the Listener port text box. The port must be open for TCP communication on the machine's firewall and on any network devices that restrict access to this machine.
-
Click to select the Encrypt data sent through this endpoint check box. This enables RC4 encryption on data sent through this endpoint.
-
Type
Mirroring
in the Endpoint name text box. The endpoint name is for referencing the endpoint later. -
Click the Next button. The Mirror Server Instance page appears.
-
Repeat the exact same configuration you set for the primary server instance with only the server instance name different (choose the mirror instance).
-
Click the Next button. The Witness Server Instance page appears.
-
Repeat the exact same configuration you set for the primary server instance with only the server instance name different (choose the witness instance).
-
Click the Next button. The Service Accounts page appears.
-
Type the domain user that SQL Server runs under for each instance's Service Accounts text box. For example
mydomain\sql_svc
. -
Click the Finish >> button. Logins are created for each account and are given CONNECT permission on each endpoint, if needed. The Complete the Wizard page appears.
-
Click the Finish button
Configuring Secret Server for Mirroring
-
Go to Admin > See All. The admin panel appears.
-
Type Database in the Search text box and select Database. The Database Configuration page appears:
-
Click the Edit button.
-
Click the Advanced (Not Required) link. A new section appears:
-
Click the select the SSL Encryption check box.
-
Type the mirror server name in the Failover Partner text box.
-
Click the Save Database Connection Settings button.
Testing Mirroring
This procedure is necessary to verify that failover will function correctly in the event that the primary server is unavailable or inoperable:
-
Open SQL Server Enterprise Manager.
-
Right click the primary database and select Properties.
-
Click the Mirroring tab.
-
Click the Failover Now button. This causes the database on primary to switch roles and become the mirror database. The mirror database becomes the primary. Clients using the application should be able to continue as before.
Database SSL Configuration
The certificate authority used for the SSL certificates must be trusted on all of the machines that are a part of Secret Server's installation. The SQL Server service account must be granted access to the certificate.
Procedure:
-
Open Microsoft Management Console by running
mmc
on the Windows command prompt. -
Drill down to Console Root > Certificates > Personal > Certificates in the navigation tree.
-
Right click the certificate and select All Tasks > Manage Private Keys.
-
Grant the user account that SQL Server uses read permission.
-
Ensure SSL is enabled for both the primary and mirror database server. See Configuring Secret Server for Mirroring. It is not necessary to configure SSL on the witness server.