-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9aaf174
Showing
5 changed files
with
571 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
4.1. a) and 4.2 a) | ||
|
||
In this setup we will create four virtual machines. Two servers for redundant | ||
data storage and two clients, each running a dom0. | ||
|
||
Network configuration is done using static IPs: | ||
|
||
server1: 10.0.2.172 | ||
server2: 10.0.2.173 | ||
virt_serv: 10.0.2.174 | ||
client1: 10.0.2.83 | ||
client2: 10.0.2.84 | ||
|
||
All of the following is executed by several factors faster after installation | ||
of kvm for qemu: | ||
|
||
apt-get install qemu-kvm | ||
|
||
The tutorial assumes a 64 bit host. For a 32 bit host, change | ||
qemu-system-x86_64 to qemu-system-i386 and change amd64 in the installer url to | ||
i386. | ||
|
||
The tutorial also assumes a Debian host (any release of lenny or newer should | ||
work) and a working apt-cacher setup. To setup apt-cacher, do: | ||
|
||
apt-get install apt-cacher | ||
|
||
If you dont want to use apt-cacher, you have to adapt the package sources in | ||
the scripts. | ||
|
||
Get the debian wheezy installer: | ||
|
||
wget http://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/kfreebsd-amd64/iso-cd/debian-testing-kfreebsd-amd64-businesscard.iso | ||
|
||
Install vde for a userspace switched network between all connected qemu | ||
instances: | ||
|
||
apt-get install vde2 | ||
|
||
And start it (sending it to the background) together with slirp which provides | ||
connection to the outside using slirp networking (just as qemu user mode | ||
networking): | ||
|
||
vde_switch -daemon | ||
slirpvde -dhcp -daemon | ||
|
||
Starting slirp with dhcp enabled is necessary for the debian-installer to | ||
acquire an initial IP (giving all settings as isolinux arguments is tedious and | ||
errorprone) and for the domus to get an IP. | ||
|
||
Create two disk images for the two server machines and two for the client | ||
machines: | ||
|
||
dd if=/dev/zero of=server1.img bs=1 count=1 seek=3000MiB | ||
dd if=/dev/zero of=server2.img bs=1 count=1 seek=3000MiB | ||
dd if=/dev/zero of=client1.img bs=1 count=1 seek=3000MiB | ||
dd if=/dev/zero of=client2.img bs=1 count=1 seek=3000MiB | ||
|
||
Start the machines with these images, giving them all the debian installer | ||
cdrom and connecting them to the vde network. | ||
|
||
qemu-system-x86_64 -m 256 -hda server1.img -net nic,macaddr=DE:AD:BE:EF:BE:9D -net vde,sock=/tmp/vde.ctl -cdrom debian-testing-amd64-businesscard.iso | ||
qemu-system-x86_64 -m 256 -hda server2.img -net nic,macaddr=DE:AD:BE:EF:74:E9 -net vde,sock=/tmp/vde.ctl -cdrom debian-testing-amd64-businesscard.iso | ||
qemu-system-x86_64 -m 256 -hda client1.img -net nic,macaddr=DE:AD:BE:EF:D4:4A -net vde,sock=/tmp/vde.ctl -cdrom debian-testing-amd64-businesscard.iso | ||
qemu-system-x86_64 -m 256 -hda client2.img -net nic,macaddr=DE:AD:BE:EF:78:01 -net vde,sock=/tmp/vde.ctl -cdrom debian-testing-amd64-businesscard.iso | ||
|
||
The isolinux boot menu will pop up. Choose "Advanced options" and then select | ||
"Automated install" and press [TAB] to edit the boot commandline. Append the | ||
preseed url for debconf like this to the end of each of the installers | ||
respectively: | ||
|
||
preseed/url=http://mister-muffin.de/debian/server1.txt | ||
preseed/url=http://mister-muffin.de/debian/server2.txt | ||
preseed/url=http://mister-muffin.de/debian/client1.txt | ||
preseed/url=http://mister-muffin.de/debian/client2.txt | ||
|
||
Press enter and get yourself a coffee. After everything is finished the | ||
machines will automatically shut down. | ||
|
||
Now start all machines by using: | ||
|
||
qemu-system-x86_64 -m 256 -hda server1.img -net nic,macaddr=DE:AD:BE:EF:BE:9D -net vde,sock=/tmp/vde.ctl -nographic | ||
qemu-system-x86_64 -m 256 -hda server2.img -net nic,macaddr=DE:AD:BE:EF:74:E9 -net vde,sock=/tmp/vde.ctl -nographic | ||
qemu-system-x86_64 -m 1000 -hda client1.img -net nic,macaddr=DE:AD:BE:EF:D4:4A -net vde,sock=/tmp/vde.ctl -nographic | ||
qemu-system-x86_64 -m 1000 -hda client2.img -net nic,macaddr=DE:AD:BE:EF:78:01 -net vde,sock=/tmp/vde.ctl -nographic | ||
|
||
The two clients get more ram now because they have to host domus. | ||
|
||
A firstboot sysv-init script will initialize drbd on the meta partition for | ||
both servers and start the synchronization by setting server1 as the primary | ||
host. | ||
|
||
When this is done, extract a root filesystem of your choice into | ||
/data/export/vm01 on server1. | ||
|
||
Creating a root filesystem to share via nfs can be done by using debootstrap | ||
and then manually configuring it [1] or by running xen-create-image, then | ||
editing /etc/fstab and then putting the result on server1. | ||
|
||
xen-create-image --hostname=vm01 --dir=/root --dhcp --noswap --size=400Mb | ||
|
||
For convenience I did the above and put a tarball with debian wheezy online. On | ||
server1, do: | ||
|
||
mkdir /data/export/vm01 | ||
wget -O - http://mister-muffin.de/debian/nfs-root-wheezy-amd64.tar | tar -x -C /data/export/vm01 | ||
|
||
Username: root | ||
Password: root | ||
|
||
After the rootfilesystem is in place you can start the domu on client1: | ||
|
||
xm create /etc/xen/vm01.cfg | ||
|
||
And migrate it to client2: | ||
|
||
xm migrate --live vm01 client2 | ||
|
||
tadaa! :) | ||
|
||
1/2: | ||
|
||
drbdadm create-md res | ||
#drbdadm up all | ||
|
||
1: | ||
#drbdadm -- --do-what-I-say primary all | ||
drbdadm -- --overwrite-data-of-peer primary all | ||
#drbdadm -- connect all | ||
#drbdadm primary | ||
|
||
|
||
|
||
[1] http://blog.mister-muffin.de/2011/11/21/xen-hypervisor-on-qemu-kvm-and-domu-nfs-boot-with-vde/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# preseed options use dhcp for installation | ||
# temporary hostname during installation will be "install" | ||
|
||
d-i debian-installer/locale string en_US | ||
d-i console-keymaps-at/keymap select us | ||
d-i keyboard-configuration/xkb-keymap select us | ||
d-i netcfg/choose_interface select auto | ||
d-i netcfg/get_hostname string install | ||
d-i netcfg/get_domain string foobar.org | ||
d-i mirror/country string manual | ||
d-i mirror/http/hostname string 10.0.2.2:3142 | ||
d-i mirror/http/directory string /ftp.de.debian.org/debian | ||
d-i mirror/suite string wheezy | ||
d-i mirror/udeb/suite string wheezy | ||
d-i passwd/root-login boolean true | ||
d-i passwd/make-user boolean false | ||
d-i passwd/root-password password root | ||
d-i passwd/root-password-again password root | ||
d-i clock-setup/utc boolean true | ||
d-i time/zone string UTC | ||
d-i clock-setup/ntp boolean true | ||
d-i partman-auto/method string regular | ||
d-i partman-auto/choose_recipe select atomic | ||
d-i partman-partitioning/confirm_write_new_label boolean true | ||
d-i partman/choose_partition select finish | ||
d-i partman/confirm boolean true | ||
d-i partman/confirm_nooverwrite boolean true | ||
d-i base-installer/install-recommends boolean false | ||
d-i base-installer/kernel/image select none | ||
tasksel tasksel/first multiselect | ||
d-i pkgsel/include string xen-linux-system-amd64 xen-tools xen-utils bridge-utils nfs-common | ||
d-i finish-install/reboot_in_progress note | ||
popularity-contest popularity-contest/participate boolean true | ||
d-i debian-installer/exit/poweroff boolean true | ||
|
||
# differences in the late_command string are only the static ip in | ||
# /etc/network/interfaces and the hostname in /etc/hostname and | ||
# localhost in /etc/hosts | ||
|
||
d-i preseed/late_command string \ | ||
echo 'T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100' >> /target/etc/inittab; \ | ||
mv /target/etc/grub.d/10_linux /target/etc/grub.d/21_linux; \ | ||
echo 'GRUB_CMDLINE_LINUX="console=ttyS0"' >> /target/etc/default/grub; \ | ||
echo 'GRUB_TERMINAL=serial' >> /target/etc/default/grub; \ | ||
in-target update-grub; \ | ||
echo '127.0.0.1 localhost' > /target/etc/hosts; \ | ||
echo '127.0.1.1 client1' >> /target/etc/hosts; \ | ||
echo '10.0.2.174 server' >> /target/etc/hosts; \ | ||
echo '10.0.2.83 client1' >> /target/etc/hosts; \ | ||
echo '10.0.2.84 client2' >> /target/etc/hosts; \ | ||
echo 'client1' > /target/etc/hostname; \ | ||
echo 'nameserver 10.0.2.3' > /target/etc/resolv.conf; \ | ||
echo 'auto lo' > /target/etc/network/interfaces; \ | ||
echo 'iface lo inet loopback' >> /target/etc/network/interfaces; \ | ||
echo 'auto eth0' >> /target/etc/network/interfaces; \ | ||
echo 'iface eth0 inet static' >> /target/etc/network/interfaces; \ | ||
echo ' address 10.0.2.83' >> /target/etc/network/interfaces; \ | ||
echo ' netmask 255.255.255.0' >> /target/etc/network/interfaces; \ | ||
echo ' gateway 10.0.2.2' >> /target/etc/network/interfaces; \ | ||
echo '(network-script network-bridge)' >> /target/etc/xen/xend-config.sxp; \ | ||
echo '(xend-relocation-server yes)' >> /target/etc/xen/xend-config.sxp; \ | ||
echo '(xend-relocation-port 8002)' >> /target/etc/xen/xend-config.sxp; \ | ||
echo '(xend-relocation-address '')' >> /target/etc/xen/xend-config.sxp; \ | ||
echo '(xend-relocation-hosts-allow '"''"')' >> /target/etc/xen/xend-config.sxp; \ | ||
echo 'kernel = "/boot/vmlinuz-3.1.0-1-amd64"' > /target/etc/xen/vm01.cfg; \ | ||
echo 'ramdisk = "/boot/initrd.img-3.1.0-1-amd64"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'vcpus = "1"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'memory = "128"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'name = "vm01"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'hostname = "vm01"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'dhcp = "dhcp"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'vif = [ "mac=00:16:3E:C7:09:32" ]' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'nfs_server = "10.0.2.174"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'nfs_root = "/data/export/vm01"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'root = "/dev/nfs"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'extra = "boot=nfs root=/dev/nfs"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'on_poweroff = "destroy"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'on_reboot = "restart"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'on_crash = "restart"' >> /target/etc/xen/vm01.cfg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# preseed options use dhcp for installation | ||
# temporary hostname during installation will be "install" | ||
|
||
d-i debian-installer/locale string en_US | ||
d-i console-keymaps-at/keymap select us | ||
d-i keyboard-configuration/xkb-keymap select us | ||
d-i netcfg/choose_interface select auto | ||
d-i netcfg/get_hostname string install | ||
d-i netcfg/get_domain string foobar.org | ||
d-i mirror/country string manual | ||
d-i mirror/http/hostname string 10.0.2.2:3142 | ||
d-i mirror/http/directory string /ftp.de.debian.org/debian | ||
d-i mirror/suite string wheezy | ||
d-i mirror/udeb/suite string wheezy | ||
d-i passwd/root-login boolean true | ||
d-i passwd/make-user boolean false | ||
d-i passwd/root-password password root | ||
d-i passwd/root-password-again password root | ||
d-i clock-setup/utc boolean true | ||
d-i time/zone string UTC | ||
d-i clock-setup/ntp boolean true | ||
d-i partman-auto/method string regular | ||
d-i partman-auto/choose_recipe select atomic | ||
d-i partman-partitioning/confirm_write_new_label boolean true | ||
d-i partman/choose_partition select finish | ||
d-i partman/confirm boolean true | ||
d-i partman/confirm_nooverwrite boolean true | ||
d-i base-installer/install-recommends boolean false | ||
d-i base-installer/kernel/image select none | ||
tasksel tasksel/first multiselect | ||
d-i pkgsel/include string xen-linux-system-amd64 xen-tools xen-utils bridge-utils nfs-common | ||
d-i finish-install/reboot_in_progress note | ||
popularity-contest popularity-contest/participate boolean true | ||
d-i debian-installer/exit/poweroff boolean true | ||
|
||
# differences in the late_command string are only the static ip in | ||
# /etc/network/interfaces and the hostname in /etc/hostname and | ||
# localhost in /etc/hosts | ||
|
||
d-i preseed/late_command string \ | ||
echo 'T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100' >> /target/etc/inittab; \ | ||
mv /target/etc/grub.d/10_linux /target/etc/grub.d/21_linux; \ | ||
echo 'GRUB_CMDLINE_LINUX="console=ttyS0"' >> /target/etc/default/grub; \ | ||
echo 'GRUB_TERMINAL=serial' >> /target/etc/default/grub; \ | ||
in-target update-grub; \ | ||
echo '127.0.0.1 localhost' > /target/etc/hosts; \ | ||
echo '127.0.1.1 client2' >> /target/etc/hosts; \ | ||
echo '10.0.2.174 server' >> /target/etc/hosts; \ | ||
echo '10.0.2.83 client1' >> /target/etc/hosts; \ | ||
echo '10.0.2.84 client2' >> /target/etc/hosts; \ | ||
echo 'client2' > /target/etc/hostname; \ | ||
echo 'nameserver 10.0.2.3' > /target/etc/resolv.conf; \ | ||
echo 'auto lo' > /target/etc/network/interfaces; \ | ||
echo 'iface lo inet loopback' >> /target/etc/network/interfaces; \ | ||
echo 'auto eth0' >> /target/etc/network/interfaces; \ | ||
echo 'iface eth0 inet static' >> /target/etc/network/interfaces; \ | ||
echo ' address 10.0.2.84' >> /target/etc/network/interfaces; \ | ||
echo ' netmask 255.255.255.0' >> /target/etc/network/interfaces; \ | ||
echo ' gateway 10.0.2.2' >> /target/etc/network/interfaces; \ | ||
echo '(network-script network-bridge)' >> /target/etc/xen/xend-config.sxp; \ | ||
echo '(xend-relocation-server yes)' >> /target/etc/xen/xend-config.sxp; \ | ||
echo '(xend-relocation-port 8002)' >> /target/etc/xen/xend-config.sxp; \ | ||
echo '(xend-relocation-address '')' >> /target/etc/xen/xend-config.sxp; \ | ||
echo '(xend-relocation-hosts-allow '"''"')' >> /target/etc/xen/xend-config.sxp; \ | ||
echo 'kernel = "/boot/vmlinuz-3.1.0-1-amd64"' > /target/etc/xen/vm01.cfg; \ | ||
echo 'ramdisk = "/boot/initrd.img-3.1.0-1-amd64"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'vcpus = "1"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'memory = "128"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'name = "vm01"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'hostname = "vm01"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'dhcp = "dhcp"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'vif = [ "mac=00:16:3E:C7:09:32" ]' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'nfs_server = "10.0.2.174"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'nfs_root = "/data/export/vm01"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'root = "/dev/nfs"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'extra = "boot=nfs root=/dev/nfs"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'on_poweroff = "destroy"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'on_reboot = "restart"' >> /target/etc/xen/vm01.cfg; \ | ||
echo 'on_crash = "restart"' >> /target/etc/xen/vm01.cfg; |
Oops, something went wrong.