We’re going to discontinue one of our datastores and moving away all active images there. However, one of the images are used as template for our CentOS VMs and assigned as non-persistent for 28 VMs.
How can we migrate it safely to another Image datastore?
Thank you in advance!
Hi, what type of ds? Qcow2?
Then it us priblematic, because all VMs disks use this base image as backing-image. Best way is terminate all vms and create new from new image in new ds. If you need prereserve actual vms, then you can stop all, move image to new ds, delete old ds, and create symlink on filesystem to old location, and start vms
well, I’m a bit surprised since it really sounds tricky. OpenNebula doesn’t cover any situations like this? Actually, we have glusterfs configured as backend for this storage with the failed drive we’re not able to hot-swap.
with you plan about preserving VMs - I’m worrying about VM template section:
DISK = [
ALLOW_ORPHANS = “NO”,
CLONE = “YES”,
CLONE_TARGET = “SYSTEM”,
CLUSTER_ID = “0”,
DATASTORE = “backup_storage”,
DATASTORE_ID = “103”,
DEV_PREFIX = “sd”,
DISK_ID = “0”,
DISK_SNAPSHOT_TOTAL_SIZE = “0”,
DISK_TYPE = “FILE”,
DRIVER = “qcow2”,
IMAGE = “CentOS 7.8 [08.17.2020]”,
IMAGE_ID = “105”,
IMAGE_STATE = “2”,
IMAGE_UNAME = “oneadmin”,
LN_TARGET = “NONE”,
ORIGINAL_SIZE = “10240”,
READONLY = “NO”,
SAVE = “NO”,
SIZE = “524288”,
SOURCE = “/var/lib/one//datastores/103/a31d58b29e84f1742e10075f575338fe”,
TARGET = “sda”,
TM_MAD = “shared”,
TYPE = “FILE” ]
I can create symlink for /var/lib/one//datastores/103/a31d58b29e84f1742e10075f575338fe to the new image location on new datastore - no problem with this part.
But, it contains “DATASTORE = “backup_storage””. What happens if I remove this datastore? I guess it will bump me with error like “man, this datastore not found”.
Looks really dangerous for me… Huge downtime and big chance of losing data.
Hi, there is one more problem, your system ds. Base image is in image ds, clones pointing to base image are in system ds. So you have to symlink both.
Regarding vm template, you can update it using command ‘onevm update ’. In this case you can also update source image, and get rid of base image by rebasing qcow2. So you dont need symlinks
As @feldsam said, there’s no supported method for achieving your goal with current OpenNebula functionality. Probably the way to proceed is to manually update VM references by using
onedb update-body command. I think the main functionality should works fine with that, but I suggest to test this with a testing VM before trying to apply any changes to production VMs.
Also, I think it makes sense to provide functionality to ease this kind of procedures. It would be nice if you can open a GitHub issue explaining your use case so we can evaluate it for future releases.
Hi @cgonzalez, thanks for pointing to
onedb update-body I was meaning this command, but I mistaken it with
hey @cgonzalez and @feldsam
thank you for your suggestions, guys! I will test with “onedb update-body”, maybe it’s the exact thing I’m looking for.
okay, seems like it doesn’t work like this or I’m missing something:
I’ve cloned the original image “CentOS 7.8 [08.17.2020]” to “default” datastore as “Clone CentOS 7.8 [08.17.2020]”
For the VM 686, I’ve corrected the following fields (posting as image, format somehow doesn’t work):
The VM interface looks good, I was able to see the new image under Storage section (Stop, Reboot, Undeploy works properly, no data lose)
But unfortunately, no reflection on Images:
@cgonzalez do you have any suggestion how to make this updated as well?
The’re a reference at the image pointing to the VMs using it:
Yo need to empty this section to something like:
You can use
onedb update-body command for doing this too.
Also, after making these changes, you can run
onedb fsck command to check if there’s any other inconsistency.
Would like to thank you for your suggestion, I think I’ve managed to move all linked VMs to the new image.
Just to double-check with you, how safe
onedb fsck command is? As I understand, I need to completely shutdown Opennebula and run it. Does it perform just checks or any changes to database?
Thank you in advance
Nice to hear that!
You shouldn’t have any problem by running
fsck tool, it will try to fix the errors that can be automatically fixed and will warn you if there’s any error that need manual intervention. It will also perform a DB backup before modifying anything.