How to Check DAG Health Status for All Exchange Servers
Although DAG provides protection against data loss and helps prevent downtime, it is susceptible to failures. Here's how to check its health status.
Join the DZone community and get the full member experience.
Join For FreeDatabase Availability Group (DAG) is a built-in framework in Microsoft Exchange Server that uses continuous replication and failover clustering to ensure high availability and site resilience.
In Exchange Server, DAG refers to a cluster of Exchange Servers (up to 16 Exchange Mailbox Servers) that hosts a set of database copies and provides protection against switchover and failover. In DAG, there is one active server and a copy of the database on the active server is replicated across all passive servers.
DAG members continuously monitor each other for failure and provide automatic database-level recovery in case of a database, disk, server, or network failure.
Although DAG provides protection against data loss and helps prevent downtime, it is susceptible to failures. Common failures detected in the DAG environment are as follows:
- Witness server failure
- DAG member failure
- MAPI network failure
- Virtual Directory failure
- DAG member failure
- Replication failure
These failures can prevent DAG members from providing automatic database recovery and may lead to downtime and data loss.
It is also a reason why DAG is not considered as an alternative to backups. Even though you have set up Exchange Server in a DAG environment, regular VSS-based backups using application-aware backup tools, such as Windows Server Backup, are critical.
Below, we have discussed steps to check and monitor health for all member Exchange Servers in the DAG environment to ensure high availability and site resilience and prevent failures.
Steps to Check and Monitor DAG Health Status for All Member Exchange Servers
In Microsoft Exchange 2010 SP1 and later versions, you can use the Get-MailboxDatabaseCopyStatus and Test-ReplicationHealth PowerShell cmdlets in Exchange Management Shell (EMS) to check the status of all DAG members, replication health, and database copies in your Exchange environment.
These PowerShell cmdlets provide an overview of all Exchange Servers’ and mailbox databases’ health status in a DAG.
Step 1: Assign Permissions
You need to assign permissions to run these cmdlets for checking the health and replication status of the Exchange Server in a DAG. The steps are as follows:
- Open Exchange Management Shell as administrator and execute the following cmdlets to view permissions needed to run the cmdlets:
$Perms = Get-ManagementRole -Cmdlet <Cmdlet>
Replace <Cmdlet> with the cmdlet for which you need to know the permissions required. For instance,
$Perms = Get-ManagementRole -Cmdlet Get-MailboxDatabaseCopyStatus
$Perms | foreach {Get-ManagementRoleAssignment -Role $_.Name -Delegating $false | Format-Table -Auto Role,RoleAssigneeType,RoleAssigneeName}
Assign Permissions
- Similarly, find the permission and roles required to run the Test-ReplicationHealth:
$Perms = Get-ManagementRole -Cmdlet Test-ReplicationHealth
$Perms | foreach {Get-ManagementRoleAssignment -Role $_.Name -Delegating $false | Format-Table -Auto Role,RoleAssigneeType,RoleAssigneeName}
Test-ReplicationHealth
- Assign the displayed roles and permission via New-ManagementRoleAssignment PowerShell cmdlet,
New-ManagementRoleAssignment –role <role-name> -user <username>
For instance,
New-ManagementRoleAssignment –role “View-only Configuration” -user “administrator”
View-Only Configuration
New-ManagementRoleAssignment –role “Monitoring” -user “administrator.”
Monitoring
Step 2: Check Databases Copy Status in All Exchange Servers
You can use the Get-MailboxDatabaseCopyStatus cmdlet to view information of the mailbox database copies that are part of the Database Availability Group (DAG). You can use the cmdlet to view information related to,
- All database copies of a particular database
Get-MailboxDatabaseCopyStatus -Identity DB2 | Format-List
- All database copies on a particular DAG Exchange Server
Get-MailboxDatabaseCopyStatus -Server MBX2 | Format-List
- Specific database copy of a database on a particular DAG Exchange Server
Get-MailboxDatabaseCopyStatus -Local | Format-List
(Get-DatabaseAvailabilityGroup) | ForEach {$_.Servers | ForEach {Get-MailboxDatabaseCopyStatus -Server $_}}
Step 3: Check Replication Health of All Exchange Servers in DAG
The Test-ReplicationHealth cmdlet allows you to check the information of continuous replication and replay status about the database copies. Besides proactively monitoring the continuous replication and replication pipeline status, the cmdlet helps administrators perform various other tests to keep an eye on the health status of quorum, cluster service, and network components.
You can run the cmdlet remotely or directly on any Exchange Server, a member of the DAG. For example, to test the replication health of Exchange Server EXCHSRV01, run the following command in the EMS.
Test-ReplicationHealth -Identity EXCHSRV01
Replication Health
You may also execute the following command to check all servers in the DAG environment.
(Get-DatabaseAvailabilityGroup) | ForEach {$_.Servers | ForEach {Test-ReplicationHealth -Server $_}}
Step 4: Run Test-ExchangeServerHealth.ps1 or Get-DAGHealthPS1 PowerShell Scripts
The Test-ExchangeServerHealth.ps1 and Get-DAGHealth.ps1 scripts perform a health check on your Exchange 2010/2013 Servers in standalone and DAG environments. It displays a detailed report on the server health status in an HTML document.
The report displays a color-coded table that helps you quickly spot the issues and warnings and fix them before they lead to a disaster.
To run the script, follow these steps:
1. Download the Test_ExchangeServerHealth.ps1 on your server and then open the PowerShell.
2. Navigate to the location where the script is stored and then execute the following command:
.\Test-ExchangeServerHealth.ps1
.\Test-ExchangeServerHealth.ps1
This checks all the servers in your organization and displays a detailed report on the health status and issues.
3. To check specific server status, execute the following command:
.\Test-ExchangeServerHealth.ps1 -Server HO-EXCHSRV01
Exchange Server Health Check Report
In case of error, such as script is not digitally signed, execute the following command and then run the Test-ExchangeServerHealthps1 script.
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Set-ExecutionPolicy
Get-DAGHealth.ps1 script to run series of health checks on the Database Availability Group and generate a much more detailed report.
You can follow the same steps to download and run the.\Get-DAGHealth.ps1 -Detailed
To Wrap Up
Database integrity and consistency can only be ensured when the active and passive database copies on DAG member servers are in sync and healthy. Thus, it is critical to ensure the database copy status and replication health in a DAG environment. In Exchange Server 2010, 2013, 2016, and 2019, you can use the Get-MailboxDatabaseCopyStatus and Test-ReplicationHealth PowerShell cmdlets to check DAG health status for database copies on all Exchange Servers. You may also run the PowerShell scripts to get a detailed report on the DAG health status. In case of failure, you can use your backup to restore a copy of the database or use an exchange recovery software to recover mailboxes from damaged or corrupt databases. The software helps you restore mailboxes from inconsistent Exchange Databases (EDB) when backups are obsolete, do not work, or are unavailable.
Opinions expressed by DZone contributors are their own.
Comments