SQL Server AlwaysOn Availability Groups
SQL Server AlwaysOn Availability Groups
This document and the information controlled therein is the property of Click Studios. It must not be reproduced in whole/part, or
otherwise disclosed, without prior consent in writing from Click Studios.
Click Studios
Table of Contents
1 OVERVIEW ........................................................................................................................... 3
2 PREREQUISITES .................................................................................................................... 4
3 CONFIGURE SQL SERVICES .................................................................................................... 5
4 INSTALL WINDOWS FAILOVER CLUSTER ROLE ...................................................................... 6
5 SET UP THE FAILOVER CLUSTER (WSFC) .............................................................................. 10
6 ENABLE ALWAYS ON AVAILABILITY GROUPS ...................................................................... 14
7 SET UP A HIGH AVAILABILITY GROUP ................................................................................. 15
8 CONFIGURING PASSWORDSTATE TO WORK WITH ALWAYS ON GROUP ............................. 27
Click Studios
1 Overview
This document will provide instructions for configuring SQL Server Always On Availability Groups for High
Availability of the Passwordstate Database.
These instructions are created using SQL Server 2017 Enterprise edition and are intended as a guide only. If
you have any technical issues with SQL Server, please contact Microsoft for support.
Click Studios
2 Prerequisites
Following are some pre-requisites to installing and configuring SQL Server for Basic Availability Groups:
• You will need to have SQL Server 2012 (or above) Enterprise installed on two separate servers with the
default instance set, and the default Port of 1433 configured. Neither of the machines that host SQL
can be a domain controller.
• You’ll also need one domain service account with “domain users” permissions on your network
• Passwordstate should be installed and communicating to a database on one of your SQL servers you
have set up for this exercise
• A network share that Always On technology requires for database backups
Below is some information about a test environment used to document this process, to help you
understand our instructions easier:
SQLDB1.halox.net - 10.0.0.146
• Microsoft Windows 2016 Server with SQL 2017 Standard installed
• Also hosts Passwordstate database
SQLDB2.halox.net – 10.0.0.147
• Microsoft Windows 2016 Server with SQL 2017 Standard installed
Win2k16installs.halox.net - 10.0.0.120
• Passwordstate web server
Network Share:
• \\SQLDB1\Backups
• halox\sqlservice has full permissions to this share
Click Studios
Confirm you have set your SQL Server service on both SQLDB1 and SQLDB2 to run under your domain
account:
• Open SQL Server Configuration Manager and edit the properties of the SQL Server service, setting
your domain account under the Log On tab.
Click Studios
On both SQLDB1 and SQLDB2, install the Failover Cluster role by following this process:
• Tick Failover Clustering, Select Include Management Tools, Click Add Features and then click Next
• Click Install
Click Studios
• Select Next
Click Studios
• Add in the name of your cluster and the static IP Address it will be assigned. This will create a
virtual computer object in Active Directory and a Host entry for this object in DNS.
• Click Next
Click Studios
• Click Finish
• This process will automatically create the cluster on SQLDB2, so if you log into any of your database
servers now, you will see the cluster has been created, and both nodes are Up:
Click Studios
• Open SQL Server Configuration Manager, go to the properties of the SQL Server service, and tick
the Enable AlwaysOn Availability Groups option. Click OK to the warning about the services
needing to be restarted.
• Restart the SQL Service service on both servers after making this change
Click Studios
• Click Next
Click Studios
• Type in a name of the Availability Group as Passwordstate, select the Cluster Type as Windows
Server Failover Cluster, and tick the option for Database Level Health Detection. Click Next.
Click Studios
• Under the Relicas tab, click the Add Replica button, connect to your second SQL Server, which in
this case is SQLDB2, and then click Connect
Click Studios
• Select the Automatic Failover option, Synchronous Commit, and Yes as the Readable Secondary
for both databases.
Click Studios
• Under the Listener tab, enable the Create an availability group listener option and enter a DNS
name of a server which will provide a client connection point.
This will create a virtual computer object in Active Directory and will also create a Host DNS record
for this Active Directory object. Enter the port as 1433 and enter a static IP Address that will be set.
Click Studios
• Enable the Full database and log backup option and set the value of the share on your primary SQL
server
Click Studios
• If you now connect to your secondary server, you will now see the Passwordstate database has
been added, and it is synchronizing
• If you run open the Always On Dashboard, you will also see information about this new Group
including its health and the current primary database etc.
Click Studios
• When connected to your SQLDB1 server, run the following query in SQL Management Studio
Tools:
• On your Passwordstate web server open Notepad “As Administrator”, open the
c:\inetpub\Passwordstate\web.config file, and take note of the password being used in the
connection string
Click Studios
• Next connect to SQLDB2 and run the following command in SQL Management Studio Tools, which
will create the passwordstate_user account on this server with the same SID. Ensure you insert the
correct SID into this statement that you discovered above. Also ensure the password is set
correctly:
USE [master]
GO
CREATE LOGIN passwordstate_user WITH PASSWORD=N'Welcome01',
SID=0x161D86476500E34EB821B6A0E766B89F, DEFAULT_DATABASE=passwordstate,
DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
• Back on your Passwordstate webserver, change the Data Source to be your new listener instead of
SQLDB1
• If your database servers are located on different subnets, you will also need to insert
;MultiSubnetFailover=Yes into your connection string as per below screenshot:
If your Primary SQL Server is unavailable for any reason, then it will automatically failover to the second
server. The time it takes to failover will depend on network bandwidth and database sizes, but for a small
database it is only a few seconds.