The following is part 2 of a 3 part series that goes over installation and configuration of Xen live migration with DRBD.
This article covers a creation of a Debian guest domain (domU virtual machine) which we will later use to migrate between the two Xen hosts.
The convention followed in the article is that [ALL]# denotes a command that needs to be run on both Xen nodes.
Installation
We’ll need the xen-tools package:
[ALL]# apt-get install xen-tools
Configure xen-tools
We’ll need an LVM group to store domU images:
[ALL]# vgcreate vg_xen /dev/sdb Physical volume "/dev/sdb" successfully created Volume group "vg_xen" successfully created
[ALL]# vgs VG #PV #LV #SN Attr VSize VFree vg_debian8 1 2 0 wz--n- 63.25g 48.11g vg_xen 1 0 0 wz--n- 50.00g 50.00g
Configuration file /etc/xen-tools/xen-tools.conf with our default settings can be seen below. Note the use of LVM group.
lvm = vg_xen install-method = debootstrap size = 4G # Root disk, suffix (G, M, k) required memory = 256M # Suffix (G, M, k) required maxmem = 512M # Suffix (G, M, k) optional swap = 128M # Suffix (G, M, k) required fs = ext4 # Default file system for any disk dist = `xt-guess-suite-and-mirror --suite` image = sparse # Specify sparse vs. full disk images (file based images only) dhcp = 1 genpass = 1 genpass_len = 12 hash_method = sha512 kernel = /boot/vmlinuz-`uname -r` initrd = /boot/initrd.img-`uname -r` arch = [amd64] mirror = `xt-guess-suite-and-mirror --mirror` mirror_wheezy = http://http.debian.net/debian mirror_jessie = http://http.debian.net/debian ext4_options = noatime,nodiratime,errors=remount-ro ext2_options = noatime,nodiratime,errors=remount-ro xfs_options = defaults
Optionally, for those using loopback images to store Xen guest domains, you will almost certainly exhaust the default number of loopback images the distribution has created, and therefore you may need the following:
[ALL]# modprobe loop max_loop=255 [ALL]# echo "loop max_loop=255" >>/etc/modules
Also ensure that you have the actual devices in the /dev directory on your host.
Create a Debian Jessie Guest (DomU)
Note the LVM volume /dev/vg_xen/jessie01-disk the guest is being installed on.
[xen01]# xen-create-image --hostname=jessie01 --lvm=vg_xen \
--vcpus=1 --memory=256M --maxmem=512M --size=4G --fs=ext4 \
--dhcp --mac=08:00:27:ff:60:00 --arch=amd64 --dist=jessie \
--noswap
General Information
--------------------
Hostname : jessie01
Distribution : jessie
Mirror : http://ftp.uk.debian.org/debian
Partitions : / 4G (ext4)
Image type : full
Memory size : 256M
Max mem size : 512M
Kernel path : /boot/vmlinuz-3.16.0-4-amd64
Initrd path : /boot/initrd.img-3.16.0-4-amd64
Networking Information
----------------------
IP Address : DHCP [MAC: 08:00:27:ff:60:00]
Creating ext4 filesystem on /dev/vg_xen/jessie01-disk
Done
Installation method: debootstrap
Done
Running hooks
Done
No role scripts were specified. Skipping
Creating Xen configuration file
Done
No role scripts were specified. Skipping
Setting up root password
Generating a password for the new guest.
All done
Logfile produced at:
/var/log/xen-tools/jessie01.log
Installation Summary
---------------------
Hostname : jessie01
Distribution : jessie
MAC Address : 08:00:27:ff:60:00
IP Address(es) : dynamic
RSA Fingerprint : 55:e7:99:06:bf:db:dd:1f:bc:0e:72:d9:26:ae:31:3d
Root Password : sqKfU3JT8sZ6
[xen01]# xen-list-images Name: jessie01 Memory: 256 MB Config: /etc/xen/jessie01.cfg
Start the VM, ensure it’s running and connect to the console.
[xen01]# xl create /etc/xen/jessie01.cfg Parsing config from /etc/xen/jessie01.cfg
[xen01]# xl list Name ID Mem VCPUs State Time(s) Domain-0 0 1022 1 r----- 215.4 jessie01 1 256 1 -b---- 1.6
[xen01]# xl console jessie01
To exit console, type “Ctrl + ]” (same as with telnet).
To shutdown the guest:
[xen01]# xl shutdown jessie01
In case there is a need to immediately terminate a domain, the destroy option can be used. This does not however give the domain OS any chance to react, and is the equivalent of ripping the power cord out on a physical machine. In most cases we will want to use the shutdown command instead.
[xen01]# xl destroy jessie01
The image file can be deleted this way, if required:
[xen01]# xen-delete-image jessie01
To ensure that the guest jessie01 is auto started on boot, a symlink can be created:
[ALL]# mkdir -p /etc/xen/auto [xen01]# ln -sf /etc/xen/jessie01.cfg /etc/xen/auto/jessie01.cfg
