Move containers between two VMmanager OVZ

From ISPWiki
Jump to: navigation, search

Preliminary steps

To move a container you need to have two servers running VMmanager OVZ. Put the public key of the source server on the target server. Execute the following command on the source server:

ssh-keygen -t rsa

This command generates the public key that you need to put on the target server:

ssh-copy-id -i /root/.ssh/ root@server_ip_address

You will be asked for the password.

Once you are done, proceed to the transfer.

Moving container

Complete the same steps as for migrating containers from VDSmanager.

First you need to create a record in the VMmanager OVZ database, however we cannot do it manually, because the id field is the primary key of the table in the base that is generated automatically. For this reason we cannot use the vzmigrate utility provided by OpenVZ. Execute the command vm.create to create a record in the database without creating the container. Your request will look something like this:


Use the values you need:

  • chratein и chrateout - limit on incoming and outgoing traffic correspondingly
  • cpu - number of CPU
  • cpufreq - CPU frequency
  • domain - container's domain name
  • hdd - hard drive диск
  • hostnode - id of the node where this container will locate
  • ip - container's IP address
  • layout - container's file system
  • mem - RAM
  • numfile - limit on file descriptors
  • numproc - limit on processes
  • ostemplate - operating system template
  • password - password
  • swapratio - Swap/Ram ratio
  • user_id - id of the user who will own this container.

Execute the command to create a "false" container that in fact does not exist on the hard drive.

Now start moving the container.

IMPORTANT NOTES! Suspend the container before starting migration otherwise some changes may be made to the container that will not copy during migration, and the container will not start.

Next, you need to move the configuration file of the container. Normally, the configuration files are located in /etc/vz/conf. On the source server execute the command:

rsync -avz /etc/vz/conf/id.conf root@ip_address_of_the_target_node:/etc/vz/conf/id.conf

Change id.conf on the source server into the container's id (you can locate it in the interface), for example 101.conf. On the target server specify the id of the container created using vm.create

Finally, move the container:

rsync -avz /vz/private/id root@ip_address_of_the_target_node:/vz/privae/id

Change of the container's IP address assigned to the network interface.