Part 1: Deploy SQL Server 2016 Availability Groups

As I was about to start deploying a SQL server for use by VMM, I was reminded about how SQL is licensed when it’s for the purpose of hosting System Center databases. If you’re licensing your Hyper-V hosts with Cloud Platform Datacentre licenses, any SQL licences required for your System Center DBs are already covered.

With that in mind, I decided that if this was actually a production build, I’d build out a 2 node SQL AlwaysON cluster that uses Availability Groups for hosting all System Center databases.

The only database we will place here (during the guide) is the VMM database. For reasons I’ll explain a little further on, I had to go with the Enterprise edition of SQL, be aware though that only SQL Standard licensing is covered when using the Cloud Platform Datacentre licensing model for System Center.

The SQL AlwaysON Availability Group feature is basically (to quote Microsoft):

…a high-availability and disaster-recovery solution that provides an enterprise-level alternative to database mirroring. Introduced in SQL Server 2012, Always On Availability Groups maximizes the availability of a set of user databases for an enterprise. An availability group supports a failover environment for a discrete set of user databases, known as availability databases, that fail over together. An availability group supports a set of read-write primary databases and one to eight sets of corresponding secondary databases. Optionally, secondary databases can be made available for read-only access and/or some backup operations.

An availability group fails over at the level of an availability replica. Failovers are not caused by database issues such as a database becoming suspect due to a loss of a data file, deletion of a database, or corruption of a transaction log.

For more information on the benefits I’d suggest having a read through the rest of the article: https://msdn.microsoft.com/en-us/library/hh510230.aspx

Prerequisites

This part of the guide won’t be focusing on the installation of SQL itself and is not intended as a best practice example, but more on the configuration of Availability groups. Before we can do that though, you will need the following:

Deploy 2 domain joined Virtual Machines to your preferred specifications, see example below

Virtual MachinevCPURAM (GB)Storage (GB)
SCSQL121650GB Database Drive (E:)
50GB Log Drive (L:)
SCSQL2
21650GB Database Drive (E:)
50GB Log Drive (L:)
    • Install .NET Framework 3.5.1 on both nodes
    • Install Failover Cluster manager on both nodes
Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools
    • Create a Failover Cluster from both SQL nodes – full guide HERE
Test-Cluster –Node SCSQL1, SCSQL2
New-Cluster –Name MyCluster –Node Server1, Server2 –StaticAddress 192.168.1.12 -NoStorage
  • Install SQL Server 2016 with SP1 on both nodes – Full guide HERE:  Make sure to select “New SQL Server stand-alone installation”
  • Install Microsoft SQL Server Management Studio (I install on both nodes for convenience) – Download Link
  • Apply all available Windows Updates to the VMs

Configure Cluster Quorum

A nice feature called Cloud Witness was added to Failover Clustering in Server 2016 which allows users to create a cluster quorum that sits in an Azure Storage Account.

This guide assumes that you already have an Azure account and have set up the relevant storage accounts and keys, with that in mind, here is a quick how-to on how to make use of that storage account for creating a Failover Cluster Manager Cloud Witness. Depending on your role within the organisation, you may have to request this information from another IT team, if that is the case, then you’ll need to know the following pieces of information:

  • Azure storage account name
  • Azure storage account key
  • Azure service endpoint – this is auto-configured as core.windows.net and should only really need changing when we start to consume services like this from Azure Stack

If you have access to your companies Azure portal you can find the information you need by navigating to (once logged in):

Storage Accounts > Relevant Storage Account > Access Keys

From here you should be able to copy the key you need to the clipboard (See screenshot).

Armed with this information, let’s go back to Failover Cluster Manager and configure our quorum.

If you don’t have access to an Azure account, you can still configure a quorum using the methods available in Server 2012 R2 and before. The following TechNet article provides a wealth of information of cluster quorums and their setup (the article is for Server 2012 but is still relevant in 2016 unless you’re using a Cloud quorum).

https://technet.microsoft.com/en-us/library/jj612870(v=ws.11).aspx

However, we’re using a cloud witness so let’s get on with it shall we?

Within Failover Cluster Manager, right-click the cluster name on the left pane and select “More Actions” and “Configure Cluster Quorum Settings”

clip_image002

Select “Next”, “Advanced quorum configuration” and “Next”

Select “All Nodes” then “Next”

clip_image003

Select “Configure a cloud witness” then click “Next”

Populate the “Azure storage account name” and “Azure storage account key” fields with the information you grabbed from Azure earlier and click “Next”, “Next” and “Finish”

clip_image004

You should now be able to see your quorum listed under the core resources of your cluster…good job!

clip_image005

Configuring Availability Groups

Armed with a fresh new SQL deployment, we can now start to configure our availability groups. As I mentioned above, we’ll be using this SQL deployment to host our SCVMM DB but the intention would be that any other System Center DBs you have or will add later should be placed here also.

One of the limitations of using SQL Standard is that you can only have one DB per Availability Group, which doesn’t sound like an issue as you can just create a new availability group per DB. However, it does mean that you can’t group databases together that will fail over together. The reason I chose to go with SQL Enterprise though is because of the way Availability Groups are created and the issue this caused me while running through the SCVMM installation, more on this to follow.

First we need to enable the Availability Group feature on your SQL instance. To do this:

Open up “SQL Server Configuration Manager”, select “SQL Server Services” on the left pane and right-click your SQL instance on the right pane and select “Properties”.

clip_image006

Select the “AlwaysOn High Availability” tab and place a tick in “Enable AlwaysOn Availability Groups” and click “OK”

Now restart the service.

