Hyper-V Replica
Hyper-V Replica is a built-in disaster recovery feature that enables you to replicate virtual machines (VMs) between two Hyper-V hosts, ensuring minimal data loss and downtime in case of a primary site failure. This guide walks through enabling and configuring Hyper-V Replica for VM disaster recovery, including prerequisites, configuration steps, and monitoring best practices.
Prerequisites for Hyper-V Replica¶
Before enabling Hyper-V Replica, ensure the following:
- Primary and secondary hosts are in the same Active Directory domain.
- Both hosts run Windows Server 2012 R2 Datacenter or Standard, or later versions with Hyper-V Replica support.
- Network connectivity exists between the primary and secondary hosts, with a dedicated replication network (low-latency, high-bandwidth).
- Storage on the secondary host must be available for storing replica VMs.
- VM settings (CPU, memory, network adapters) must match between primary and secondary hosts.
Enabling Hyper-V Replica on the Primary Server¶
- Open Hyper-V Manager and select the VM to replicate.
- Right-click the VM and choose Enable Replication.
- In the wizard, specify the Replica Server (secondary host) and configure replication settings:
- Replication Frequency: Default is every 15 minutes (adjust based on RPO requirements).
- Bandwidth Limit: Set a limit to avoid network congestion.
- Authentication: Use Kerberos or certificate-based authentication (Kerberos is default for domain-joined hosts).
Example PowerShell command to enable replication:
Enable-VmReplication -VMName "VM01" -ReplicaServer "SecondaryHost" -ReplicationFrequencyInSeconds 900 -BandwidthLimitInKbps 5120
Configuring the Secondary Server¶
- Create a Replica VM:
- On the secondary host, use the New-VmReplica cmdlet to create a replica VM.
- Ensure the VM’s hardware configuration matches the primary.
- Warning: Ensure the VM is stopped on the primary host before creating a replica.
Example PowerShell command to create a replica:
- Configure Replica Settings:
- Set Recovery Point Objective (RPO) and Recovery Time Objective (RTO) via the Hyper-V Manager or PowerShell.
- Use Test-VmReplication to validate replication health and failover readiness.
Example PowerShell command to test replication:
Monitoring and Maintenance¶
- Check replication status:
Verify the Replication Health and Last Replication Time. - Monitor logs: Use Event Viewer (Event ID 16192) or the Hyper-V Manager for replication errors.
- Regularly test failover: Use Stop-VmReplication and Start-VmReplication to simulate failover/failback scenarios.
Troubleshooting Common Issues¶
- Network latency: Ensure replication traffic uses a dedicated, low-latency network.
- Storage issues: Verify the secondary host’s storage path is accessible and has sufficient space.
- Authentication failures: Confirm Kerberos trusts or certificate validity between hosts.
- VM configuration mismatches: Ensure CPU, memory, and network settings align between primary and secondary.
Key takeaways¶
- Enable Hyper-V Replica on the primary VM first, then configure the secondary server.
- Use PowerShell for automation and validation (e.g.,
Test-VmReplication). - Regularly monitor replication health and test failover procedures.
- Prioritize network and storage reliability to meet RPO/RTO goals.
- Address authentication and configuration mismatches promptly to avoid replication failures.