Home > Uncategorized > HOWTO: Detecting and Automating Exchange 2010 DAG Activation

HOWTO: Detecting and Automating Exchange 2010 DAG Activation

An Exchange 2010 Database Availability Group (DAG) requires that each DB has more than one DB, which can be active only on one sever in the Mailbox DAG.  Various events can cause these DAG’s to become active on the opposite node – failure of hardware, load of hardware, failure of quorum, etc.  In these cases, there are ways to automate the discovery of this event.  However, it would be nice if there was a way to automate the rebalance of this event as well.  Turns out – there is.

All DAG’s and DB’s in Exchange 2010 have an “Activation Preference”.  This determines which Mailbox node is preferred, in which order.  This can be seen in the GUI as such:

clip_image001

Here we can see that A2J and EXEC are set to be Activation Preference 1 on SERVERMBX1, and K2Z is set as Activation Preference 2.  The opposite is true for SERVERMBX2.

It turns out, that since Exchange 2010 SP2, there have been built in scripts to deal with this, found in the <DRIVE>:\Program Files\Microsoft\Exchange Server\V14\Scripts folder.   Two scripts exist that are relevant here:

1) Identify the DAG status:

[PS] E:\Program Files\Microsoft\Exchange Server\V14\Scripts>.\RedistributeActiveDatabases.ps1 -ShowDatabaseDistributionByServer | ft

ServerName           TotalDbs      ActiveDbs     PassiveDbs PreferenceCoun     MountedDbs  DismountedDbs DagName

                                                            tList

———-           ——–      ———     ———- ————–     ———-  ————- ——-

SERVERMBX2                 3              1              2 {1, 2}                      1              0 SERVERvxdag2

SERVERMBX1                 3              2              1 {2, 1}                      2              0 SERVERvxdag2

-or-

[PS] E:\Program Files\Microsoft\Exchange Server\V14\Scripts>.\RedistributeActiveDatabases.ps1 -ShowDatabaseCurrentActives | ft

***************************************

Balance DAG DBs

Friday, October 11, 2013 11:08:51 PM

***************************************

Dag                                :   SERVERvxdag2

ServerCount                        :   2

DatabaseCount                      :   3

CopiesCount                        :   6

—————————-

Starting Server Distribution

—————————-

ServerName  TotalDbs ActiveDbs PassiveDbs PreferenceCountList MountedDbs DismountedDbs DagName

———-  ——– ——— ———- ——————- ———- ————- ——-

SERVERMBX1        3         2          1 {2, 1}                       2             0 SERVERvxdag2

SERVERMBX2        3         1          2 {1, 2}                       1             0 SERVERvxdag2

DbName            ActiveOnPreferen ActiveServerAtSt ActiveOnPreferen ActiveServerAtEn IsOnMostPreferre       MoveStatus

                         ceAtStart art              ceAtEnd          d                           dCopy

——            —————- —————- —————- —————- —————-       ———-

Mailboxes K2Z New                1 SERVERMBX2                                                    True  NoMoveAttempted

Mailboxes A2J New                1 SERVERMBX1                                                    True  NoMoveAttempted

Mailboxes EXEC                   1 SERVERMBX1                                                    True  NoMoveAttempted

—————-

Summary of Moves

—————-

Successfully moved      : 0

Moved to less preferred : 0

Failed to move          : 0

Not moved               : 3

Start time              : Friday, October 11, 2013 11:08:49 PM

End time                : Friday, October 11, 2013 11:08:51 PM

Duration                : 00:00:01.7628226

2) Correct the DAG status:

[PS] E:\Program Files\Microsoft\Exchange Server\V14\Scripts>.\RedistributeActiveDatabases.ps1 -DAGName SERVERvxdag2 -BalanceDBsByActivationPreference -whatif

***************************************

Balance DAG DBs

Friday, October 11, 2013 11:12:41 PM

***************************************

Dag                                :   SERVERvxdag2

ServerCount                        :   2

DatabaseCount                      :   3

CopiesCount                        :   6

—————————-

Starting Server Distribution

—————————-

ServerName  TotalDbs ActiveDbs PassiveDbs PreferenceCountList MountedDbs DismountedDbs DagName

———-  ——– ——— ———- ——————- ———- ————- ——-

SERVERMBX1        3         1          2 {2, 1}                       1             0 SERVERvxdag2

SERVERMBX2        3         2          1 {1, 2}                       2             0 SERVERvxdag2

———————–

Starting Database Moves

———————–

Considering move of ‘Mailboxes EXEC’ from ‘SERVERMBX2’ (AP = 2) to ‘SERVERMBX1’ (AP = 1)…

Database ‘Mailboxes EXEC’ successfully moved from ‘SERVERMBX2’ to ‘SERVERMBX1’.

ServerName  ActiveDbs PassiveDbs

———-  ——— ———-

SERVERMBX1         2          1

SERVERMBX2         1          2 `n

—————-

Summary of Moves

—————-

Successfully moved      : 1

Moved to less preferred : 0

Failed to move          : 0

Not moved               : 2

Start time              : Friday, October 11, 2013 11:12:39 PM

End time                : Friday, October 11, 2013 11:12:41 PM

Duration                : 00:00:01.9033464

DbName                    : Mailboxes A2J New

ActiveOnPreferenceAtStart : 1

ActiveServerAtStart       : SERVERMBX1

ActiveOnPreferenceAtEnd   : 1

ActiveServerAtEnd         : SERVERMBX1

IsOnMostPreferredCopy     : True

MoveStatus                : NoMoveAttempted

DbName                    : Mailboxes EXEC

ActiveOnPreferenceAtStart : 2

ActiveServerAtStart       : SERVERMBX2

ActiveOnPreferenceAtEnd   : 1

ActiveServerAtEnd         : SERVERMBX1

IsOnMostPreferredCopy     : True

MoveStatus                : MoveSucceeded

DbName                    : Mailboxes K2Z New

ActiveOnPreferenceAtStart : 1

ActiveServerAtStart       : SERVERMBX2

ActiveOnPreferenceAtEnd   : 1

ActiveServerAtEnd         : SERVERMBX2

IsOnMostPreferredCopy     : True

MoveStatus                : NoMoveAttempted

                Here you can see that if we run the command with the “-whatif” parameter, we see that it wants to move the EXEC DB, which is in fact activated on the incorrect server.  Regardless of what it displays, PowerShell “-whatif” only SHOWS the same output of IF the command ran.  Rerun the command with “-confirm:$False” instead of “-whatif”.   This will run the command without any prompt for confirmation – such as if you wanted to run it in an automated script periodically. 

NOTE: Changing the DAG Activation status of a DB may cause a password prompt on Outlook clients that are highly active and/or not in “cached” mode.  As such, it is recommended that this level of automation only be run outside of normal business hours (eg: 7PM – 5AM).  Automating the activation of the script may require including additional parameters to let the proper Exchange PowerShell modules to load in a non-interactive session. 

NOTE: This does not, of course, remove the need to determine the root cause of the issue and/or prevent it from occurring in the first place. 

It is worth noting that there is a wealth of built in Microsoft provided Exchange scripts, that are worthy of exploration as your time permits:

clip_image002

Particularly “StartDagServerMaintenance” and “StopDagServerMaintenance” which handle preventing the automated rebalance during maintenance instead of failure (eg: when the DAG activation status is intentional).

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: