Solved

Scheduling replication Hyper-v

Posted on 2014-01-15
8
627 Views
Last Modified: 2016-10-25
HI All,

I have two hyperv servers with the following VMs:

SERVER: Hyperv1
VM: Alice
VM: FreePBX2

SERVER: Hyperv3
VM: TeaCup

I have replication enabled for the Hyperv1 server VMs (Alice and FreePBX2) to replicate to Hyperv3 and for TeaCup to replicate to Hyperv1.

However they are in separate offices connected by a 2mb pipe.  If replication happens all the time, which is the default setting, then there is too much bandwidth used and everything else between the offices is too slow.  

I don;t need a sync every 5 minutes and would like to schedule the replication to happen between 8pm and 7am every night and 24 hours a day on Sundays.

I looked around and found the following link to do this in powershell, but i have never used powershell and so I am really concerned about messing something up.  Is there a better way to do this?  Or otherwise a step by step on powershell?  Maybe a scheduled task that can be created?

Appreciate your help.
0
Comment
Question by:colin911
  • 3
  • 3
8 Comments
 
LVL 36

Expert Comment

by:Mahesh
ID: 39783114
Hyper-V Replica sends the log files or write changes for a virtual machine (VM) to the replica Hyper-V server for merging to the target virtual hard disk (VHD) every five minutes, and this interval can't be changed. If you want to have more granular control of the bandwidth used by Hyper-V Replica, you have two options.
•Change the port used for the Hyper-V Replica from the default 80 or 443 (which can be done in the GUI or via Windows PowerShell), then use Quality of Service (QoS) to limit bandwidth at different times of the day for that port. This effectively throttles the transmission of the write logs. If insufficient bandwidth was allocated, then the logs would build up until the QoS policy allocated more bandwidth, such as at night, when the logs could be transmitted and catch up.
Check below link for PowerShell command
http://blogs.technet.com/b/tommypatterson/archive/2012/10/10/replication-with-hyper-v-replica-part-ii-restricted-bandwidth-replication-step-by-step.aspx
Also in Replica properties you can vary VSS copy replication interval.

OR

•Use a script to pause replication at certain times, then resume when desired.

Both options need care, because if too much change occurs, the transaction log queue could be very large, taking a long time to send. If if the log size is more than 50 percent of the total VHD sizes, then a full resync operation will be performed. This takes additional IO and time as a block-by-block comparison is performed.

My suggestion is, its not good idea to replicate hyper-v replica over 2 Mbps link
Hyper-V replica if I understand correctly, it should be used in DR scenarios where bandwidth is never a constraint.
You should setup one more Hyper-V server at each location and setup replica locally
OR you can just implement complete VM Backup solution hopefully.

Mahesh
0
 

Author Comment

by:colin911
ID: 39786304
thank you Mahesh.  I'd be interested in the script option.  The replication size will not be big because the replication will not occur on the storage HD's.  Those are backed up separately.  so the only change will be in the OS config, and there are very rarely any changes on these.  But since they hold AD, I want to have a spare copy i can turn on.  Not even really a problem if it is dated a few days normally...

however i have no idea how to perform the script option.  I'm more familiar with GUI interfaces rather than scripting...

Would it be a script that I would use for a scheduled task?
0
 
LVL 36

Expert Comment

by:Mahesh
ID: 39786371
you can enable a scheduled job that suspends and resumes a VM replication. The following Cmdlets can be used:

Suspend-VMReplication
Resume-VMReplication

Just check below blog posts for actual commands, it might help
http://vniklas.djungeln.se/2012/11/30/schedule-hyper-v-vm-replication-for-non-office-hours-with-powershell/
http://vniklas.djungeln.se/2012/06/17/using-powershell-v3-scheduling-for-off-hours-hyper-v-vm-maintenanceconfiguring/

Mahesh
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:colin911
ID: 39786449
Yes, this was the link i already saw (sorry did not paste in into my original post).  I don;t have any familiarity with Powershell so was hoping to not have to go this way.  I started entering some of these values but quickly encountered errors and was a bit concerned, which is why I was looking for a way to do it without having to use powershell.

Granted I can use copy and paste and if there is no other way then I will try again i guess, but I really won't know if I have made a mistake or not and if so don't know how to use powershell to fix the mistake.

Is there a batch file I can create and have the scheduled task run that batch at a certain time to enable or stop the replication?  might not be the best method but I would be more comfortable with that...
0
 
LVL 36

Accepted Solution

by:
Mahesh earned 500 total points
ID: 39786633
In the 1st article PowerShell commands are very straight forward and self explanatory

It works with VMName, so you can create test VM, build its replica and start playing around it to get comfort
OR
Test below
Start by creating two batch files on your Hyper-v RECEIVING host.
c:\SuspendReplication.cmd  which contains the command:  powershell suspend-vmreplication *
 c:\ResumeReplication.cmd which contains the command:  powershell resume-vmreplication *

Now, you can create sc tasks through GUI or in the dos window, enter the following commands to schedule the tasks:

schtasks /create /tn “SuspendReplication” /tr c:\SuspendReplication.cmd /sc daily /st 08:00
schtasks /create /tn “ResumeReplication” /tr c:\ResumeReplication.cmd /sc daily /st 17:00

The first suspends replication at 8am and the second resumes at 5pm.
Choose whatever times you prefer to suit your needs.

Additional links
http://technet.microsoft.com/en-us/library/hh848510.aspx
http://blogs.technet.com/b/virtualization/archive/2013/05/10/resynchronization-of-virtual-machines-in-hyper-v-replica.aspx

Hope that helps

Mahesh
0
 

Author Comment

by:colin911
ID: 39788785
Thank you!  That helps a lot.
0
 

Expert Comment

by:steven freitas
ID: 41858299
@Mahesh

Hi I'm pretty new to coding and PowerShell and CMD commands and all that stuff. Could you please clarify what you mean in this line:

"sc tasks through GUI or in the dos window"

SC??
What GUI?
DOS??

Many thanks :)
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
OfficeMate Freezes on login or does not load after login credentials are input.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question