skip to Main Content

Balance mailbox databases in Exchange DAG

What is the best way to balance mailbox databases in Exchange Server? There are a couple of ways to balance Exchange mailbox databases. In this article, you will learn how to use the PowerShell script that comes with Exchange Server to rebalance mailbox databases.

The organization got two Exchange Servers, and four mailbox databases with a DAG configured. The Exchange Servers are in an active/active state, with each holding active mailbox databases. Two mailbox databases are active on EX01-2016 and two mailbox databases on EX02-2016. We can activate the mailbox databases one by one on the preferred Exchange Server. To speed things up, it’s excellent to use the PowerShell script.

Get mailbox database activation preference

You can get the mailbox database activation preference in Exchange Admin Center and with PowerShell. Let’s have a look at both.

Exchange Admin Center

In Exchange Admin Center, go to servers > databases. Verify on which Exchange Server the mailbox databases are active.

Balance mailbox databases in Exchange DAG before

Exchange Management Shell

Get the information with Exchange Management Shell. Use the Get-MailboxDatabase cmdlet and activation preference parameter -ActviationPrereference to list the mailbox databases.

[PS] C:\>Get-MailboxDatabase | Format-Table Name, Server, ActivationPreference -AutoSize

Name Server    ActivationPreference
---- ------    --------------------
DB01 EX01-2016 {[EX01-2016, 1], [EX02-2016, 2]}
DB02 EX01-2016 {[EX02-2016, 1], [EX01-2016, 2]}
DB03 EX01-2016 {[EX01-2016, 1], [EX02-2016, 2]}
DB04 EX01-2016 {[EX02-2016, 1], [EX01-2016, 2]}

There are four mailbox databases configured. At the moment, all the mailbox databases are active on the Exchange Server EX01-2016.

How to rebalance mailbox databases

You can wait, and it will automatically move the active mailbox databases to the preferred activation preference. That’s the default DAG activation preference behavior since Exchange Server 2016 CU2. Another way is to activate the mailbox database manually.

There are three options to manually activate the active mailbox database to the preferred activation preference:

  1. Activate mailbox databases in Exchange Admin Center
  2. Activate mailbox databases with Exchange Management Shell (PowerShell)
  3. Balance mailbox databases with PowerShell script (Microsoft)

The recommended way is to use option three, the PowerShell script supplied by Microsoft.

Get Database Availability Group name

Before using the PowerShell script to rebalance the mailbox databases, you need to know the Database Availability Group (DAG) name.

Use the Get-DatabaseAvailabilityGroup cmdlet and -Status parameter to list the DAGs.

[PS] C:\>Get-DatabaseAvailabilityGroup -Status | Format-Table -AutoSize

Name       Member Servers         Operational Servers
----       --------------         -------------------
DAG01-2016 {EX02-2016, EX01-2016} {EX01-2016, EX02-2016}

The name of the DAG is DAG01-2016.

Balance Exchange mailbox database with PowerShell script

The organization’s configuration is active/active mode, and both member servers (Exchange Servers) hold active mailbox databases:

  • Exchange Server EX01-2016: Mailbox databases with even numbers
  • Exchange Server EX02-2016: Mailbox databases with uneven numbers

Run Exchange Management Shell as administrator. Run cd $exscripts to change the path to the Exchange Server scripts folder.

[PS] C:\>cd $exscripts

[PS] C:\Program Files\Microsoft\Exchange Server\V15\scripts>

Return your active database copies to their most preferred DAG member. Use the PowerShell script RedistributeActiveDatabases.ps1 supplied by Microsoft. Add the DAG name and -BalanceDbsByActivationPreference switch.

The script will run and check every mailbox database and ask you to confirm. Press A to confirm and proceed further.

[PS] C:\Program Files\Microsoft\Exchange Server\V15\scripts>.\RedistributeActiveDatabases.ps1 -DagName "DAG01-2016" -BalanceDbsByActivationPreference

***************************************
Balance DAG DBs
Sunday, January 3, 2021 8:52:03 PM
***************************************
Dag                                :   DAG01-2016
ServerCount                        :   2
DatabaseCount                      :   4
CopiesCount                        :   8

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

ServerName TotalDbs ActiveDbs PassiveDbs PreferenceCountList MountedDbs DismountedDbs DagName
---------- -------- --------- ---------- ------------------- ---------- ------------- -------
EX01-2016         4         4          0 {2, 2}                       4             0 DAG01-2016
EX02-2016         4         0          4 {2, 2}                       0             0 DAG01-2016


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

Considering move of 'DB02' from 'EX01-2016' (AP = 2) to 'EX02-2016' (AP = 1)...

Confirm
Are you sure you want to perform this action?
Moving mailbox database "DB02" from server "EX01-2016.exoip.local" to server "EX02-2016.exoip.local".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): A
WARNING: [19:52:08.589 UTC] The property 'Mounted' cannot be found on this object. Verify that the property exists.

You can get a warning after you use the above command:

WARNING: The property ‘Mounted’ cannot be found on this object. Verify that the property exists.

The warning will show if the mailbox database moved three times in the last hour.

The solution is to run the command as the previous step, but this time add the -SkipMoveSuppressionChecks switch. It will go through all the mailbox databases and ask to confirm if you want to move. Click A to confirm.

[PS] C:\Program Files\Microsoft\Exchange Server\V15\scripts>.\RedistributeActiveDatabases.ps1 -DagName "DAG01-2016" -BalanceDbsByActivationPreference -SkipMoveSuppressionChecks

***************************************
Balance DAG DBs
Sunday, January 3, 2021 8:52:45 PM
***************************************
Dag                                :   DAG01-2016
ServerCount                        :   2
DatabaseCount                      :   4
CopiesCount                        :   8

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

ServerName TotalDbs ActiveDbs PassiveDbs PreferenceCountList MountedDbs DismountedDbs DagName
---------- -------- --------- ---------- ------------------- ---------- ------------- -------
EX01-2016         4         4          0 {2, 2}                       4             0 DAG01-2016
EX02-2016         4         0          4 {2, 2}                       0             0 DAG01-2016


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

Considering move of 'DB02' from 'EX01-2016' (AP = 2) to 'EX02-2016' (AP = 1)...

Confirm
Are you sure you want to perform this action?
Moving mailbox database "DB02" from server "EX01-2016.exoip.local" to server "EX02-2016.exoip.local".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): A
Database 'DB02' successfully moved from 'EX01-2016' to 'EX02-2016'.

ServerName ActiveDbs PassiveDbs
---------- --------- ----------
EX01-2016          3          1
EX02-2016          1          3 `n
Considering move of 'DB04' from 'EX01-2016' (AP = 2) to 'EX02-2016' (AP = 1)...

Confirm
Are you sure you want to perform this action?
Moving mailbox database "DB04" from server "EX01-2016.exoip.local" to server "EX02-2016.exoip.local".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): A
Database 'DB04' successfully moved from 'EX01-2016' to 'EX02-2016'.

ServerName ActiveDbs PassiveDbs
---------- --------- ----------
EX01-2016          2          2
EX02-2016          2          2 `n

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

Start time              : Sunday, January 3, 2021 8:52:43 PM
End time                : Sunday, January 3, 2021 8:52:51 PM
Duration                : 00:00:07.4324253



DbName                    : DB01
ActiveOnPreferenceAtStart : 1
ActiveServerAtStart       : EX01-2016
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : EX01-2016
IsOnMostPreferredCopy     : True
MoveStatus                : NoMoveAttempted

DbName                    : DB02
ActiveOnPreferenceAtStart : 2
ActiveServerAtStart       : EX01-2016
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : EX02-2016
IsOnMostPreferredCopy     : True
MoveStatus                : MoveSucceeded

DbName                    : DB03
ActiveOnPreferenceAtStart : 1
ActiveServerAtStart       : EX01-2016
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : EX01-2016
IsOnMostPreferredCopy     : True
MoveStatus                : NoMoveAttempted

DbName                    : DB04
ActiveOnPreferenceAtStart : 2
ActiveServerAtStart       : EX01-2016
ActiveOnPreferenceAtEnd   : 1
ActiveServerAtEnd         : EX02-2016
IsOnMostPreferredCopy     : True
MoveStatus                : MoveSucceeded

The PowerShell script did move two mailbox databases (DB02 and DB04) successfully. The script did not attempt to move the other two mailbox databases (DB01 and DB03) because they are already on the preferred activation preference.

Verify the mailbox database activation preference

Run the Get-MailboxDatabase cmdlet, just like the first step, to check which Exchange Server the active mailbox database is located.

The mailbox databases:

  • DB01 and DB03 are active on Exchange Server EX01-2016
  • DB02 and DB04 are active on Exchange Server EX02-2016
[PS] C:\>Get-MailboxDatabase | Format-Table Name, Server, ActivationPreference -AutoSize

Name Server    ActivationPreference
---- ------    --------------------
DB01 EX01-2016 {[EX01-2016, 1], [EX02-2016, 2]}
DB02 EX02-2016 {[EX02-2016, 1], [EX01-2016, 2]}
DB03 EX01-2016 {[EX01-2016, 1], [EX02-2016, 2]}
DB04 EX02-2016 {[EX02-2016, 1], [EX01-2016, 2]}

You can always verify the mailbox databases in Exchange Admin Center by checking the activate on server column.

Balance mailbox databases in Exchange DAG after

All the mailboxes databases are active on the preferred activation preference. The RedistributeActiveDatabases.ps1 PowerShell script worked great!

Keep reading: Activate database copy failed content index disabled »

Conclusion

In this article, you learned how to balance mailbox databases in Exchange DAG. Use the PowerShell script by Microsoft to rebalance mailbox databases on the Exchange Servers. Check the activation preference in Exchange Management Shell after completion.

Did you enjoy this article? You may also like Change DAG database activation preference. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 2 Comments

  1. Hi Ali, our company has a 2 node DAG cluster. They are holding all 4 databases active on 1 node. Why is it best practice to balance the active databases over all the DAG members? Is it just performance or more?

    1. Hi Can,

      It’s more than only performance.

      1. Ensures that each DAG member’s full stack of services (client connectivity, replication pipeline, transport, etc.) is being validated during normal operations.

      2. Distributes the load across as many servers as possible during a failure scenario, thereby only incrementally increasing resource use across the remaining members within the DAG.

Leave a Reply

Your email address will not be published. Required fields are marked *