2.12. Migrating Virtual Machines and Containers

To facilitate hardware upgrades and load balancing between multiple hosts, OpenVZ enables you to migrate virtual machines and containers between physical servers with the prlctl migrate command.

Before migration, make sure that the destination server:

  • has enough hard disk space to store the resulting virtual machine or container,
  • has enough memory and CPU power to run the resulting virtual machine or container,
  • has a stable network connection with the source server.

You can migrate VMs and containers both to and from a remote server. For example, to move a VM to a remote server, run this command on the local server:

# prlctl migrate MyVM root:passwd@remoteserver.com

To move a VM from a remote server, run this command the local server:

# prlctl migrate destserver.com/MyVM localhost

If you do not provide the destination server credentials in the command, you will be asked to do so during migration.

Once migration is complete, the original virtual machine is removed from the source server. However, you can keep the original VM with the --keep-src option.

Migration implies transferring large amounts of data between servers which can take considerable time. To reduce the amount of data to be transferred, OpenVZ has compression enabled by default. Compression consumes additional server resources and can be disabled if necessary with the --no-compression option.