Creating a Database Availability Group using Exchange Management Shell

by Mike Pfeiffer on February 6, 2010

Database Availability Groups (DAGs) are the foundation of high availability and site resilience in Exchange Server 2010. Using DAGs, we can create a group of up to 16 mailbox servers that contain a set of database copies providing redundancy for mailbox databases. If a mailbox server in a DAG fails, its active database copies can be mounted on another server in the DAG.

DAGs can be designed in several ways. You can deploy a simple configuration, with just two DAG members in a single site. You can also do more advanced configurations, using multiple servers using separate physical sites.

In this post, I am going to create a simple two node DAG using mailbox servers located in a single site. The entire process will be done in Exchange Management Shell from start to finish – keep in mind you can also use EMC to create and manage DAGs, but using Exchange Management Shell gives us a little more control.

Considerations

Here are a few requirements and recommendations about DAGs that need to be taken into consideration before we get started:

  • DAGs can run on Exchange 2010 Standard or Enterprise – your DAG members can be a mix of these Exchange versions.
  • DAGs must run on an Enterprise OS – Since DAGs utilize Windows Failover Clustering, you need to use Either 2008 Enterprise or 2008 R2 Enterprise. All members of a DAG MUST run the same OS, don't try to mix 2008 and 2008 R2.
  • Use at least two NICs in each DAG member – This is not a requirement, but a best practice. Use, one for the MAPI network and one or more for Replication. Using at least two networks enables the DAG members to distinguish between a server outage and a network outage.
  • DAG networks must match – Make sure the network configuration is identical from one DAG member to the next. For example, if you are using three NICs on your first DAG member then you need the same amount on the remaining servers defined with the same networks.
  • DAG NICs should be on seperate networks – Each NIC should be in its own network subnet \ VLAN.
  • Use Gigabit Ethernet NICs – This almost goes without saying, but obviously is for the sake of performance.
  • High Latency is bad – DAG members do not support round trip network latency greater than 250 milliseconds (ms).
  • File Share Witness (FSW) can be hosted by any server in the domain – Just make sure that if your FSW is not an Exchange Server that the Exchange Trusted Subsystem group is in the local administrators group
  • Each DAG needs an IP address – This can be statically assigned, if it is not, it will attempt to obtain an address via DHCP.

The Lab Setup

For this example, I am going to use a total of 4 servers within a single Active Directory site. One Active Directory Domain Controller, an Hub\CAS server and two mailbox servers. The relevant settings for the mailbox servers are as follows:

Server Names: MB1, MB2
MAPI Network: 172.16.23.0/24
Replication Network: 10.1.1.0/24

Create the DAG

The first thing we need to do is create the DAG. To do this, we use the New-DatabaseAvailabilityGroup cmdlet, specifying the name of the DAG, the name of the witness server, the local path to the witness directory on the witness server and the DAG IP address:

New-DatabaseAvailabilityGroup -Name DAG -WitnessServer HC1 -WitnessDirectory C:\FSW -DatabaseAvailabilityGroupIPAddresses 172.16.23.100

As you can see from the command, my witness server is named HC1 – this is the Hub\CAS server. I did not manually pre-create the C:\FSW directory, this will happen automatically in the next step when we add the mailbox servers to the DAG.

Adding Mailbox Servers to the DAG

Now that the DAG has been created, we can add the mailbox servers to the DAG. We use the Add-DatabaseAvailabilityGroupServer cmdlet to add servers MB1 and MB2 to the DAG:

Add-DatabaseAvailabilityGroupServer -Identity DAG -MailboxServer MB1

Now that MB1 has been added, we add MB2 to the DAG:

Add-DatabaseAvailabilityGroupServer -Identity DAG -MailboxServer MB2

Managing DAG Network Replication

The DAG networks we have configured on the DAG members are automatically added to the DAG when running the Add-DatabaseAvailabilityGroupServer as DAGNetwork01 and DAGNetwork02. We can confirm this by running the Get-DatabaseAvailabilityGroupNetwork cmdlet:

As you can see in the screenshot above, our MAPI network (172.16.23.0/24) has been assigned to DAGNetwork02, whereas the Replication network (10.1.1.0/24) has been assigned to DAGNetwork01 and both networks have replication enabled by default.

