Home » Exchange Server » Managing Database Copies for an Exchange Server 2016 Database Availability Group

Managing Database Copies for an Exchange Server 2016 Database Availability Group

When you first deploy an Exchange Server 2016 database availability group, or any time later when you add a new member to the DAG, there will be some steps required to manage the database copies within the DAG.

As an example, I’ve created a new Exchange 2016 DAG with two members. Before they were added to the DAG the server EX2016SRV1 hosted one database named DB05, and EX2016SRV2 hosted one database named DB06. I’ve then created an additional two databases on EX2016SRV1 named DB07 and DB08. At present the databases have a single copy within the DAG, which looks like this.

exchange-2016-dag-db-copies-01

To view this in PowerShell we can run the Get-MailboxDatabaseCopyStatus cmdlet.

If you have other databases in your organization they will also appear in the output above. I have removed mine for the sake of clarity.

In this article I will demonstrate how to:

  • Add database copies to a DAG member
  • Remove database copies from a DAG member
  • Balance active database copies across a DAG

Adding Database Copies to an Exchange Server 2016 DAG Member

The objective in this scenario is to add database copies so that each database has two copies for high availability, one on each DAG member. To achieve this we use the Add-MailboxDatabaseCopy cmdlet. For example, this command will add a copy of DB06 (currently hosted on EX2016SRV2) to the DAG member EX2016SRV1.

When you add a new database copy you’ll see a warning message: “Please restart the Microsoft Exchange Information Store service on server SERVERNAME after adding new mailbox databases.” An explanation of this warning can be read here.

Adding the new database copy will automatically start the seeding process (copying the database and log files to the new server) and begin the continuous replication process. The new database copy will automatically be configured with the next available activation preference for copies of that database (which I’ll explain later in the section about balancing database copies across a DAG).

The seeding time will depend on the amount of data that needs to be copied and the network bandwidth that is available. The seeding will occur from the database copy that is currently active. If you’re seeding across a slower WAN connection and there is already another passive copy in that datacenter that would be faster to seed from because it is closer, you can modify the command shown above to postpone seeding.

Then, manually start the seeding process using Update-MailboxDatabaseCopy and specify which DAG member to seed from.

You can repeat the commands above to add copies of multiple databases to a new server, however that gets a bit tedious. Instead, we can use PowerShell to add multiple database copies in a single command. For example, here is the list of database copies on EX2016SRV1.

We know that DB05, DB07, and DB08 are yet to be added to EX2016SRV2. One way to show only the databases in the DAG that are yet to be added to EX2016SRV2 is as follows.

So we can simply pipe that into Add-MailboxDatabaseCopy to add copies to EX2016SRV2.

Run Get-MailboxDatabaseCopyStatus to see the results.

Removing Database Copies from an Exchange Server 2016 DAG Member

When you are planning to decommission a DAG member you will need to remove all of the database copies from the server before it can be removed from the DAG member list. To remove database copies we use the Remove-MailboxDatabaseCopy.

For example, to remove the copy of DB05 from the DAG member EX2013SRV2 we run this command.

To remove all of the database copies from a DAG member without being prompted for confirmation use the following command.

Warning: This will remove all of the database copies from the server without prompting for confirmation first.

If you try to remove a database copy that is currently active it will fail with an error message similar to this.

The database “DB06” is currently hosted on server “EX2016SRV2”. Use Move-ActiveMailboxDatabase to move the active copy of the database to a different server. You can use the Remove-MailboxDatabase task if this is the only copy.

If you were doing this as part of a server decommission you would simply move the active database copy to another server, then re-run Remove-MailboxDatabaseCopy.

Balancing Active Database Copies for an Exchange Server 2016 DAG

The first copy of a database in a DAG is configured with an activation preference of 1. As you add new copies of that database the copies are configured with activation preference values in order. So the second copy is AP=2, the third is AP=3, and so on. Activation preference and the impact is can have on DAG operations is explained in more detail in my article Why Did My Database Failover to the Wrong Server?

Depending on how you first built your DAG you may have an unbalanced distribution of activation preferences across your database copies. For example in my DAG this is the current layout of the AP values. When all active database copies are the AP=1 copy the DAG will generally function just fine, but the storage IOPS will not be even and it’s possible that some operations such as an unplanned failover may take longer.

exchange-2016-dag-db-copies-03

We can balance our activation preferences using some PowerShell scripts, which I’ve previously written about in my article on PowerShell Scripts for Balancing Database Availability Groups. Following the guidance in that article I can run the following command to balance my AP distribution.

exchange-2016-dag-db-copies-04

With the AP values more evenly distributed, but now it means some of my active database copies are not the most preferred copy. This in itself is not a problem, but as mentioned earlier a balanced DAG has benefits.

exchange-2016-dag-db-copies-05

I can rebalance the active database copies with this command.

Summary

In this tutorial I’ve demonstrated how to add and remove database copies from Exchange Server 2016 database availability group members. I’ve also demonstrated the concept of activation preference, and how to balance activation preferences across your DAG members.

Paul is a Microsoft MVP for Office Servers and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul is a co-author of Office 365 for IT Pros and several other books, and is also a Pluralsight author.
Category: Exchange Server

8 comments

  1. Gerard Toscano says:

    I am in the planning stages of upgrading to a Ex2016 standard (2) server DAG plus witness. I am confused about the licensing. Per Microsoft standard allows for 5 mounted DB’s per server whether they are active or passive. So in my case I am planning for 4 active DB’s and a passive copy for each totaling 8. Is my understanding correct or am I missing something? Should I be considering Enterprise instead?

  2. Roberto Oviedo says:

    Good morning, Paul.

    As always very good post, I have a question maybe you have already done it but I have not found clear information, I am in process of migration to Exchange 2016, I am thinking of setting up a DAG with 4 servers (2 servers in a central site and 2 servers On a DRP site), I have a question regarding database replication, it is possible in Exchange 2013 or 2016 to replicate a database from a passive copy.

    This is because I have a very limited link (8Mb) and I would like to have 1 copy on each server of the remote site and I do not want to replicate 2 times from the central site, I would like to see if it is possible to replicate from a server of the DRP site and thus reduce Network consumption on the WAN.

    SitePri Site DRP
    Server1 Server2 | Server3 Server4
    Active —————> | Pasive1 —> Pasive2
    Active–>| Pasive1 —> Pasive2

    Thanks in advance.

    Greetings.

    • You can do the initial seeding of a database copy from either an active or passive copy, but the ongoing replication is from the active copy only.

      Running DAGs over low bandwidth links is not a good idea. If you’re going to do a multi-site DAG, the network has to be good.

  3. David M says:

    Good evening Paul,

    Should we pre-create the folder structure on the second (or additional) mailbox servers? I know the paths must be identical so I made sure the drive letters were the same (databases on the E: drive and log files on the F: drive). Since I’m only testing Exchange 2016 DAGs at this point, I thought I’d just let Exchange create the folders. Exchange created the folders successfully and all the data replicated correctly. However, there was a warning about folder permissions (slightly edited):

    WARNING: There was a problem creating directory “E:\MBXDB-01” on server “EX16-4.my.domain”. In order to ensure that the Exchange data is kept secure, please create the directory, if it does not already exist, and configure directory permissions so that “SYSTEM” and the local “Administrators” group have “Full Control” for the folder, subfolders, and files. It is recomended that permission inheritance be broken so that only “SYSTEM” and “Administrators” have access to the directory.

    Once again, that did not prevent the actual creation of another copy of the database.

    I was prompted to restart the Information Store service on the second mailbox server (that may be normal).

    Test-ReplicationHealth and…
    Get-MailboxDatabase | Get-MailboxDatabaseCopyStatus
    are both OK.

    I notice that on the first server, the permissions on the (manually created) folders are not what is recommended above either (there are additional Exchange groups that have permissions) but I’ll stick with my initial question for now, rather than going all over the place with this.

    Thanks in advance!

      • David M says:

        David – Were you running the Add-databasecopy cmdlet (or GUI) from the target server? If not, can you delete the DB copy and re-run from the target server?

Leave a Reply

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