Migrating a container between two OpenVZ nodes involves several steps:
1. Stop the container on the source node: – `vzctl stop [CTID]`
1. Create a backup of the container on the source node: – `vzdump [CTID] —dumpdir /root/`
1. Securely copy the backup file to the destination node: – `scp /root/vzdump-[CTID].tar root@[destination-node-ip]:/root/`
1. On the destination node, restore the backup file: – `vzrestore /root/vzdump-[CTID].tar [CTID]`
1. If the container had a fixed IP, assign the IP to the new container: – `vzctl set [CTID] —ipadd [container-ip] —save` – `vzctl set [CTID] —nameserver [nameserver-ip] —save`
1. Start the container on the destination node: – `vzctl start [CTID]`
1. Verify that the container is running correctly on the destination node: – `vzctl exec [CTID] ping [any-ip]` – `vzctl enter [CTID]`
Please note, the ‘[’ and ‘]’ brackets are placeholders for your own values.
Also, keep in mind that this is a pretty sensitive operation, so you might want to consider doing this during a maintenance window or notifying users about possible downtime.
Make sure you have the necessary resources available on the destination node before starting the migration process.
Lastly, ensure that both source and destination nodes are using the same kernel version and configuration to avoid any compatibility issues.
After the migration, don’t forget to cleanup (remove) the old container from the source node :
- `vzctl destroy [CTID]`
Also, always make sure you have a backup before doing any potentially destructive operation.