Virtual machine replication is a solution to maintain one or multiple virtual machine copies among 2 or more locations. This solution has multiple advantages – ensured availability in case of primary location failures such as network, electrical or in more severe cases data encryption. Replication can be done independently of underlying storage (SAN, File share etc.) this allows to do much more granual replication to virtual machine or even VM disk level. Additional VM replications include creation of backups, data center migrations and much more.

In this blog we will check out VMware’s vSphere Replication as product is integrated and licensed under vSphere, it is also a great starting point to know more about replication.

Working Principle

Replication can be done in multiple ways – from site A to site B, in reverse, and from multiple sites to a single destination site. It is not required for sites to be dedicated, they can both send and receive replication data. To start with replication 2 sites are required along with a vCenter in each site.

In each of the sites a replication Site Recovery Manager (SRM) virtual machine is deployed. SRM is the main management point from which sites are connected, replications are configured and then monitored. SRM is deployed using an OVF. During deployment parameters such as replication network, appliance name, vCenter location are set. After deployment, initial configuration takes place where sites are connected via vCenters, after that VM replications can be configured and started.

01 - Site Recovery

Replication itself takes place at VM level. Every ESXi host has an integrated vSphere Replication agent/driver along with vSCSI filter that does the replication. VM data is replicated before it is sent down to storage.

02 - vSphere replication

The advantages of VM level replication are the ability to replicate more granularly up to VM disks compared to storage level replication where only volumes/LUNs could be replicated. This provides flexibility as VM can be replicated no matter where it resides – SAN, File share, JBOD etc.

Starting a replication

When configuring a VM replication it is possible to select the datastore on which data will be replicated (again no matter what technology or vendor is being used), set replication points and time interval when points are made. VSR supports up to 24 replication points (snapshots) with intervals between 5 minutes up to 24 hours. Due to this prior planning may be needed, as replicating once an hour, restores will be possible only from points made in the last 24 hours.

03 - Replication Settings

Replication starts with an initial replication, all VM data is being sent to the target site. In the event of network or some other error, replication will stop and will be able to start again from the point where it left.

Initial Seed

VSR also offers initial seed, an ability to transfer VM data to the target site manually. This is helpful in cases where internet link between sites is limited, and large initial dataset must be sent, this helps accelerate initial replicas and saves bandwidth. Initial seed can be used by downloading VM VMDK file and then transferring it to the target site via external storage or by any other means. At the target site VMDK file is specified for a particular VM and its integrity is then checked. It is worth mentioning that VMDK files can be only downloaded from turned off virtual machines.

VM Failover

In case of a failure or failover tests in primary site, VMs can be recovered in the secondary site. When recovering it is possible to choose whether sync last changes (if primary site is still available) or to recover using latest synced point. If multiple replication points are available notification will be shown with point count and that the points are available as snapshots.

04 - Recovery

After recovery, VM is registered in target site and is ready for use. Earlier VM recovery point can be selected from the VM Snapshot menu. Restores usually take no more than a minute.

When the primary site becomes available and all issues are resolved, VMs can be replicated back to their original location. This process is not automatic; however, the steps remain the same: choose target datastore, number of replication points (usually 0 as this replication will only be used for reverse migration) and target host (only when recovery is initated).

Datacenter migration

Finally, vSphere Replication can be used as VM migration tool between vSphere sites. Select all the necessary virtual machines, replicated over and when ready finish the migration. As VMs are replicated and already reside on target site migration downtime is minimal, as VM must be turned off in the primary site and turned on at the secondary.