Exchange DAGs and Cluster Ownership

Change the cluster owner for an Exchange DAG via. Powershell and PRTG

We run Exchange on a multiserver DAG, which behaves similarly to a cluster. It’s built on the same principles as a cluster, but it’s technically not a cluster and is administered differently than a cluster. It’s … clusterish.

One of the issues that we run in to occasionally is that Cluster Owner changes to another DAG member server, which causes problems with our backup software. (The backup software can’t truely handle a cluster and wants to connect to the IP of a single server). The fix is pretty simple - change the owner back to the server it should be! Powershell makes this really easy:


PS H:\> Get-ClusterGroup | Move-ClusterGroup -Node Exchange05

Name                                    OwnerNode                               State
----                                    ---------                               -----
Available Storage                       EXCHANGE04                              Offline
Cluster Group                           Exchange03                              Offline


PS H:\> Get-ClusterGroup

Name                                    OwnerNode                               State
----                                    ---------                               -----
Available Storage                       Exchange05                              Offline
Cluster Group                           Exchange05                              Online

To prevent any complications with our backups, I would like:

  1. The Owner Node to be monitored
  2. The Owner Node to be corrected to the proper values, if it’s not on Exchange05.

We run PRTG for server monitoring…. Fortunately, PRTG can do this for us! The (old) article Monitoring Active Cluster Nodes With PRTG outlines the process. I only used this as a guide, as I ended up sourcing Jannos-443’s PRTG-MSCluster-PrefNodes.ps1 script.

I started by checking the Preferred Node setting for these two cluster objects:

[PS] C:\Windows\system32>Get-ClusterGroup | Get-ClusterOwnerNode

ClusterObject     OwnerNodes
-------------     ----------
Available Storage {}
Cluster Group     {}

Just peachy. Neither object has a preferred owner. Let’s fix that:

[PS] C:\Windows\system32>Get-ClusterGroup | set-ClusterOwnerNode Exchange05.corp.agricorp.com
[PS] C:\Windows\system32>Get-ClusterGroup | Get-ClusterOwnerNode

ClusterObject     OwnerNodes
-------------     ----------
Available Storage {Exchange05}
Cluster Group     {Exchange05}

That’s better. With that out of the way, I created a new PRTG sensor to monitor that the Cluster was Owned by the Preferred Node:

  1. Save the Cluster-checking script to ${env:ProgramFiles(x86)}\PRTG Network Monitor\Custom Sensors\EXEXML on the PRTG probe server.
  2. Open PRTG and browsed to the Exchange05 server object. This is the server that should be the Owner
  3. Create a new sensor. Select a sensor type “EXE/Script Advanced Sensor”.
  4. Select PRTG-MSCluster-PrefNodes.ps1 from the dropdown list. Provide the Exchange Cluster name as a parameter. In my case, I entered Exchange2016.
  5. Set the Security Context of the sensor to Use Windows credentials of parent device
  6. Save changes. Query the sensor a couple of times to make sure that it’s working properly. When one or more nodes isn’t on the Preferred Node, then the sensor will change to ‘Warning’.

Next, I want PRTG’s Notification action to correct the Owner of the cluster object. We’ll create a custom notification that will run a short Powershell script I wrote:

<#
    .SYNOPSIS
    Force Cluster Owner to a specific server

    .DESCRIPTION
    https://kb.paessler.com/en/topic/40713-can-i-automatically-restart-a-windows-service-with-prtg
    Copy this script to the main PRTG server's Notifications\EXE scripts folder (${env:ProgramFiles(x86)}\PRTG Network Monitor\Notifications\EXE)
    and create a new Notification Template > Execute Program. Choose this script from the dropdown and provide the SERVERNAME as a parameter.
    The Credentials need to be generated under the instance that PRTG is running as (NT Authority\System). These domain creds allow PRTG
    to remotely run code on the remote system and manipulate the Cluster Groups.

    .PARAMETER Server
    Server FQDN or NetBIOS Name

    .EXAMPLE
    Sample call from PRTG EXE/Script Advanced
    PRTG-MSCluster-MoveClusterGroup.ps1 EXCHANGE01

    Author:  Greg Beifuss
    7:48 AM 9/8/2021
#>

param(
    [string]$Server = $null
)

$id = Import-Clixml "C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE\powershell.xml"
$Scriptblock = {
Get-ClusterGroup | Move-ClusterGroup -Node $env:COMPUTERNAME
}
Invoke-Command -ComputerName $Server -ScriptBlock $Scriptblock -Credential $id
  1. Use Export-CLIXML to store credentials that can log into the destination server (in my case, Exchange05)
  2. Save this script to ${env:ProgramFiles(x86)}\PRTG Network Monitor\Notifications\EXE)` on the main PRTG server. This is the server that Notifications run from - the other PRTG servers simply won’t have the Notifications directory.
  3. Create a new Notification Template in PRTG. Choose ‘Execute Program’, and select the PRTG-MSCluster-MoveClusterGroup.ps1 script. Provide a cluster member server name as the parameter. This will be passed into the script. Save.
  4. Browse to the PRTG sensor that was previously created. Select ‘Notification Triggers’. Enable a State Trigger that will perform the Notification Template you just created. I used:
    • When sensor state is Warning for at least 60 seconds, perform PRTG-MSCluster-MoveClusterGroup
  5. Save & test.

You can see below that at 7:49ish, both the cluster object owners changed from the preferred nodes. I know this since PRTG detected this as “2”, not “1”. In any case, after the sensor had been in this state for 60 seconds, the notification task started and moved the cluser objects back to their proper ‘home’. The sensor value reset to “0” clusters on a non-preferred node.

Built with Hugo
Theme Stack designed by Jimmy