How-to – Rebalance Mailbox Databases in a DAG with Exchange Server 2010 SP1

0
930

After an outage or maintenance to the Mailbox servers in a Database Availability Group you may find that the mailbox databases are no longer balanced across all of the DAG members.

For example after applying updates to DAG members you may see that all of the mailbox databases are active on a single DAG member.

[PS] C:\>Get-MailboxDatabase | ft name, server, activationpreference -AutoSize

Name                Server ActivationPreference
----                ------ --------------------
Mailbox Database 02 EX1    {[EX2, 1], [EX1, 2]}
Mailbox Database 01 EX1    {[EX1, 1], [EX2, 2]}
Mailbox Database 03 EX1    {[EX1, 1], [EX2, 2]}
Mailbox Database 04 EX1    {[EX2, 1], [EX1, 2]}

You can see in the above output that all of the mailbox databases are active on server EX1, even though some of them have EX2 as a preferred server.

Exchange Server 2010 Service Pack 1 shipped with a script that allows you to automatically redistribute mailbox databases to their first activation preference. The script can be found in the \Scripts folder of the Exchange Server 2010 installation path, which by default would be C:\Program Files\Microsoft\Exchange\V14\Scripts.

You can use the script to output a report of the current mailbox database distribution among the DAG members.

[PS] C:\Program Files\Microsoft\Exchange Server\V14\Scripts>.\RedistributeActiveDatabases.ps1 -DagName DAG -ShowDatabase
DistributionByServer | ft

ServerName           TotalDbs      ActiveDbs     PassiveDbs PreferenceCoun     MountedDbs  DismountedDbs DagName
                                                            tList
----------           --------      ---------     ---------- --------------     ----------  ------------- -------
EX2                         4              0              4 {2, 2}                      0              0 dag
EX1                         4              4              0 {2, 2}                      4              0 dag

To rebalance the mailbox databases based on activation preference use the following script parameters.

[PS] C:\Program Files\Microsoft\Exchange Server\V14\Scripts>.\RedistributeActiveDatabases.ps1 -DagName DAG -BalanceDbsBy
ActivationPreference

***************************************
Balance DAG DBs
Thursday, October 28, 2010 10:16:36 PM
***************************************
Dag                                :   dag
ServerCount                        :   2
DatabaseCount                      :   4
CopiesCount                        :   8

----------------------------
Starting Server Distribution
----------------------------

ServerName TotalDbs ActiveDbs PassiveDbs PreferenceCountList MountedDbs DismountedDbs DagName
---------- -------- --------- ---------- ------------------- ---------- ------------- -------
EX1               4         4          0 {2, 2}                       4             0 dag
EX2               4         0          4 {2, 2}                       0             0 dag

-----------------------
Starting Database Moves
-----------------------

Considering move of 'Mailbox Database 04' from 'ex1' (AP = 2) to 'EX2' (AP = 1)...

Confirm
Are you sure you want to perform this action?
Moving mailbox database "Mailbox Database 04" from server "ex1.exchangeserverpro.local" to server
"EX2.exchangeserverpro.local".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): a
Database 'Mailbox Database 04' successfully moved from 'ex1' to 'ex2'.

ServerName ActiveDbs PassiveDbs
---------- --------- ----------
EX1                3          1
EX2                1          3 `n
Considering move of 'Mailbox Database 02' from 'ex1' (AP = 2) to 'EX2' (AP = 1)...

Confirm
Are you sure you want to perform this action?
Moving mailbox database "Mailbox Database 02" from server "ex1.exchangeserverpro.local" to server
"EX2.exchangeserverpro.local".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): a
Database 'Mailbox Database 02' successfully moved from 'ex1' to 'ex2'.

ServerName ActiveDbs PassiveDbs
---------- --------- ----------
EX1                2          2
EX2                2          2 `n

----------------
Summary of Moves
----------------
Successfully moved      : 2
Moved to less preferred : 0
Failed to move          : 0
Not moved               : 2

Start time              : Thursday, October 28, 2010 10:16:35 PM
End time                : Thursday, October 28, 2010 10:17:51 PM
Duration                : 00:01:15.3764472

DbName                    : Mailbox Database 01
ActiveOnPreferenceAtStart : 1
ActiveServerAtStart       : ex1
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : ex1
IsOnMostPreferredCopy     : True
MoveStatus                : NoMoveAttempted

DbName                    : Mailbox Database 02
ActiveOnPreferenceAtStart : 2
ActiveServerAtStart       : ex1
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : ex2
IsOnMostPreferredCopy     : True
MoveStatus                : MoveSucceeded

DbName                    : Mailbox Database 03
ActiveOnPreferenceAtStart : 1
ActiveServerAtStart       : ex1
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : ex1
IsOnMostPreferredCopy     : True
MoveStatus                : NoMoveAttempted

DbName                    : Mailbox Database 04
ActiveOnPreferenceAtStart : 2
ActiveServerAtStart       : ex1
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : ex2
IsOnMostPreferredCopy     : True
MoveStatus                : MoveSucceeded

You can see in the above output that all of the mailbox databases are active on server EX1, even though some of them have EX2 as a preferred server.

Exchange Server 2010 Service Pack 1 shipped with a script that allows you to automatically redistribute mailbox databases to their first activation preference. The script can be found in the \Scripts folder of the Exchange Server 2010 installation path, which by default would be C:\Program Files\Microsoft\Exchange\V14\Scripts.

You can use the script to output a report of the current mailbox database distribution among the DAG members.

[PS] C:\Program Files\Microsoft\Exchange Server\V14\Scripts>.\RedistributeActiveDatabases.ps1 -DagName DAG -ShowDatabase
DistributionByServer | ft

ServerName           TotalDbs      ActiveDbs     PassiveDbs PreferenceCoun     MountedDbs  DismountedDbs DagName
                                                            tList
----------           --------      ---------     ---------- --------------     ----------  ------------- -------
EX2                         4              0              4 {2, 2}                      0              0 dag
EX1                         4              4              0 {2, 2}                      4              0 dag

To rebalance the mailbox databases based on activation preference use the following script parameters.

[PS] C:\Program Files\Microsoft\Exchange Server\V14\Scripts>.\RedistributeActiveDatabases.ps1 -DagName DAG -BalanceDbsBy
ActivationPreference

***************************************
Balance DAG DBs
Thursday, October 28, 2010 10:16:36 PM
***************************************
Dag                                :   dag
ServerCount                        :   2
DatabaseCount                      :   4
CopiesCount                        :   8

----------------------------
Starting Server Distribution
----------------------------

ServerName TotalDbs ActiveDbs PassiveDbs PreferenceCountList MountedDbs DismountedDbs DagName
---------- -------- --------- ---------- ------------------- ---------- ------------- -------
EX1               4         4          0 {2, 2}                       4             0 dag
EX2               4         0          4 {2, 2}                       0             0 dag

-----------------------
Starting Database Moves
-----------------------

Considering move of 'Mailbox Database 04' from 'ex1' (AP = 2) to 'EX2' (AP = 1)...

Confirm
Are you sure you want to perform this action?
Moving mailbox database "Mailbox Database 04" from server "ex1.exchangeserverpro.local" to server
"EX2.exchangeserverpro.local".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): a
Database 'Mailbox Database 04' successfully moved from 'ex1' to 'ex2'.

ServerName ActiveDbs PassiveDbs
---------- --------- ----------
EX1                3          1
EX2                1          3 `n
Considering move of 'Mailbox Database 02' from 'ex1' (AP = 2) to 'EX2' (AP = 1)...

Confirm
Are you sure you want to perform this action?
Moving mailbox database "Mailbox Database 02" from server "ex1.exchangeserverpro.local" to server
"EX2.exchangeserverpro.local".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): a
Database 'Mailbox Database 02' successfully moved from 'ex1' to 'ex2'.

ServerName ActiveDbs PassiveDbs
---------- --------- ----------
EX1                2          2
EX2                2          2 `n

----------------
Summary of Moves
----------------
Successfully moved      : 2
Moved to less preferred : 0
Failed to move          : 0
Not moved               : 2

Start time              : Thursday, October 28, 2010 10:16:35 PM
End time                : Thursday, October 28, 2010 10:17:51 PM
Duration                : 00:01:15.3764472

DbName                    : Mailbox Database 01
ActiveOnPreferenceAtStart : 1
ActiveServerAtStart       : ex1
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : ex1
IsOnMostPreferredCopy     : True
MoveStatus                : NoMoveAttempted

DbName                    : Mailbox Database 02
ActiveOnPreferenceAtStart : 2
ActiveServerAtStart       : ex1
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : ex2
IsOnMostPreferredCopy     : True
MoveStatus                : MoveSucceeded

DbName                    : Mailbox Database 03
ActiveOnPreferenceAtStart : 1
ActiveServerAtStart       : ex1
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : ex1
IsOnMostPreferredCopy     : True
MoveStatus                : NoMoveAttempted

DbName                    : Mailbox Database 04
ActiveOnPreferenceAtStart : 2
ActiveServerAtStart       : ex1
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : ex2
IsOnMostPreferredCopy     : True
MoveStatus                : MoveSucceeded

The outcome of the moves can be seen here. Each mailbox database in the DAG is now active on its preferred server.

[PS] C:\>Get-MailboxDatabase | ft name, server, activationpreference -AutoSize

Name                Server ActivationPreference
----                ------ --------------------
Mailbox Database 02 EX2    {[EX2, 1], [EX1, 2]}
Mailbox Database 01 EX1    {[EX1, 1], [EX2, 2]}
Mailbox Database 03 EX1    {[EX1, 1], [EX2, 2]}
Mailbox Database 04 EX2    {[EX2, 1], [EX1, 2]}

 [This is a rivisited page. Original source page http://exchangeserverpro.com]