Database availability groups are reasonably smart and robust systems, but they do need monitoring, or else you might find one day they are not providing the HA that you need them to. One of the useful PowerShell cmdlets for keeping an eye on things is Test-ReplicationHealth. It can be used to help troubleshoot database availability groups by running it locally or against a remote server.
[PS] C:\>Test-ReplicationHealth Server Check Result Error ------ ----- ------ ----- E15MB2 ClusterService Passed E15MB2 ReplayService Passed E15MB2 ActiveManager Passed E15MB2 TasksRpcListener Passed E15MB2 TcpListener Passed E15MB2 ServerLocatorService Passed E15MB2 DagMembersUp Passed E15MB2 ClusterNetwork Passed E15MB2 QuorumGroup Passed E15MB2 DatabaseRedundancy Passed E15MB2 DatabaseAvailability Passed E15MB2 DBCopySuspended Passed E15MB2 DBCopyFailed Passed E15MB2 DBInitializing Passed E15MB2 DBDisconnected Passed E15MB2 DBLogCopyKeepingUp Passed E15MB2 DBLogReplayKeepingUp Passed
To test a remote server, use the -Identity parameter.
[PS] C:\>Test-ReplicationHealth -Identity E15MB2 Server Check Result Error ------ ----- ------ ----- E15MB2 ClusterService Passed E15MB2 ReplayService Passed E15MB2 ActiveManager Passed E15MB2 TasksRpcListener Passed E15MB2 TcpListener Passed E15MB2 ServerLocatorService Passed E15MB2 DagMembersUp Passed E15MB2 ClusterNetwork Passed E15MB2 QuorumGroup Passed E15MB2 DatabaseRedundancy Passed E15MB2 DatabaseAvailability Passed
The cmdlet also accepts pipeline input, however if you were to simply pipe Get-MailboxServer into it and you have Mailbox servers in the organization that are not DAG members then you risk seeing errors in your results that just get in the way. Instead you can pipe only the members of a database availability group into Test-ReplicationHealth using the following method:
[PS] C:\>Get-DatabaseAvailabilityGroup | select -ExpandProperty:Servers | Test-ReplicationHealth
There’s a lot of output to look at, so it’s often easier to filter the results to only those that have not passed.
[PS] C:\>Get-DatabaseAvailabilityGroup | Select -ExpandProperty:Servers | Test-ReplicationHealth | Where {$_.Result.Valu e -ne "Passed"} Server Check Result Error ------ ----- ------ ----- EX2016SRV2 DatabaseAvailability *FAILED* Failures:... EX2016SRV1 DatabaseAvailability *FAILED* Failures:...
The error details are usually truncated, so outputting the results as a list will let you see more information.
[PS] C:\>Get-DatabaseAvailabilityGroup | Select -ExpandProperty:Servers | Test-ReplicationHealth | Where {$_.Result.Val e -ne "Passed"} | Format-List
By the way, if you’re curious about what each of the tests do, there’s a “CheckDescription” provided for each of the checks that Test-ReplicationHealth performs. Some of them are still a bit vague, but there’s some useful info there that can help point you in the right direction to investigate further.
[PS] C:\>Test-ReplicationHealth | Format-List Check* Check : ClusterService CheckDescription : Checks if the cluster service is healthy. Check : ReplayService CheckDescription : Checks if the Microsoft Exchange Replication service is running. Check : ActiveManager CheckDescription : Checks that Active Manager is running and has a valid role. Check : TasksRpcListener CheckDescription : Checks that the Tasks RPC Listener is running and is responding to remote requests. Check : TcpListener CheckDescription : Checks that the TCP Listener is running and is responding to requests. Check : ServerLocatorService CheckDescription : Checks that the Server Locator Service is running and is responding to requests. Check : DagMembersUp CheckDescription : Verifies that the members of a database availability group are up and running. Check : MonitoringService CheckDescription : Checks that the Monitoring WCF Service is running and is responding to requests. This endpoint is hosted inside the DAG Management service. Check : ClusterNetwork CheckDescription : Checks that the networks are healthy. Check : QuorumGroup CheckDescription : Checks that the quorum and witness for the database availability group is healthy. Check : FileShareQuorum CheckDescription : Verifies that the path used for the file share witness can be reached. Check : DatabaseRedundancy CheckDescription : Verifies that databases have sufficient redundancy. If this check fails, it means that some databases are at risk of losing data. Check : DatabaseAvailability CheckDescription : Verifies that databases have sufficient availability. If this check fails, it means that some databases are at risk of losing service.
This article Using Test-ReplicationHealth to Troubleshoot Database Availability Groups is © 2016 ExchangeServerPro.com
Get more Exchange Server tips at ExchangeServerPro.com