From 9b119e3a938eec39a39985401618a5d29979fc8d Mon Sep 17 00:00:00 2001 From: Randy Bush Date: Sat, 4 Jul 2020 15:21:45 -0700 Subject: [PATCH] from wiki --- pages/NewVMonBKNIX.md | 211 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 pages/NewVMonBKNIX.md diff --git a/pages/NewVMonBKNIX.md b/pages/NewVMonBKNIX.md new file mode 100644 index 0000000..d0c29f6 --- /dev/null +++ b/pages/NewVMonBKNIX.md @@ -0,0 +1,211 @@ +# Creating a New VM Guest on the BKNIX Ganeti Cluster + +## Install Image Types + +Install the noop image type on all nodes in the cluster + +``` +echo 'deb http://repo.noc.grnet.gr/ wheezy main' > /etc/apt/sources.list.d/grnet.list +wget -O - http://repo.noc.grnet.gr/grnet.gpg.key | apt-key add - +apt-get update +apt-get install ganeti-os-noop +``` + +Now you can create instances a la + +``` +gnt-instance add -t plain -o noop +... +``` + +## Create the VM + +As I am lazy, I have a script to create a new VM guest + +``` +do-add nodeNum diskGB ramGB nameFQDN +``` + +This is the script as it is in vm0:~root + +``` +#!/bin/sh + +# do-add nodeNum diskGB ramGB nameFQDN + +DISK=$2 +RAM=$3 +NAME=$4 +NODE=vm$1.bknix.co.th + +gnt-instance add \ + -t plain \ + -o image+default \ + -s ${DISK}G \ + -B maxmem=${RAM}G,minmem=$((${RAM}/2))G \ + -n $NODE \ + -H kvm:vnc_bind_address=0.0.0.0 \ + --no-install \ + --no-start \ + --no-ip-check \ + --no-name-check \ + ${NAME} +``` + +## If You are Lazy and Just Want to Copy the Prototype + +Find the image of the source and target images + +``` +gnt-instance info proto.bknix.co.th | grep 'on prim' +gnt-instance info your.vm.name | grep 'on prim' +dd bs=1024k if=/dev/ganeti/f95c22fc-8061-4402-b276-193875fc6561.disk0 | ssh vm1.bknix.co.th dd of=/dev/ganeti/b295c26a-04a9-46be-a4b9-a5febfd29195.disk0 +``` + +You can then start your VM + +``` +gnt-instance start your.vm.name +``` + +Start a console + +``` +gnt-instance console your.vm.name +``` + +Configure the Network to the Correct IP, Gateway etc. + +``` +e /etc/network/interfaces +``` + +Fix the hostname + +``` +echo "foo.bknix.co.th" > /etc/hostname +hostname `cat /etc/hostname` +``` + +Reconfigure the mail system for the hostname and the correct IP address + +``` +dpkg-reconfigure exim4-config +``` + +Fix grub for something I forgot +``` + +### Find the Console Port of the Running VM + +``` +gnt-instance info your.vm.name | grep console +``` + +### Tunnel VNC over SSH + +From your laptop + +``` +ssh -N -L 5900:127.0.0.1: your.vm.name +``` + +I use a hack + +``` +do-link vnc vm0.bknix.co.th 11024 +``` + +### Run VNC to the Guest VM + +From your laptop, use a VNC client to connect to localhost, display 0, password as set for the VM host. + +### Do the Install + +It should have booted the CD-ROM. Now do the install of the OpSys in your usual fashion. + +When it finishes, if you just let it reboot, it will likely just boot the CD-ROM again. So restart the guest by + +``` +gnt-instance reboot your.vm.name +``` + +### Enable Serial Console + +It is also smart to enable the serial console in the guest so that the Ganeti host is able to + +``` +gnt-instance console your.vm.name +``` + +In FreeBSD, the hack is in /etc/ttys and the baud rate makes no difference. + +``` +ttyu0 "/usr/libexec/getty std.9600" vt100 on secure +``` + +### Install NTP + +[Install !NTP in the guest](https://wiki.rg.net/wiki/GuestNTP) + +## DRBD Mirror Guest to Cluster + +You will likely want the reliability of mirroring the guest to another node in the cluster. I have a script I use + +``` +#!/bin/sh +# do-drbd guest-name to-node +gnt-instance shutdown $1 +gnt-instance modify \ + -t drbd \ + --no-wait-for-sync \ + -n $2 \ + $1 +gnt-instance start $1 +``` \ No newline at end of file