Installing a Cumulative Update or Windows updates on a Database Availability Group (DAG) member without first draining it can cause failed deliveries and unexpected database failovers. This is the sequence to follow. In the examples, EX01 is the server being patched and EX02.contoso.com is another Mailbox server in the same site.
Before you start
- Run everything from the Exchange Management Shell, as administrator.
- Make sure the other DAG members are healthy (
Get-MailboxDatabaseCopyStatus). - Note in your change log which databases are active on
EX01.
Enter maintenance mode
1. Drain transport
Set-ServerComponentState -Identity EX01 -Component HubTransport -State Draining -Requester Maintenance
Restart-Service MSExchangeTransport
Restart-Service MSExchangeFrontEndTransport
2. Redirect queued messages
Redirect-Message -Server EX01 -Target EX02.contoso.com
3. Pause the cluster node
Suspend-ClusterNode -Name EX01
4. Move active databases off and block activation
Set-MailboxServer -Identity EX01 -DatabaseCopyActivationDisabledAndMoveNow $true
Set-MailboxServer -Identity EX01 -DatabaseCopyAutoActivationPolicy Blocked
Wait until no database is still mounted on EX01:
Get-MailboxDatabaseCopyStatus -Server EX01 | Where-Object Status -eq "Mounted"
5. Take the whole server offline
Set-ServerComponentState -Identity EX01 -Component ServerWideOffline -State Inactive -Requester Maintenance
You can now install the update and reboot.
Leave maintenance mode
Run the same steps in reverse:
Set-ServerComponentState -Identity EX01 -Component ServerWideOffline -State Active -Requester Maintenance
Resume-ClusterNode -Name EX01
Set-MailboxServer -Identity EX01 -DatabaseCopyAutoActivationPolicy Unrestricted
Set-MailboxServer -Identity EX01 -DatabaseCopyActivationDisabledAndMoveNow $false
Set-ServerComponentState -Identity EX01 -Component HubTransport -State Active -Requester Maintenance
Restart-Service MSExchangeTransport
Restart-Service MSExchangeFrontEndTransport
Check before you close the change
Get-ServerComponentState -Identity EX01 | Where-Object State -ne "Active"
Get-MailboxDatabaseCopyStatus -Server EX01
Then rebalance active databases across the DAG with the RedistributeActiveDatabases.ps1 script from the Exchange Scripts folder, using -BalanceDbsByActivationPreference.
| Step | Enter | Leave |
|---|---|---|
| Transport | HubTransport Draining |
HubTransport Active |
| Cluster | Suspend-ClusterNode |
Resume-ClusterNode |
| Databases | Activation blocked | Unrestricted |
| Server | ServerWideOffline Inactive |
ServerWideOffline Active |
- #exchange-server
- #dag
- #patching
- #powershell
Questions about this article or a project of your own?