initial commit
This commit is contained in:
commit
9aaf1744a5
5 changed files with 571 additions and 0 deletions
134
README
Normal file
134
README
Normal file
|
@ -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/
|
79
client1.txt
Normal file
79
client1.txt
Normal file
|
@ -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;
|
79
client2.txt
Normal file
79
client2.txt
Normal file
|
@ -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;
|
140
server1.txt
Normal file
140
server1.txt
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
# 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/expert_recipe string \
|
||||||
|
my-layout :: \
|
||||||
|
1000 1000 1500 ext4 \
|
||||||
|
$primary{ } \
|
||||||
|
$bootable{ } \
|
||||||
|
method{ format } \
|
||||||
|
format{ } \
|
||||||
|
use_filesystem{ } \
|
||||||
|
filesystem{ ext4 } \
|
||||||
|
mountpoint{ / } \
|
||||||
|
label{ root } \
|
||||||
|
. \
|
||||||
|
150 150 150 ext4 \
|
||||||
|
label{ drbd-meta } \
|
||||||
|
. \
|
||||||
|
300 1000 -1 ext4 \
|
||||||
|
method{ format } \
|
||||||
|
format{ } \
|
||||||
|
use_filesystem{ } \
|
||||||
|
filesystem{ ext4 } \
|
||||||
|
label{ drbd-data } \
|
||||||
|
.
|
||||||
|
d-i partman-basicfilesystems/no_mount_point boolean false
|
||||||
|
d-i partman-basicfilesystems/no_swap boolean false
|
||||||
|
d-i partman-ext3/no_mount_point boolean false
|
||||||
|
d-i partman-ext4/no_mount_point boolean false
|
||||||
|
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
|
||||||
|
tasksel tasksel/first multiselect
|
||||||
|
d-i pkgsel/include string ntp ntpdate nfs-kernel-server drbd8-utils heartbeat
|
||||||
|
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
|
||||||
|
# also, `drbdadm primary all` will only called from firstboot on server1
|
||||||
|
|
||||||
|
d-i preseed/late_command string \
|
||||||
|
echo 'T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100' >> /target/etc/inittab; \
|
||||||
|
echo 'GRUB_CMDLINE_LINUX="console=ttyS0"' >> /target/etc/default/grub; \
|
||||||
|
echo 'GRUB_TERMINAL=serial' >> /target/etc/default/grub; \
|
||||||
|
in-target update-grub; \
|
||||||
|
in-target update-rc.d -f nfs-kernel-server remove; \
|
||||||
|
in-target update-rc.d -f nfs-common remove; \
|
||||||
|
echo '/data/export/ 10.0.2.0/255.255.255.0(rw,no_root_squash,no_all_squash,sync,no_subtree_check)' > /target/etc/exports; \
|
||||||
|
echo 'global {' > /target/etc/drbd.conf; \
|
||||||
|
echo ' usage-count no;' >> /target/etc/drbd.conf; \
|
||||||
|
echo '}' >> /target/etc/drbd.conf; \
|
||||||
|
echo 'resource res {' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' protocol C;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' startup { degr-wfc-timeout 120; }' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' disk { on-io-error detach; }' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' net {}' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' on server1 {' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' device /dev/drbd0;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' disk /dev/sda6;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' address 10.0.2.172:7788;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' meta-disk /dev/sda5[0];' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' }' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' on server2 {' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' device /dev/drbd0;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' disk /dev/sda6;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' address 10.0.2.173:7788;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' meta-disk /dev/sda5[0];' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' }' >> /target/etc/drbd.conf; \
|
||||||
|
echo '}' >> /target/etc/drbd.conf; \
|
||||||
|
echo 'logfacility local0' > /target/etc/heartbeat/ha.cf; \
|
||||||
|
echo 'keepalive 2' >> /target/etc/heartbeat/ha.cf; \
|
||||||
|
echo 'deadtime 30' >> /target/etc/heartbeat/ha.cf; \
|
||||||
|
echo 'bcast eth0' >> /target/etc/heartbeat/ha.cf; \
|
||||||
|
echo 'node server1 server2' >> /target/etc/heartbeat/ha.cf; \
|
||||||
|
echo 'server1 IPaddr::10.0.2.174/24/eth0 drbddisk::res Filesystem::/dev/drbd0::/data::ext4 nfs-kernel-server' > /target/etc/heartbeat/haresources; \
|
||||||
|
echo 'auth 3' > /target/etc/heartbeat/authkeys; \
|
||||||
|
echo '3 md5 somerandomstring' >> /target/etc/heartbeat/authkeys; \
|
||||||
|
chmod 600 /target/etc/heartbeat/authkeys; \
|
||||||
|
echo '127.0.0.1 localhost' > /target/etc/hosts; \
|
||||||
|
echo '127.0.1.1 server1' >> /target/etc/hosts; \
|
||||||
|
echo '10.0.2.172 server1' >> /target/etc/hosts; \
|
||||||
|
echo '10.0.2.173 server2' >> /target/etc/hosts; \
|
||||||
|
echo '10.0.2.83 client1' >> /target/etc/hosts; \
|
||||||
|
echo '10.0.2.84 client2' >> /target/etc/hosts; \
|
||||||
|
echo 'server1' > /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.172' >> /target/etc/network/interfaces; \
|
||||||
|
echo ' netmask 255.255.255.0' >> /target/etc/network/interfaces; \
|
||||||
|
echo ' gateway 10.0.2.2' >> /target/etc/network/interfaces; \
|
||||||
|
mkdir /target/data; \
|
||||||
|
mount /dev/sda6 /target/data; \
|
||||||
|
mv /target/var/lib/nfs/ /target/data/; \
|
||||||
|
mkdir /target/data/export; \
|
||||||
|
umount /target/data; \
|
||||||
|
ln -s /data/nfs/ /target/var/lib/nfs; \
|
||||||
|
echo '#!/bin/sh -e' > /target/etc/init.d/firstboot; \
|
||||||
|
echo '### BEGIN INIT INFO' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '# Provides: firstboot' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '# Required-Start: $all' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '# Required-Stop:' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '# Default-Start: 2 3 4 5' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '# Default-Stop: 0 1 6' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '### END INIT INFO' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo 'echo "running firstboot script"' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo 'update-rc.d -f firstboot remove' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo 'ifconfig > foobar' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo 'cat /proc/drbd >> foobar' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo 'drbdadm create-md res' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '/etc/init.d/drbd restart' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo 'drbdadm -- --overwrite-data-of-peer primary all' >> /target/etc/init.d/firstboot; \
|
||||||
|
chmod +x /target/etc/init.d/firstboot; \
|
||||||
|
in-target update-rc.d firstboot defaults;
|
139
server2.txt
Normal file
139
server2.txt
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
# 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/expert_recipe string \
|
||||||
|
my-layout :: \
|
||||||
|
1000 1000 1500 ext4 \
|
||||||
|
$primary{ } \
|
||||||
|
$bootable{ } \
|
||||||
|
method{ format } \
|
||||||
|
format{ } \
|
||||||
|
use_filesystem{ } \
|
||||||
|
filesystem{ ext4 } \
|
||||||
|
mountpoint{ / } \
|
||||||
|
label{ root } \
|
||||||
|
. \
|
||||||
|
150 150 150 ext4 \
|
||||||
|
label{ drbd-meta } \
|
||||||
|
. \
|
||||||
|
300 1000 -1 ext4 \
|
||||||
|
method{ format } \
|
||||||
|
format{ } \
|
||||||
|
use_filesystem{ } \
|
||||||
|
filesystem{ ext4 } \
|
||||||
|
label{ drbd-data } \
|
||||||
|
.
|
||||||
|
d-i partman-basicfilesystems/no_mount_point boolean false
|
||||||
|
d-i partman-basicfilesystems/no_swap boolean false
|
||||||
|
d-i partman-ext3/no_mount_point boolean false
|
||||||
|
d-i partman-ext4/no_mount_point boolean false
|
||||||
|
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
|
||||||
|
tasksel tasksel/first multiselect
|
||||||
|
d-i pkgsel/include string ntp ntpdate nfs-kernel-server drbd8-utils heartbeat
|
||||||
|
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
|
||||||
|
# also, `drbdadm primary all` will only called from firstboot on server1
|
||||||
|
|
||||||
|
d-i preseed/late_command string \
|
||||||
|
echo 'T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100' >> /target/etc/inittab; \
|
||||||
|
echo 'GRUB_CMDLINE_LINUX="console=ttyS0"' >> /target/etc/default/grub; \
|
||||||
|
echo 'GRUB_TERMINAL=serial' >> /target/etc/default/grub; \
|
||||||
|
in-target update-grub; \
|
||||||
|
in-target update-rc.d -f nfs-kernel-server remove; \
|
||||||
|
in-target update-rc.d -f nfs-common remove; \
|
||||||
|
echo '/data/export/ 10.0.2.0/255.255.255.0(rw,no_root_squash,no_all_squash,sync,no_subtree_check)' > /target/etc/exports; \
|
||||||
|
echo 'global {' > /target/etc/drbd.conf; \
|
||||||
|
echo ' usage-count no;' >> /target/etc/drbd.conf; \
|
||||||
|
echo '}' >> /target/etc/drbd.conf; \
|
||||||
|
echo 'resource res {' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' protocol C;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' startup { degr-wfc-timeout 120; }' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' disk { on-io-error detach; }' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' net {}' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' on server1 {' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' device /dev/drbd0;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' disk /dev/sda6;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' address 10.0.2.172:7788;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' meta-disk /dev/sda5[0];' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' }' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' on server2 {' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' device /dev/drbd0;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' disk /dev/sda6;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' address 10.0.2.173:7788;' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' meta-disk /dev/sda5[0];' >> /target/etc/drbd.conf; \
|
||||||
|
echo ' }' >> /target/etc/drbd.conf; \
|
||||||
|
echo '}' >> /target/etc/drbd.conf; \
|
||||||
|
echo 'logfacility local0' > /target/etc/heartbeat/ha.cf; \
|
||||||
|
echo 'keepalive 2' >> /target/etc/heartbeat/ha.cf; \
|
||||||
|
echo 'deadtime 30' >> /target/etc/heartbeat/ha.cf; \
|
||||||
|
echo 'bcast eth0' >> /target/etc/heartbeat/ha.cf; \
|
||||||
|
echo 'node server1 server2' >> /target/etc/heartbeat/ha.cf; \
|
||||||
|
echo 'server1 IPaddr::10.0.2.174/24/eth0 drbddisk::res Filesystem::/dev/drbd0::/data::ext4 nfs-kernel-server' > /target/etc/heartbeat/haresources; \
|
||||||
|
echo 'auth 3' > /target/etc/heartbeat/authkeys; \
|
||||||
|
echo '3 md5 somerandomstring' >> /target/etc/heartbeat/authkeys; \
|
||||||
|
chmod 600 /target/etc/heartbeat/authkeys; \
|
||||||
|
echo '127.0.0.1 localhost' > /target/etc/hosts; \
|
||||||
|
echo '127.0.1.1 server2' >> /target/etc/hosts; \
|
||||||
|
echo '10.0.2.172 server1' >> /target/etc/hosts; \
|
||||||
|
echo '10.0.2.173 server2' >> /target/etc/hosts; \
|
||||||
|
echo '10.0.2.83 client1' >> /target/etc/hosts; \
|
||||||
|
echo '10.0.2.84 client2' >> /target/etc/hosts; \
|
||||||
|
echo 'server2' > /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.173' >> /target/etc/network/interfaces; \
|
||||||
|
echo ' netmask 255.255.255.0' >> /target/etc/network/interfaces; \
|
||||||
|
echo ' gateway 10.0.2.2' >> /target/etc/network/interfaces; \
|
||||||
|
mkdir /target/data; \
|
||||||
|
mount /dev/sda6 /target/data; \
|
||||||
|
mv /target/var/lib/nfs/ /target/data/; \
|
||||||
|
mkdir /target/data/export; \
|
||||||
|
umount /target/data; \
|
||||||
|
ln -s /data/nfs/ /target/var/lib/nfs; \
|
||||||
|
echo '#!/bin/sh -e' > /target/etc/init.d/firstboot; \
|
||||||
|
echo '### BEGIN INIT INFO' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '# Provides: firstboot' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '# Required-Start: $all' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '# Required-Stop:' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '# Default-Start: 2 3 4 5' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '# Default-Stop: 0 1 6' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '### END INIT INFO' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo 'echo "running firstboot script"' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo 'update-rc.d -f firstboot remove' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo 'ifconfig > foobar' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo 'cat /proc/drbd >> foobar' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo 'drbdadm create-md res' >> /target/etc/init.d/firstboot; \
|
||||||
|
echo '/etc/init.d/drbd restart' >> /target/etc/init.d/firstboot; \
|
||||||
|
chmod +x /target/etc/init.d/firstboot; \
|
||||||
|
in-target update-rc.d firstboot defaults;
|
Loading…
Reference in a new issue