In our last installment, we took a look at deploying a set of VMs with shared storage in the form of shared virtual disks. This week, we’ll go into the guests and bring the disks online and deploy Failover Cluster.

Preparing The Disks

When we attach the shared virtual disks along with our Windows template vDisk, the shared disks will start out offline and unformatted. We’ll rectify that here. You can use the Disk Management applet in Computer Management to do this, but we’ll present it here as a set of DISKPART.EXE commands, which are easy to copy/paste and apply in a script somewhere.

No matter which approach you take, the process is the same and comes down to these steps:

  1. On the primary:
    1. Online the shared disks
    2. Explicitly assign a drive letter (optional)
    3. Format the disks
  2. On the secondary
    1. Online the shared disks
    2. Explicitly assign a drive letter (optional)

Add the following commands to a text file (init-disks-primary.txt for example):

select disk 1
online disk
attributes disk clear readonly
create partition primary
select partition 1
format fs=NTFS LABEL="DATA"
assign letter=S

select disk 2
online disk
attributes disk clear readonly
create partition primary
select partition 1
format fs=NTFS LABEL="LOGS"
assign letter=L

These commands are DISKPART.EXE commands to bring each disk online, set them writable and create a partition and format it. We also explicitly assign drive letters (S for SQL and L for Logs). The latter isn’t required.

To run these commands in batch, simply redirect the contents of this file to stdin for DISKPART.EXE, which might look like this:

DISKPART.EXE < init-disks-primary.txt

We do this on the primary. The secondary is a very similar process, but we don’t need to create a partition or format it (the primary will have already done so). For the secondary, add the following DISKPART.EXE commands to a file called init-disks-secondary.txt:

select disk 1
online disk
attributes disk clear readonly
select partition 1
assign letter=S

select disk 2
online disk
attributes disk clear readonly
select partition 1
assign letter=L

And run those in a similar fashion:

DISKPART.EXE < init-disks-secondary.txt

At this point, we have both disks available to both guests. It’s important that we don’t try to write anything to the disks at this point — we need to deploy Failover Cluster to control which VM has write access to the disks (the active node in the cluster). If you take a look at the Disk Management applet in Computer Management, you ought to see something similar this:

disk-mgmt-clustered

Installing and configuring Failover Cluster on both nodes is straightforward through PowerShell. First, we install the Failover Cluster role on both VMs:

Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools

And then create a new cluster from the primary node and add the secondary and the shared virtual disks. To deploy the cluster, we’ll need the following information:

  1. A unique name for the cluster (SQL-SC in the example below)
  2. A shared IP address for clients to access the cluster (192.0.2.30 in the example below)
  3. The names of the nodes/VMs in the cluster (RSVD-SC1 and RSVD-SC2 in the example below)

Given those, we can create the cluster:

New-Cluster -Name SQL-SC -Node RSVD-SC1 -StaticAddress 192.0.2.30

Add the second node to the cluster:

Add-ClusterNode -Cluster SQL-SC -Name RSVD-SC1

And finally add all of the shared storage to the cluster:

Get-ClusterAvailableDisk -Cluster SQL-SC | Add-ClusterDisk -Cluster SQL-SC

At this point, you should have a two node cluster and Failover Cluster Manager should show the two shared virtual disks as cluster shared storage, which might look something like this:

rsvd-clustered

With the cluster running, simply use the Microsoft SQL Server installer to install a clustered instance of SQL and point it at the shared storage. You can then point your SQL clients at the cluster name given above and live happily ever after.

[Serpens Cluster image by Robert Sullivan and used unmodified under Public Domain]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s