I’ve recently been doing a significant amount with Windows Server Clustering and Availability Groups and I thought I’ d get some of the information posted whilst its all fresh.
Clustering, the basics
The basics of Windows Server Clustering are that you have enough nodes or nodes with witnesses that allow you to achieve a majority vote which is called Quorum.
For example if you have two nodes in the cluster and a file share witness you have three nodes which can all vote. So if node number one becomes unavailable, node number two and the file share witness can vote for node number two. Node number two gets two votes, enough for a majority vote or Quorum so the node number two becomes the primary node.
Dynamic Quorum and Dynamic Witness
In Windows Server 2012 R2 Windows Server Clustering gets two new important features that make clustering even easier, dynamic quorum and dynamic witness. Dynamic Quourm was introduced in Windows Server 2012. In previous versions of windows once a cluster node had a vote, usually set up during the initial cluster configuration, it always keeps its vote unless a system administrator explicitly take it away.
With Dynamic Quorum, the quorum majority is determined by the set of nodes that are active members of the cluster. A node will have its vote removed if it is no longer a member of the cluster and will get its vote returned if it becomes a member of the cluster again. Also dynamic quorum will attempt to balance the overall nodes with a vote to an odd number in order to maintain a majority vote.
Dynamic Witness is similar in that the Witness’ weight (or current ability to vote) is also managed to balance the overall nodes with a vote to an odd number in order to maintain a majority vote, so if you have an even number of nodes the Witness gets a vote thus making the overall votes an odd number and therefore the ability to maintain a majority vote.
Starting with Windows Server 2012 R2, it is recommended to always configure a witness as the cluster automatically manages the witness vote, with Dynamic Witness, and the nodes vote with Dynamic Quorum. The following information and setups assume we’re running at least Windows Server 2012 R2 to provide us with both these Dynamic features.
Setting up a two-site three node cluster with a witness
Shown below is a typical example of a three node cluster with a File Share Witness. With SQL Server we would usually have node 1 and node 2 as our synchronous replicas and node 3 as our offsite asynchronous replica.
The above setup can withstand the link between the offsite node 3 becoming unavailable AND an additional node going offline as the witness will get a, dynamic, vote when the link goes unavailable and this protects quorum using node and witness majority.
Using SSMS and Failover cluster manager
When we use our Availability Groups with Windows Server Clustering we can additionally see some of the cluster information in the base tables. To see the members, votes, types and states we can issue the T-SQL command;
SELECT member_name, number_of_quorum_votes,member_type_desc,member_state_desc FROM sys.dm_hadr_cluster_members
Now, if your cluster has a witness, this will return a disk or file share witness and also show that it has a vote. This is not entirely true due to dynamic witness in Windows Server 2012 R2. With Windows Server Clustering in Windows Server 2012 R2 we get Dynamic Quorum and Dynamic Witness which adjusts the ability to cast a vote.
In PowerShell, there is a large amount of available commands to use to manage Windows Server Clustering.
I commonly use the below three commands. The first one returns the information whether or not the witness has a vote. The second command lets us see the the cluster nodes and their state. The third one shows us the nodes, whether or not they have a vote (Dynamic Weight) and their state (Up or Down).
(Get-Cluster).WitnessDynamicWeight Get-ClusterNode Get-ClusterNode | Format-Table Name, Dynamicweight, State
Its always worth repeating that failing over or changing state of availability groups should only be done from Management Studio using the GUI or T-SQL and never using Failover Cluster Manager.
Thanks for reading!