clip_image007

We can now go on and create an Availability Group using Microsoft SQL Server Management Studio

You can’t create an Availability Group without first having a DB to reside in it. Being that on Standard, you can only have one DB per group, SCVMM wouldn’t be able to add its own DB to this group. Here are the ways I tried to work round this:

Pre-stage the SCVMM DB on SCSQL1 and point the SCVMM installer towards it (at this point you could also just let the installer create the DB, the outcome will be the same). The installation completed successfully but we now have a DB that isn’t a member to an Availability Group. When adding the DB to an Availability Group, its connection string and IP will change and SCVMM is still set to connect to SCSQL1. To change this it’s basically an uninstall/reinstall of the SCVMM management server while retaining the DB. When running through the reinstall, it rolled back and threw an error as it kept trying to change the DB recovery model back to Simple (even though Full was selected when it was created). POINT TO NOTE, it’s entirely possible that you can get this working but for me the installer just wouldn’t complete irrelevant of what I tried.

I then decided to install SQL Enterprise as it allows multiple DBs per Availability Group. The idea here was to create a temporary DB to get the Availability Group up and running and then point the SCVMM installer towards the group listener and let it create its own DB as normal. This worked without issue.

With the above in mind, let’s move on and run through that process.

Create a Temporary Database

Right-click on “Databases” on the left pane and select “New Database…”

clip_image008

Type a name for your database, this can be anything as this DB can be deleted later.

clip_image009

Under “Options” make sure the “Recovery Model” is “Full” and click “OK”

clip_image010

Now before we can create an Availability Group there are two last task that need completed:

  • Carry out a full backup of the database you just created
  • Give your SQL CNO (Cluster Name Object) permission to create object within its OU in Active Directory. This is a requirement as the cluster needs to create a computer object for the Availability Group that you’re about to add.

Backup your Database

Right-click on your database on the left pane and select “Tasks” and then “Backup”

clip_image011

Just select the defaults here and click “OK”, we don’t care about this backup as it’s only to allow us to use the DB in the creation of the Availability Group

clip_image012

clip_image013

Add Permissions for Cluster CNO

We need to give your cluster computer object specific permissions over the OU it resides in. It needs these to be able to create other computer objects for any cluster roles it deploys.

You may have to enable Advanced Features within the Active Directory Users and Computers MMC to view the security tab on an OU. You can do this as follows:

Press “Windows +R” and type “dsa.msc” to launch the Active Directory Users and Computers MMC

Click on “View” in the menu bar and select “Advanced Features”

clip_image014

Using Active Directory Users and Computers MMC, browse to the OU that holds your cluster CNO, right click and select “Properties”

Select the “Security” tab and click “Add”

clip_image015

Click Object Types and place a tick in “Computers” to include them in/limit the search scope and click “OK”

clip_image016

clip_image017

Type your SQL cluster CNO under “Enter the object names to select” and click “OK”

clip_image018

Now click “Advanced”, highlight the account you just added and select “Edit”

clip_image019

Under “Permissions”, place a tick in “List contents” and “Create Computer Objects”.

Scroll down to “Properties” and make sure there is also a tick in “Read all properties” and click “OK” 3 times

clip_image020

clip_image021

Create Availability Group…FINALLY!

Browse to “AlwaysOn High Availability” and right-click on “Availability Group”. Now select “New Availability Group Wizard”

clip_image022

Enter a name that makes sense and place a tick in “Database Level Heath Detection”. Now click “Next”

clip_image023

Select the temp database that you created earlier. Note that the status shows as “Meets prerequisites”. This is because we did a full backup earlier. Now click “Next”.

clip_image024

Click “Add Replica…”. Under “Server Name”, type the name of your second SQL node and click “Connect”

clip_image025

Configure Automatic Failover and Synchronous Commit as show below and click on the “Listener” tab.

clip_image026

Select “Create an availability group listener now”. Enter a name, 1433 for the port and select “Static IP” from the dropdown.

Click “Add…”, select the correct subnet from the dropdown and type in an IP address. Now click “OK” and “Next”.

clip_image027

Select “Full” as the synchronization preference and type in a file share name that both nodes have access to and click “Next”

clip_image028

This screen will run through the validation, assuming all it well, click “Next” and then “Finish”. If there are any errors, you can click on the error link and it’ll give you additional information to assist in troubleshooting.

clip_image029

clip_image030

Here’s how your “AlwaysOn High Availability” tree should look now.

clip_image031

Now you have your Availability Group and listener up and running, we can continue on to our SCVMM installation

2 Replies to “Part 1: Deploy SQL Server 2016 Availability Groups”

  1. Thank you for this good article.

    I get an error on the “New availibility group” @ the validation step. I get this error:

    Checking for the database files on the secondary replica SQL-SRV2 resulted in an error. The following files already exist. \\sql-dc1\DatabaseSQL1\MSSQL13.MSSQLSERVER\MSSQL\DATA\SQL-Test.mdf;\\sql-dc1\logsSQL1\MSSQL13.MSSQLSERVER\MSSQL\Data\SQL-Test_log.ldf (Microsoft.SqlServer.Management.HadrModel)

    I created the database on de SQL-SRV1 server. The locatoin mentioned above is on de SQL-SRV1 server. The locations for de SQL-SRV2 server are \\sql-dc1\DatabaseSQL2\…

    Could you help me with this error

    1. Hi Romke,

      What’s your setup, as I’ve noticed the error you listed contains “sql-dc1” as part of the UNC path. You mention that “sql-dc1” exists on “SQL-SRV1”, can you elaborate a little please?
      Thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *