Exchange Server 2010 SP1 and above – Error putting 2 servers at a time in maintenance mode using StartDagMaintenance.ps1 script


 

 

 

The StartDagMaintenance.ps1 script pauses servers cluster node and blocks chosen servers and databases from being mounted. Here is what it does in the below example, for en environment that has 3 or more Servers with 3 or more database copies per database:

 

Here is the logic used by the script (big thanks to Allan Wang – US PFE for putting the below together !):

  • SERVER_1 (who is already in maintenance) was chosen because

 

    • 1/ the activation preference is set to “1”,

AND

    • 2/ it has the following conditions: “Status=Healthy, ContentIndexing=Healthy, CopyQueueLength=0, ReplayQueueLength=0

 

VERBOSE: [01:45:10.133 UTC] Move-DagMasterCopy: Entering: `$db=DB10, `$srcServer=SERVER_2, `$preferredTarget=

VERBOSE: [01:45:10.180 UTC] Test-DagTargetCopy: Testing move criteria for DB10SERVER_1, with `$Lossless=True and

`$CICheck=False ...

VERBOSE: [01:45:10.196 UTC] Test-DagTargetCopy: Name='RED02RED-MLT-1', Status='Healthy', CIStatus='Healthy',

CopyQueueLength=0, ReplayQueueLength=0

VERBOSE: [01:45:10.196 UTC] Test-DagTargetCopy: Leaving (returning 'True')

 

The suggestion made to administrators is to suspend the database after the server is put into maintenance so that the logic would most likely skip it (Overall status will change to “Suspended” then the script won’t try to mount databases on it)

 

*********** Below example put together by Bernard Chouinard, Canadian independant Consultant *********

 

  • Start the Dag maintenance on the first server with the dag maintenance script (StartDagMaintenance.ps1 –ServerName <First_Server_Name>)

 

  • Then suspend databases on this same first server with the below script:

#Get database on the first server

$dbases = Get-MailboxDatabaseCopyStatus -Server servername

#Suspend the database copy, this is so when the second server is put into maintenance mode it does not select the first server to move databases to

$dbases | %{if ((Get-MailboxDatabase $($_.DatabaseName)).ReplicationType -eq 'Remote'){Suspend-MailboxDatabaseCopy $($_.Name) -SuspendComment 'Serverbeing patched and rebooted' -Confirm:$false}}

 

  • Start the Dag maintenance on the second server with the dag maintenance script (StartDagMaintenance.ps1 –ServerName <SECOND_Server_Name>) – NOTE: databases will be on a third server, but the script won’t try to mount databases on the FIRST server as it’s suspended now.

 

  • Then resume (“un-suspend”) databases on the first server – NOTE: they will continue to replicate, but still be blocked from activation as we ran StartDagMaintenance.ps1 earlier…

#Resume the database copy on the first server

$dbases | %{if ((Get-MailboxDatabase $($_.DatabaseName)).ReplicationType -eq 'Remote'){Resume-MailboxDatabaseCopy $($_.Name) -Confirm:$false}}

 

****************** Example end – Thank you very much Bernard ! *****************

 

Or, if you are a scripting warrior, you can add an “IF” statement to test the DatabaseCopyAutoActivationPolicy  parameter and/or the database status (as the StartDagMaintenance.ps1 script also set individual databases as suspended for activation only).

 

Sam.


Comments (0)

Skip to main content