≡ Menu

Performing Maintenance on DAG Members in Exchange 2010 SP1

Exchange 2010 SP1 includes a few new scripts that you can use to make DAG member maintenance a breeze. It’s a simple process; you run a script to put a DAG member into maintenance mode, moving the active databases off the server. After maintenance has been completed, you run another script to take the server out of maintenance mode and then you can redistribute the databases across the DAG. The process is outlined in detail below.

1. Run the StartDagServerMaintenance.ps1 script to put the DAG member in maintenance mode
When you run this script, it moves all the active databases to other DAG members. It pauses the node in the cluster, and sets the DatabaseCopyAutoActivationPolicy mailbox server setting to Blocked. The Suspend-MailboxDatabaseCopy cmdlet is run for each database hosted by the DAG member, and the cluster core resources will be moved to another server in the DAG if needed.

[PS] C:\Program Files\Microsoft\Exchange Server\V14\scripts>.\StartDagServerMaintenance.ps1 -serverName adatum-ex1

2. Run the StopDagServerMaintenance.ps1 script to take the DAG member out of maintenance mode
After maintenance is complete, run this script to take the server out of maintenance mode. It will run the Resume-MailboxDatabaseCopy cmdlet for each database its hosting, resume the node in the cluster, and set the DatabaseCopyAutoActivationPolicy setting to Unrestricted.

[PS] C:\Program Files\Microsoft\Exchange Server\V14\scripts>.\StopDagServerMaintenance.ps1 -serverName adatum-ex1

You can run these scripts remotely from another server with the Exchange tools installed and specify the DAG member using the serverName parameter. Just make sure that the server you are running the scripts from has the Windows Failover Cluster Management tools installed.

3. Run RedistributeActiveDatabases.ps1 script to re-balance the active database copies across the DAG
Finally, you can run this script to redistribute the active mailbox databases across the DAG. There are two options for balancing active database copies within a DAG: by activation preference and by site and activation preference.

[PS] C:\Program Files\Microsoft\Exchange Server\V14\scripts>.\RedistributeActiveDatabases.ps1 -DagName DAG -BalanceDbsByActivationPreference -ShowFinalDatabaseDistribution -Confirm:$false

When using the BalanceDbsByActivationPreference parameter the script tries to move the databases to their most preferred copy based on activation preference, regardless of the AD site. If you use the BalanceDbsBySiteAndActivationPreference parameter, the script will attempt to active the most preferred copy and also try to balance them within each AD site.

There are a number of parameters that can be used with this script. Run get-help .\RedistributeActiveDatabases.ps1 for more details. Also, all of these scripts are documented in Managing Mailbox Database Copies and Managing Database Availability Groups on TechNet.

7 comments… add one

  • Dave Rowe April 13, 2011, 11:44 am

    When I run this command I get the following error. Have you seen this before?

    [PS] C:\apps\Exchange\Scripts>.\StartDagServerMaintenance.ps1 -serverName mbx01
    WARNING: [18:42:24.717 UTC] Call-ClusterExe: cluster.exe did not succeed, but 5 was not a retry-able error code. Not
    attempting any other servers. This may be an expected error by the caller.
    WARNING: The Resume operation won’t have an effect on database replication because database ‘DB01′ hosted on server
    ‘MBX01′ is the active mailbox database.
    WARNING: The Resume operation won’t have an effect on database replication because database ‘DB02′ hosted on server
    ‘MBX01′ is the active mailbox database.
    WARNING: The Resume operation won’t have an effect on database replication because database ‘DB03′ hosted on server
    ‘MBX01′ is the active mailbox database.
    WARNING: The Resume operation won’t have an effect on database replication because database ‘DB04′ hosted on server
    ‘MBX01′ is the active mailbox database.
    Log-Error : [18:42:24.717 UTC] Start-DagServerMaintenance: Failed to suspend the server mbx01 from hosting the Primary
    Active Manager, returned 5.
    At C:\apps\Exchange\Scripts\StartDagServerMaintenance.ps1:165 char:14
    + Log-Error <<<< ($StartDagServerMaintenance_LocalizedStrings.res_0004 -f $serverName,$LastExitCode,"
    tart-DagServerMaintenance") -stop
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Log-Error

  • MATT March 15, 2012, 7:42 am

    I received the same error as Dan. The problem…. UAC.

    Run the Exchange Management Shell “as administrator” and then it works.

  • Uwe September 26, 2013, 2:27 am

    That fix the issue!!

    Thanks, Uwe

  • SysAdmin-E.com April 28, 2011, 7:26 am

    It looks like cluster errors. Is you DAG/cluster in good heath? Here are some commands to check that:
    Test-ReplicationHealth
    Test-ServiceHealth

  • Hans October 14, 2011, 2:07 am

    Got the same error. No idea, what this is. Try following:
    Move-ActiveMailboxDatabase -Server <> -ActivateOnServer <>
    This moves the mailbox database copies from Server1 to Server2.
    Get-MailboxDatabaseCopyStatus -Server <>| Suspend-MailboxDatabaseCopy -ActivationOnly
    This prevents the copies from Server 1 to be activated.
    After the maintenance:
    Get-MailboxDatabaseCopyStatus -Server <> | Resume-MailboxDatabaseCopy
    .\RedistributeActiveDatabases.ps1 -DAGName DERT<> -BalanceDbsByActivationPreference -confirm:$false
    Works fine for me.

  • Rino June 24, 2014, 7:33 am

    why is the server name the same for both StartDagServerMaintenance and StopDagServerMaintenance scripts?

    i would have thought in the StartDagServerMaintenance, you specify a destination server while in the StopDagServerMaintenance, you specify the servername where you’re doing maintenance?

  • Scott July 10, 2014, 6:29 pm

    Rino,

    You are simply specifying the server that you are doing the maintenance on. when done you run the stop script to take that server out of maintenance mode. Pretty self explanatory.

Leave a Comment