ClonageVM
Le clonage
root@super-tech:/# virsh domblklist sirh Target Source ------------------------------------------------ vda /var/lib/libvirt/images/sirh-sys.img vdb /var/lib/libvirt/images/sirh-data.img root@super-tech:/# virsh snapshot-create-as --domain sirh sirh-snap --disk-only --atomic --quiesce Domain snapshot sirh-snap created root@super-tech:/# virsh snapshot-list sirh Name Creation Time State ------------------------------------------------------------ sirh-snap 2016-03-30 12:10:47 -0400 disk-snapshot root@super-tech:/# virsh domblklist sirh Target Source ------------------------------------------------ vda /var/lib/libvirt/images/sirh-sys.sirh-snap vdb /var/lib/libvirt/images/sirh-data.sirh-snap root@super-tech:/# rsync -avh --progress /var/lib/libvirt/images/sirh-sys.img /var/lib/libvirt/images2/sirh-sys-COPY.img sending incremental file list sirh-sys.img 4.15G 100% 80.45MB/s 0:00:49 (xfr#1, to-chk=0/1) sent 4.15G bytes received 35 bytes 82.21M bytes/sec total size is 4.15G speedup is 1.00 root@super-tech:/# rsync -avh --progress /var/lib/libvirt/images/sirh-data.img /var/lib/libvirt/images2/sirh-data-COPY.img sending incremental file list sirh-data.img 19.70G 100% 70.89MB/s 0:04:25 (xfr#1, to-chk=0/1) sent 19.71G bytes received 35 bytes 74.23M bytes/sec total size is 19.70G speedup is 1.00 root@super-tech:/# virsh blockcommit sirh vda --active --verbose --pivot Block Commit: [100 %] Successfully pivoted root@super-tech:/# virsh blockcommit sirh vdb --active --verbose --pivot Block Commit: [100 %] Successfully pivoted root@super-tech:/# virsh snapshot-list sirh Name Creation Time State ------------------------------------------------------------ sirh-snap 2016-03-30 12:10:47 -0400 disk-snapshot root@super-tech:/# virsh domblklist sirh Target Source ------------------------------------------------ vda /var/lib/libvirt/images/sirh-sys.img vdb /var/lib/libvirt/images/sirh-data.img root@super-tech:/# root@super-tech:/# rm /var/lib/libvirt/images/sirh-data.sirh-snap /var/lib/libvirt/images/sirh-sys.sirh-snap root@super-tech:/#
Création et adaptation de la vm clone
Disons qu'après l'opération de clonage, nous avons : form-sirh-sys.img et form-sirh-data.img.
création de la nouvelle vm
root@super-tech:# virt-install --import --disk /var/lib/libvirt/images2/form-sirh-sys.img,device=disk,bus=virtio,io=native --disk /var/lib/libvirt/images2/form-sirh-data.img,device=disk,bus=virtio,io=native --vcpus=1 --ram=1024 --name=form-sirh --hvm --vnc --network bridge:br_dmzrpv_102,model=virtio
On la met sur un bridge qui n'est pas le bon, juste le temps de changer son IP.- changement des IP ... hummm ... comment automatiser quand on n'a aucun accès (cf ci-dessus, mauvais bridge, mauvaise IP)
- et qu'on n'a pas de qemu-guest-agent (vm sous Squeeze)
- eh ben : on le fait à la main :
côté vm (connexion via la console)
root@sirh:# sed -i "/^\taddress/ c\ /taddress 199.84.140.47" /etc/network/interfaces root@sirh:# echo "form-sirh" > /etc/hostname root@sirh:# sed -i "s/sirh/c\199.84.140.47\tform-sirh.auf.org sirh.auf.org form-sirh recrutement.auf.org form-recrutement.auf.org/" /etc/hosts root@sirh:# rm /etc/udev/rules.d/70-persistent-net.rules root@sirh:# poweroff
(éventuellement /etc/resolv.conf aussi) . On arrête la vm à la fin
on modifie son interface réseau (côté hôte) :
root@super-tech:~# virsh dumpxml --inactive --security-info form-sirh > form-sirh.xml root@super-tech:~# sed -i "s#br_dmzrpv_102#br_dmzpub_101#" form-sirh.xml root@super-tech:# virsh define form-sirh.xml root@super-tech:# virsh start form-sirh
et on relance la vm.- adaptation (côté vm)
virer les cron
root@form-sirh:~# sed -i -e '/adequasys/s|^|#|' /etc/cron.d/local-adequasys
Mod-mellon : accès pour Mathieu seul
root@form-sirh:~# sed -E -i -e '/(mathieu.person|\[REG\])/! s|MellonCond|#MellonCond|' /etc/apache2/sites-available/sirh.auf.org-ssl.conf root@form-sirh:~# sed -i -e '/mathieu.person/s/\[OR\]//' /etc/apache2/sites-available/sirh.auf.org-ssl.conf
changer le nom serveur (mais pas les dossiers)
root@form-sirh:~# sed -E -i -e '/(saml|srv\/www)/! s|sirh.auf.org|form-sirh.auf.org|' /etc/apache2/sites-available/sirh.auf.org-ssl.conf root@form-sirh:~# sed -i -e 's/PROD/FORM/' /etc/apache2/sites-available/sirh.auf.org-ssl.conf
- relancer apache2