It's a good idea to have DAG replication enabled on multiple networks. Keep in mind, you could actually add a third replication network to this configuration for increased redundancy. If you need to disable DAG replication on a network, you can use Set-DatabaseAvailabilityGroupNetwork with the ReplicationEnabled parameter set to $false.

Adding Mailbox Database Copies

The final step is to add a mailbox database copy to the DAG. We currently have a database named DAGDB1 mounted on MB1. We'll use the Add-MailboxDatabaseCopy cmdlet to add a database copy to server MB2.

Add-MailboxDatabaseCopy -Identity DAGDB1 -MailboxServer MB2 -ActivationPreference 2

That's it, we now have a working DAG with a database copy. I will be posting a lot more about database availability groups in upcoming posts, that's all for now.

Related Posts

{ 8 comments… read them below or add one }

Robert August 9, 2010 at 7:56 am

After your setup how can you test the failover? When I bring one down, it brings down the other mailbox database down? Should DAGNetwork01 and DAGNetwork02 both show each IP Addresses in the Network Interfaces? I would apppreciate your opinion or insight.

Reply

Mike Pfeiffer August 9, 2010 at 8:42 am

Hi Robert,

You can do a switchover by activating a passive copy of a database using the Move-ActiveMailboxDatabase cmdlet, or by right clicking on a passive database in EMC and selecting ‘Activate Database Copy’. To simulate a failover, I usually stop the cluster service or pull the network cables from the server hosting the active databases.

As far as the networks go, each one will show the subnet, along with the IP addresses that are used by each DAG member in that network.

Reply

Robert August 9, 2010 at 9:22 am

Yes, thank you. When i do the pull the Network cable out for testing purposes, it takes down “unmounts both EX1 and EX2 mailbox database because they are in the DAG”? Nothing more happens?
I show DAGNetwork01 with a subnet and Network interface that is correct for both servers IPs
I show DAGnetwork02 with a subnet and Network interface as only “one” IP 192.168.1.41. This is the second NIC card configured for EX1. EX2 has a second NIC but it does not show up is connected.
Any suggestion for me?

Reply

Mike Pfeiffer August 9, 2010 at 9:32 am

Could you post the output for the following commands?

Get-DatabaseAvailabilityGroup | fl
Get-DatabaseAvailabilityGroupNetwork | fl

You can email me the info via the contact form if you prefer.

Reply

Robert August 9, 2010 at 10:02 am

[PS] C:\Windows\system32>Get-DatabaseAvailabilityGroup | fl

RunspaceId : 68898d85-35d4-410b-80cb-dadaff3a3ddf
Name : DAG1
Servers : {EX3, EX1}
WitnessServer : ADS2.RCBOS.LOCAL
WitnessDirectory : C:\FSWDAG1
AlternateWitnessServer :
AlternateWitnessDirectory :
NetworkCompression : InterSubnetOnly
NetworkEncryption : InterSubnetOnly
DatacenterActivationMode : Off
StoppedMailboxServers : {}
StartedMailboxServers : {}
DatabaseAvailabilityGroupIpv4Addresses : {10.22.28.40}
OperationalServers :
PrimaryActiveManager :
ThirdPartyReplication : Disabled
ReplicationPort : 0
NetworkNames : {}
AdminDisplayName :
ExchangeVersion : 0.10 (14.0.100.0)
DistinguishedName : CN=DAG1,CN=Database Availability Groups,CN=Exchange Administrative Group
BOHF23SPDLT),CN=Administrative Groups,CN=BOS Exchange,CN=Microsoft Excha
=Services,CN=Configuration,DC=rcbos,DC=local
Identity : DAG1
Guid : 71c7011c-0f3a-4ca1-81bc-5855ae89e714
ObjectCategory : rcbos.local/Configuration/Schema/ms-Exch-MDB-Availability-Group
ObjectClass : {top, msExchMDBAvailabilityGroup}
WhenChanged : 5/27/2010 8:47:25 PM
WhenCreated : 5/27/2010 8:47:25 PM
WhenChangedUTC : 5/28/2010 3:47:25 AM
WhenCreatedUTC : 5/28/2010 3:47:25 AM
OrganizationId :
OriginatingServer : bosads.rcbos.local
IsValid : True

[PS] C:\Windows\system32>Get-DatabaseAvailabilityGroupNetwork | fl

