I am sure some of you are wondering how to migrate or move individual SmartOS Virtual Machines from one SmartOS Server Node to another.
This may be necessary in certain situations such as:
- Backup and Disaster Recovery purposes: In situations that require you have a standby node available with a backup of your running VM’s that can be brought up quickly should a failure occur.
- SmartOS server load balancing: In situations where one SmartOS Node is overloaded and you need to move VM’s to another server node that has more capacity available.
- Deploying Clones of your SmartOS VM’s to new server nodes.
- Moving a Virtual Machine to another geographic zone for lower latency or to adhere to legalities that requires IT infrastructure reside physically in a certain country.
Folks, before we get started it is important to mention that this multi step manual method of accomplishing this will probably not be required in later releases of SmartOS. I am told that members of team at Joyent are planning on integrating this directly into “VMADM” at some point in the future. In addition these instructions are specifically for KVM branded Virtual Machines. There are tools in SmartOS such as “zonecfg” which is used to manage all types of zones, but as far as I can tell they mainly work with Joyent branded zones and did not work for me with KVM Virtual Machines. Please let me know if anyone has either managed to use them successfully or has a more elegant way of accomplishing this.
In the mean time the below steps worked perfectly for me and is confirmed to work even after a node reboot.
The Steps Involved
On the Source SmartOS Node:
zfs snapshot -r zones/cb18400e-0df6-40a1-b6d8-f99d6f53e9b0@migration zfs snapshot -r zones/cb18400e-0df6-40a1-b6d8-f99d6f53e9b0-disk0@migration zfs send -R zones/cb18400e-0df6-40a1-b6d8-f99d6f53e9b0@migration | ssh firstname.lastname@example.org zfs recv zones/cb18400e-0df6-40a1-b6d8-f99d6f53e9b0 zfs send -R zones/cb18400e-0df6-40a1-b6d8-f99d6f53e9b0-disk0@migration | ssh email@example.com zfs recv zones/cb18400e-0df6-40a1-b6d8-f99d6f53e9b0-disk0 scp /etc/zones/cb18400e-0df6-40a1-b6d8-f99d6f53e9b0.xml firstname.lastname@example.org:/etc/zones/
On the Target SmartOS Node:
echo 'cb18400e-0df6-40a1-b6d8-f99d6f53e9b0:installed:/zones/cb18400e-0df6-40a1-b6d8-f99d6f53e9b0:cb18400e-0df6-40a1-b6d8-f99d6f53e9b0' >> /etc/zones/index vmadm boot cb18400e-0df6-40a1-b6d8-f99d6f53e9b0
Thats it we are done. It would be pretty easy to to script this. Example: “vm-migrate UUID TARGET-IP”
If anyone does indeed write such a script I hope you would consider sharing it?