Search code examples
sql-serverazureload-balancingdatabase-mirroring

Database mirroring between Windows Azure VMs


I have two windows server 2012 data-center R2 VMs with SQL Server standard 2012 running. I installed my both application and the db server on each of VMs. Both VMs reside within the same cloud service.

Also I setup load balancing between two VMs through port:80. Now it's a matter of mirroring the databases. I tried to setup SQL Mirroring but no luck so far. I'm not sure how these two VMs communicate with each other via the same port 5022.

Also I've done some reading but still I'm not sure what is the possible way of doing this. I definitely need a help now.

Questions: a) Do I need to set up a virtual network in order to mirror databases? b) Can I mirror databases resides within the same virtual network? c) If my assumptions above are incorrect, what is the best way forward on this?

Thanks in advance!!

UPDATE: I managed to setup Principle server in VM1 and both Mirror & Witness servers in VM2 (If you have resources best way to have them in separated VMs). Both VMs reside within same Virtual Network and same cloud service.

So when the Principle is not available, Witness automatically set the Mirror to Principle and it's no longer in the recovery state.

If you're planning to have both Witness & Mirror SQL instances within the same server, Make sure you use a different Port for Witness server. eg.

- Principle : 5022
- Mirror    : 5022
- Witness   : 5023

Solution

  • They can be in same Cloud Service and placing them into the same CS will make life simpler, because of no need to deal with public endpoints. In fact Cloud Service is just a container for VMs and/or Roles that's also associated with an implicitly created network (thus you need an endpoint to access it from outside).

    It is also recommended to put VMs into the same Availability Set, in this case Azure will try to do not shutdown all the VMs at the same time.

    The simplest way to setup DBM is to use certificates. You can see example here.

    Note: don't forget to setup witness if you need an automatic failover.