There are two variants:
- import from a server with VMmanager OVZ;
- import from a server with a third-party control panel.
Importing virtual machines from a server with VMmanager OVZ
-
To import a container you need to have two servers with 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 ssh-copy-id -i /root/.ssh/id_rsa.pub root@<server IP address>
View details -
In VMmanager database create a record about the container. Access the target server with root-permissions and execute the API-request:
https:/ip:1500/vemgr?admdown=off&chratein=1000&chrateout=1000&comments=&cpu=1&cpufreq=1000&domain=domain.com&func=vm.create&hdd=4000&hostnode=1&ip=xxx.xx.xx.x&layout=ploop&mem=512&name=example&numfile=16536&numproc=5000&ostemplate=template&password=*&swapratio=0&user_id=yy&vmnote
View details - After you have started the request, you will see the confirmation window in the browser. Add &out=xml at the end of the request and click OK. Thus, you will create a "false" container that in fact does not exist on the hard drive.
- Suspend the container on the source server.
-
Import the configuration file of the container. By default, 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 cluster node>:/etc/vz/conf/<id.conf>
View details -
To import the container, execute the command on the source server:
rsync -avz /var/lib/vz/private/<id-old>/ root@<IP-address of the cluster node>:/var/lib/vz/private/<id>
View details - Change the IP address on the container network interface.
Importing containers from a server with a third-party control panel
There are 2 variants to import containers from servers with other control panels:
- install VMmanager OVZ locally on the source server;
- install VMmanager OVZ on a separate server and add the source server a cluster node.
Complete the following steps before you start:
- Install VMmanager OVZ on the local or a separate server
- Disable or uninstall the control panel;
- Create the following objects in VMmanager OVZ:
- Cluster nodes. Connect all the servers from which you want to import virtual machines.
- A user who will be the owner of the virtual machines; otherwise a new user will be created for each container.
- Networks. In the IP addresses management module or in IPmanager create networks corresponding to the IP addresses of your container; network type is "public".
Execute the command to start importing the local containers. Container identifiers (CTID) will be changed:
/usr/local/mgr5/sbin/mgrctl -m vemgr import.local user=user_id elid=CTID hostnode=id|all
The command output must be empty. Make sure there are no errors in the import log. The command output must be empty:
grep "WARNING Skip" /usr/local/mgr5/var/vemgr.log