Solved

Scheduling replication Hyper-v

Posted on 2014-01-15
8
519 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 35

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 35

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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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 35

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
This is an issue that we can get adding / removing permissions in the vCSA 6.0. We can also have issues searching for users / groups in the AD (using your identify sources). This is how one of the ways to handle this issues and fix it.
In this Micro Tutorial viewers will learn how to restore their server from Bare Metal Backup image created with Windows Server Backup feature. As an example Windows 2012R2 is used.
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now