RunspaceId : 68898d85-35d4-410b-80cb-dadaff3a3ddf
Name : DAGNetwork01
Description :
Subnets : {{10.22.28.0/24,Up}}
Interfaces : {{EX1,Up,10.22.28.41}, {EX3,Up,10.22.28.42}}
MapiAccessEnabled : True
ReplicationEnabled : True
IgnoreNetwork : False
Identity : DAG1\DAGNetwork01
IsValid : True

RunspaceId : 68898d85-35d4-410b-80cb-dadaff3a3ddf
Name : DAGNetwork02
Description :
Subnets : {{192.168.1.0/24,Up}}
Interfaces : {{EX1,Up,192.168.1.41}}
MapiAccessEnabled : False
ReplicationEnabled : True
IgnoreNetwork : False
Identity : DAG1\DAGNetwork02
IsValid : True

Robert August 9, 2010 at 11:09 am

I got the other NIC to work! Problem still, wehn EX1 goes down everything goes down.
[PS] C:\Windows\system32>Get-DatabaseAvailabilityGroup | fl
Creating a new session for implicit remoting of “Get-DatabaseAvailabilityGroup” command…

RunspaceId : 3cdafe48-9fe1-4440-b7a9-feeb45ab995e
Name : DAG1
Servers : {EX3, EX1}
WitnessServer : ADS2.RCBOS.LOCAL
WitnessDirectory : C:\FSWDAG1
AlternateWitnessServer :
AlternateWitnessDirectory :
NetworkCompression : InterSubnetOnly
NetworkEncryption : InterSubnetOnly
DatacenterActivationMode : Off
StoppedMailboxServers : {}
StartedMailboxServers : {}
DatabaseAvailabilityGroupIpv4Addresses : {10.22.28.40}
OperationalServers :
PrimaryActiveManager :
ThirdPartyReplication : Disabled
ReplicationPort : 0
NetworkNames : {}
AdminDisplayName :
ExchangeVersion : 0.10 (14.0.100.0)
DistinguishedName : CN=DAG1,CN=Database Availability Groups,CN=Exchange Administrative Group (FYDI
BOHF23SPDLT),CN=Administrative Groups,CN=BOS Exchange,CN=Microsoft Exchange,CN
=Services,CN=Configuration,DC=rcbos,DC=local
Identity : DAG1
Guid : 71c7011c-0f3a-4ca1-81bc-5855ae89e714
ObjectCategory : rcbos.local/Configuration/Schema/ms-Exch-MDB-Availability-Group
ObjectClass : {top, msExchMDBAvailabilityGroup}
WhenChanged : 5/27/2010 8:47:25 PM
WhenCreated : 5/27/2010 8:47:25 PM
WhenChangedUTC : 5/28/2010 3:47:25 AM
WhenCreatedUTC : 5/28/2010 3:47:25 AM
OrganizationId :
OriginatingServer : bosads.rcbos.local
IsValid : True

[PS] C:\Windows\system32>Get-DatabaseAvailabilityGroupNetwork | fl

RunspaceId : 3cdafe48-9fe1-4440-b7a9-feeb45ab995e
Name : DAGNetwork01
Description :
Subnets : {{10.22.28.0/24,Up}}
Interfaces : {{EX1,Up,10.22.28.41}, {EX3,Up,10.22.28.42}}
MapiAccessEnabled : True
ReplicationEnabled : True
IgnoreNetwork : False
Identity : DAG1\DAGNetwork01
IsValid : True

RunspaceId : 3cdafe48-9fe1-4440-b7a9-feeb45ab995e
Name : DAGNetwork02
Description :
Subnets : {{192.168.1.0/24,Up}}
Interfaces : {{EX1,Up,192.168.1.41}, {EX3,Up,192.168.1.42}}
MapiAccessEnabled : True
ReplicationEnabled : True
IgnoreNetwork : False
Identity : DAG1\DAGNetwork02
IsValid : True

Robert August 9, 2010 at 2:21 pm

Hello Mike, maybe I have been looking at this wrong.. New progress for me, maybe you can give me some advice. After troubleshooting more i found that it actually failsover nicely from EX3 to EX1 and correctly, but when I switchover the database to the EX3 server and run the failover from EX1 to EX3 it dismounts both EX1 and EX3?

Reply

Mike Pfeiffer August 10, 2010 at 7:00 am

Could be a number of things…Have you looked at the event log? What process are you using to simulate the failover?

Reply

Leave a Comment

Previous post:

Next post: