After an outage or maintenance to the Exchange 2010 or Exchange 2013, or Exchange 2016Mailbox 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.
1
2
3
4
5
6
7
8
|
[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 FilesMicrosoftExchangeV14Scripts.
You can use the script to output a report of the current mailbox database distribution among the DAG members.
1
2
3
4
5
6
7
8
|
[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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
[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.
1
2
3
4
5
6
7
8
|
[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]}
|