Network/Procedures/Migrate a VM to a new VM Host

From Makers Local 256
Jump to: navigation, search
  • Exactly match the size of an existing volume
root@vm4:~# lvdisplay /dev/vm4_storage/mail_disk --units=B | grep "LV Size"
  LV Size                8589934592 B
root@vm666:~# lvcreate 666 --name mail_disk --size 8589934592B
  • Edit the resource file on the current primary to include the new VM host
resource mail_disk {
	protocol C;
	meta-disk internal;
	device /dev/drbd_mail_disk minor 4; #dev and minor must be unique per disk
	syncer {
		verify-alg sha1;
		rate 5M;
	}
	net {
		allow-two-primaries;# yes;
		cram-hmac-alg sha1;
		shared-secret "mail_disk";
                after-sb-0pri discard-zero-changes;
                after-sb-1pri consensus;
                after-sb-2pri disconnect;
	}
	on vm4 {
		disk /dev/vm4_storage/mail_disk;
		address 10.56.0.40:7796; #port must be unique per disk
	}
	on vm666 {
		disk /dev/666/mail_disk;
		address 10.56.0.60:7796;
	}
#	on vm2 {
#		disk /dev/vm2_storage/mail_disk;
#		address 10.56.0.20:7796;
#	}
}
  • Copy the drbd resource file to the new VM host
root@vm666# scp vm4:/etc/drbd.d/mail_disk.res /etc/drbd.d/
  • Create the drbd block device
root@vm666# drbdadm create-md mail_disk
  • Start a sync between the primary and the new VM host
root@vm666# drbdadm adjust mail_disk
root@vm4# drbdadm adjust mail_disk
root@vm4# drbdadm disconnect mail_disk
root@vm4# drbdadm connect mail_disk
  • Once the sync has finished, stop the VM on the primary and start it on the new VM host
root@vm4# xl shutdown mail
root@vm4# sleep 60
root@vm4# drbdadm secondary mail_disk
#the last number in the error output is X
root@vm4# multipathd -k
root@vm4# multipathd> del path drbdX
root@vm4# multipathd> quit
root@vm4# drbdadm secondary mail_disk
root@vm666# drbdadm primary mail_disk
root@vm666# xl create /etc/xen/mail.cfg