Migration from one HN to another

From OpenVZ Virtuozzo Containers Wiki
Revision as of 14:39, 30 September 2011 by 169.244.134.66 (talk) (ubFNTu <a href="http://nnovyhepiyti.com/">nnovyhepiyti</a>, [url=http://ewllifjkymnm.com/]ewllifjkymnm[/url], [link=http://tddxmdgdgatc.com/]tddxmdgdgatc[/link], http://daqacaffprvh.com/)
Jump to: navigation, search
Yellowpin.svg Note: this article is not formatted according to this Wiki standards. Please help reformatting it in a better way.

The vzmigrate script is used to migrate a container from one Hardware Node to another.

ubFNTu <a href="http://nnovyhepiyti.com/">nnovyhepiyti</a>, [url=http://ewllifjkymnm.com/]ewllifjkymnm[/url], [link=http://tddxmdgdgatc.com/]tddxmdgdgatc[/link], http://daqacaffprvh.com/

Prerequisites

Make sure:

  • you have at least one good backup of the virtual machine you intend to migrate
  • rsync is installed on the target host
  • In general you cannot migrate from bigger kernel versions to smaller ones
  • By default, after the migration process is completed, the Container private area and configuration file are deleted on the old HN. However, if you wish the Container private area on the Source Node to not be removed after the successful Container migration, you can override the default vzmigrate behavior by using the –r no switch.

vzmigrate usage

Now that the vzmigrate script will function, a little bit on vzmigrate.

This program is used for container migration to another node
Usage:
vzmigrate [-r yes|no] [--ssh=<options>] [--keep-dst] [--online] [-v]
        destination_address <CTID>
Options:
-r, --remove-area yes|no
        Whether to remove container on source HN for successfully migrated container.
--ssh=<ssh options>
        Additional options that will be passed to ssh while establishing
        connection to destination HN. Please be careful with options
        passed, DO NOT pass destination hostname.
--keep-dst
        Do not clean synced destination container private area in case of some
        error. It makes sense to use this option on big container migration to
        avoid syncing container private area again in case some error
        (on container stop for example) occurs during first migration attempt.
--online
        Perform online (zero-downtime) migration: during the migration the
        container hangs for a while and after the migration it continues working
        as though nothing has happened.
-v
        Verbose mode. Causes vzmigrate to print debugging messages about
        its progress (including some time statistics).

Example

Here is an example of migrating container 101 from the current HN to one at 10.1.5.6:

[root@OpenVZ .ssh]# vzmigrate 10.1.5.6 101
OPT:10.1.5.6
Starting migration of container 101 on 10.1.5.6
Preparing remote node
Initializing remote quota
Syncing private
Syncing 2nd level quota
Turning quota off
Cleanup

Migrate all running containers

Here's a simple shell script that will migrate each container one after another. Just pass the destination host node as the single argument to the script. Feel free to add the -v flag to the vzmigrate flags if you'd like to see it execute with the verbose option:

for CT in $(vzlist -H -o veid); do vzmigrate --remove-area no --keep-dst $1 $CT; done


Additional Information

You can also use this guide to migrate from OpenVZ to Proxmox VE.

If you use Proxmox VE, you may also want to read how to Backup-Restore a virtual machine, be it OpenVZ or KVM.