Merge branch 'master' of github.com:ffzg/gnt-info
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 23 Oct 2019 07:21:54 +0000 (09:21 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 23 Oct 2019 07:21:54 +0000 (09:21 +0200)
13 files changed:
doc/2019-04-25-update.txt [new file with mode: 0644]
doc/2019-08-25-mudrac-lvm.txt [new file with mode: 0644]
doc/ipxe-boot.txt [new file with mode: 0644]
doc/rbd-showmapped-p.diff [new file with mode: 0644]
doc/win10-kvm-virtio.txt [new file with mode: 0644]
drbd-find-stuck-slaves.sh [new file with mode: 0755]
gnt-instance-kernel.sh
gnt-kill-instance.sh [new file with mode: 0755]
gnt-lv-snap-rsync.sh
gnt-running.sh
gnt-tcpdump.sh [new file with mode: 0755]
hooks/grub [new file with mode: 0755]
smart-megaraid.sh

diff --git a/doc/2019-04-25-update.txt b/doc/2019-04-25-update.txt
new file mode 100644 (file)
index 0000000..d00f3d0
--- /dev/null
@@ -0,0 +1,10 @@
+applied rbd-showmapped-p.diff to remove errors:
+
+Thu Apr 25 09:20:23 2019   - ERROR: instance odin.ffzg.hr: couldn't retrieve status for disk/0 on r1u32.gnt.ffzg.hr: rbd showmapped failed (exited with exit code 1): rbd: unrecognised option '-p'\n
+Thu Apr 25 09:20:23 2019   - ERROR: instance odin.ffzg.hr: couldn't retrieve status for disk/1 on r1u32.gnt.ffzg.hr: rbd showmapped failed (exited with exit code 1): rbd: unrecognised option '-p'\n
+Thu Apr 25 09:20:23 2019   - ERROR: instance gray: couldn't retrieve status for disk/0 on r1u32.gnt.ffzg.hr: rbd showmapped failed (exited with exit code 1): rbd: unrecognised option '-p'\n
+
+root@r1u30:/home/dpavlin# gnt-cluster renew-crypto --new-cluster-certificate --new-rapi-certificate --new-spice-certifi
+cate
+
+
diff --git a/doc/2019-08-25-mudrac-lvm.txt b/doc/2019-08-25-mudrac-lvm.txt
new file mode 100644 (file)
index 0000000..bc9634c
--- /dev/null
@@ -0,0 +1,64 @@
+# export rootfs
+
+root@r1u28:/mnt/mudrac# rbd export rbd/f734a9d5-0c81-4840-a798-951941f597da.rbd.disk3 mudrac-disk3.img
+
+root@r1u28:~# lvcreate -L 21G -n mudrac-root oscarvg
+  Logical volume "mudrac-root" created.
+
+root@r1u28:~# losetup -f /dev/oscarvg/mudrac-root
+root@r1u28:~# losetup
+NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE         DIO
+/dev/loop1         0      0         0  0 /dev/dm-72          0
+/dev/loop0         0      0         1  0 /dev/shm/test.img   0
+
+fdisk /dev/loop1
+# create partitions for rootfs so we can later use grub to boot this machine
+
+root@r1u28:~# kpartx -a -v /dev/loop1
+
+root@r1u28:~# dd if=/mnt/mudrac/mudrac-disk3.img of=/dev/mapper/loop1p1 bs=1M
+
+root@r1u28:~# kpartx -d -v /dev/loop1
+del devmap : loop1p1
+
+root@r1u28:~# losetup -d /dev/loop1
+
+root@r1u28:~# mount /dev/oscarvg/mudrac-root /tmp/mudrac-root/ -o offset=`expr 512 \* 2048`
+
+modified:
+
+/etc/fstab
+/etc/network/intrafeces
+
+
+
+# export home
+
+rbd export rbd/214e17fa-22e4-490d-9ef7-d07d666f6ddf.rbd.disk1 /mnt/mudrac/home.img
+
+root@r1u28:~# ls -alh /mnt/mudrac/*.img
+-rw-r--r-- 1 root root 3.4T Aug 25 07:32 /mnt/mudrac/home.img
+-rw-r--r-- 1 root root  20G Aug 25 05:43 /mnt/mudrac/mudrac-disk3.img
+
+root@r1u28:/dev/oscarvg# lvcreate -L 3.5T -n mudrac-home oscarvg
+
+root@r1u28:/mnt/mudrac# dd if=home.img of=/dev/oscarvg/mudrac-home bs=10M
+
+3702261809152 bytes (3.7 TB, 3.4 TiB) copied, 34196 s, 108 MB/s
+
+
+better way would be to dump data directly into lvm with something like:
+
+rbd export -rbd-concurrent-management-ops 20 rbd/214e17fa-22e4-490d-9ef7-d07d666f6ddf.rbd.disk1 - | pv | dd of=/dev/oscarvg/mudrac-home bs=4M
+
+default for -rbd-concurrent-management-ops is 10
+
+
+
+# add instance to ganeti
+
+
+gnt-instance add -B maxmem=4G,vcpus=4 -t plain -n r1u28 -o debootstrap+default  --disk 0:adopt=mudrac-root --disk 1:adopt=mudrac-home --net 0:link=br0002 --net 1:link=br1010 --no-name-check --no-ip-check --no-start mudrac2
+
+gnt-instance modify -t drbd -n r1u30 --no-wait-for-sync mudrac2
+
diff --git a/doc/ipxe-boot.txt b/doc/ipxe-boot.txt
new file mode 100644 (file)
index 0000000..5d5ad88
--- /dev/null
@@ -0,0 +1,60 @@
+
+How to create machine which will boot clonezilla from pxe:
+
+Create lv for future disk
+
+root@r1u32:~# lvcreate -L 30G -n cz2 oscarvg
+WARNING: ext4 signature detected on /dev/oscarvg/cz2 at offset 1080. Wipe it? [y/n]: y
+  Wiping ext4 signature on /dev/oscarvg/cz2.
+  Logical volume "cz2" created.
+
+
+root@r1u32:~# gnt-instance add -B maxmem=2G,vcpus=4 -t plain -n r1u32 -o snf-image+default --os-parameters=img_format=diskdump,img_id=windows2k3,img_properties='{"OSFAMILY":"windows"}' --disk 0:adopt=cz2 --net 0:link=br0063 --no-name-check --no-ip-check --no-start k-cz2
+Wed May  1 15:48:33 2019 * disk 0, size 30.0G
+Wed May  1 15:48:33 2019 adding instance k-cz2 to cluster config
+Wed May  1 15:48:33 2019 adding disks to cluster config
+Wed May  1 15:48:34 2019  - INFO: Waiting for instance k-cz2 to sync disks
+Wed May  1 15:48:34 2019  - INFO: Instance k-cz2's disks are in sync
+Wed May  1 15:48:34 2019  - INFO: Waiting for instance k-cz2 to sync disks
+Wed May  1 15:48:34 2019  - INFO: Instance k-cz2's disks are in sync
+
+root@r1u32:~# gnt-instance modify -H initrd_path=,kernel_path=,boot_order=network k-cz2
+Modified instance k-cz2
+ - hv/kernel_path ->
+ - hv/initrd_path ->
+ - hv/boot_order -> network
+Please don't forget that most parameters take effect only at the next (re)start of the instance initiated by ganeti; restarting from within the instance will not be enough.
+Note that changing hypervisor parameters without performing a restart might lead to a crash while performing a live migration. This will be addressed in future Ganeti versions.
+
+Find mac of new machine:
+
+root@r1u32:~# gnt-instance info k-cz2 | grep MAC
+      MAC: aa:00:00:29:da:96
+
+
+Now you will need to configure booting for mac adress of that machine:
+
+root@dns01:~# vi /etc/dhcp/conf4.d/lib-pub.conf 
+
+subclass "lib-pub-unknown" 1:aa:00:00:29:da:96; # k-cz2 test on oscar ganeti
+
+        host k-cz2 {
+            hardware ethernet aa:00:00:29:da:96; 
+            allow booting;
+            next-server 10.60.4.9;
+            filename "pxelinux.0";
+        }
+
+
+Restart dhcpd to pickup configuration:
+
+root@dns01:~# /etc/init.d/isc-dhcp-server reload
+
+Start machine or rebootit:
+
+root@r1u32:/srv/gnt-info# socat - /var/run/ganeti/kvm-hypervisor/ctrl/k-cz2.monitor
+QEMU 2.8.1 monitor - type 'help' for more information
+(qemu) system_reset
+system_reset
+
+
diff --git a/doc/rbd-showmapped-p.diff b/doc/rbd-showmapped-p.diff
new file mode 100644 (file)
index 0000000..c596949
--- /dev/null
@@ -0,0 +1,20 @@
+--- /usr/share/ganeti/2.15/ganeti/storage/bdev.py.orig 2018-09-08 19:22:03.000000000 +0200
++++ /usr/share/ganeti/2.15/ganeti/storage/bdev.py      2019-04-25 09:16:12.708023721 +0200
+@@ -1020,8 +1020,6 @@
+       showmap_cmd = [
+         constants.RBD_CMD,
+         "showmapped",
+-        "-p",
+-        pool,
+         "--format",
+         "json"
+         ]
+@@ -1036,7 +1034,7 @@
+     except RbdShowmappedJsonError:
+       # For older versions of rbd, we have to parse the plain / text output
+       # manually.
+-      showmap_cmd = [constants.RBD_CMD, "showmapped", "-p", pool]
++      showmap_cmd = [constants.RBD_CMD, "showmapped"]
+       result = utils.RunCmd(showmap_cmd)
+       if result.failed:
+         base.ThrowError("rbd showmapped failed (%s): %s",
diff --git a/doc/win10-kvm-virtio.txt b/doc/win10-kvm-virtio.txt
new file mode 100644 (file)
index 0000000..78d41ce
--- /dev/null
@@ -0,0 +1,21 @@
+Boot machine using kvm -hda to select disk as ide
+
+drvload e:\viostor\w10\x86\viostor.inf
+
+# I can't find drvload on my windows 10 install -- dpavlin
+
+dism /image:f:\ /add-driver /driver:e:\viostor\w10\x86\viostor.inf
+
+
+After installing virtio drivers on ide disk, you have to force safemode boot
+
+search, cmd.exe, run as administrator:
+
+bcdedit /set {current} safeboot minimal
+
+
+Showdown machine and reboot this time using virtio drivers.
+
+disable safeboot:
+
+bcdedit /deletevalue {current} safeboot
diff --git a/drbd-find-stuck-slaves.sh b/drbd-find-stuck-slaves.sh
new file mode 100755 (executable)
index 0000000..1b9fd80
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cat /proc/drbd | grep cs:WFConnection | cut -d: -f1 | tr -d ' ' | sed 's/^/drbd/' > /dev/shm/drbd.WFConnection
+ls -l /var/run/ganeti/instance-disks/ | grep -f /dev/shm/drbd.WFConnection
index ee740da..0af3fb6 100755 (executable)
@@ -1,8 +1,16 @@
 #!/bin/sh -xe
 
-KERNEL=3.16
+test -z "$KERNEL" || KERNEL=4.9
 #KERNEL=3.10
 #KERNEL=3.2
 
-gnt-instance modify -H initrd_path=/boot/initrd.img-$KERNEL-kvmU,kernel_path=/boot/vmlinuz-$KERNEL-kvmU $1
+ver=$( ls /boot/config*-4.9* | sort --field-separator="-" --key=5 --reverse | head -1 | cut -d- -f2- )
+
+tar cfvpz /tmp/$ver.tar.gz /lib/modules/$ver
+ls -al /tmp/$ver.tar.gz
+
+#gnt-instance modify -H initrd_path=/boot/initrd.img-$ver,kernel_path=/boot/vmlinuz-$ver $1
+#gnt-instance modify -H kernel_args="ro net.ifnames=0 biosdevname=0" influx # keep old eth0 names
+gnt-instance modify -H initrd_path=/boot/initrd.img-$ver,kernel_path=/boot/vmlinuz-$ver,kernel_args="ro net.ifnames=0 biosdevname=0" $1
+
 
diff --git a/gnt-kill-instance.sh b/gnt-kill-instance.sh
new file mode 100755 (executable)
index 0000000..d6b5e4b
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh -xe
+
+instance=$1
+test -z "$instance" && echo "Usage:$0 instance [0|intefrace]" && exit 1
+
+on_node=`gnt-instance list --no-header -o pnode $instance`
+pid=`ssh $on_node cat /var/run/ganeti/kvm-hypervisor/pid/$instance || exit 1`
+ssh $on_node "kill -9 $pid"
index 9928924..f00b08f 100755 (executable)
@@ -3,6 +3,7 @@
 instance=$1
 disk=$2
 test -z "$backup" && backup="backup"
+test -z "$rsync_server" && rsync_server="lib15"
 
 if [ "$1" = '-' ] ; then
        read instance disk
@@ -29,7 +30,7 @@ ssh $node lvs -o name,tags | grep $instance | tee /dev/shm/$instace.$node.lvs |
        echo "# $lv | $origin | $disk_nr"
 
        rsync_args=""
-       if rsync lib15::$backup/$instance/rsync.args /dev/shm/$instance-rsync.args 2>/dev/null; then
+       if rsync $rsync_server::$backup/$instance/rsync.args /dev/shm/$instance-rsync.args 2>/dev/null; then
                rsync_args="`cat /dev/shm/$instance-rsync.args`"
        fi
 
@@ -44,7 +45,7 @@ cat <<__SHELL__ > /dev/shm/$instance.sh
        test ! -z "\$offset" && offset=",offset=\$offset"
        mount /dev/$vg/$lv.snap /dev/shm/$lv.snap -o noatime\$offset
 
-       rsync -ravHzXA --inplace --numeric-ids --delete $rsync_args /dev/shm/$lv.snap/ lib15::$backup/$instance/$disk_nr/
+       rsync -ravHzXA --inplace --numeric-ids --delete $rsync_args /dev/shm/$lv.snap/ $rsync_server::$backup/$instance/$disk_nr/
 
        umount /dev/shm/$lv.snap
 
@@ -58,8 +59,8 @@ __SHELL__
 
        ssh $node sh -xe /dev/shm/$instance.sh
 
-       # execute zfs snap on lib15 via ssh command="" wrapper
-       ssh -i /etc/ganeti/id_dsa-zfs-snap lib15 lib15/$backup/$instance/$disk_nr
+       # execute zfs snap on $rsync_server via ssh command="" wrapper
+       ssh -i /etc/ganeti/id_dsa-zfs-snap $rsync_server $rsync_server/$backup/$instance/$disk_nr
 done
 
 if [ $found_lvm = 0 ] ; then
index 97e51d6..415fabb 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh -e
 while true ; do
-  JOBID=`gnt-job list --no-headers --running | tee /dev/stderr | awk '{ print $1; exit }'`
+  JOBID=`gnt-job list --no-headers --running | tee /dev/stderr | grep -v GROUP_VERIFY_DISKS | awk '{ print $1; exit }'`
   if [ -n "$JOBID" ]
   then
        gnt-job watch $JOBID || true # don't exit on failed jobs
diff --git a/gnt-tcpdump.sh b/gnt-tcpdump.sh
new file mode 100755 (executable)
index 0000000..55649d7
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh -xe
+
+instance=$1
+test -z "$instance" && echo "Usage:$0 instance [0|intefrace]" && exit 1
+interface=$2
+test -z "$interface" && interface=0
+
+on_node=`gnt-instance list --no-header -o pnode $instance`
+mac=`gnt-instance info --static $instance | grep MAC: | awk -v nr=$interface 'BEGIN { line=0 } { if ( line == nr ) { print $2 } line = line + 1 }'`
+tap=`ssh $on_node cat /var/run/ganeti/kvm-hypervisor/nic/$instance/$interface || exit 1`
+ssh $on_node "tcpdump -i $tap -v ether host $mac"
diff --git a/hooks/grub b/hooks/grub
new file mode 100755 (executable)
index 0000000..fc29325
--- /dev/null
@@ -0,0 +1,105 @@
+#!/bin/bash -x
+#
+# This is an example script that install and configure grub after installation.
+# To use it put it in your CUSTOMIZE_DIR and make it executable.
+#
+# Do not include grub in EXTRA_PKGS of
+# $sysconfdir/default/ganeti-instance-debootstrap because it will
+# cause error of debootstrap.
+#
+# based on https://groups.google.com/forum/#!searchin/ganeti/debootstrap|sort:date/ganeti/N8_r8lKoA-k/8ExYRnPUAQAJ
+
+set -e
+
+# On wheezy we debootstrap with extlinux instead of grub
+if [ $SUITE = "wheezy" ]; then
+    exit 0
+fi
+
+. common.sh
+
+CLEANUP=( )
+
+trap cleanup EXIT
+
+if [ -z "$TARGET" -o ! -d "$TARGET" ]; then
+  echo "Missing target directory"
+  exit 1
+fi
+
+if [[ $BLOCKDEV == /dev/drbd* ]]; then
+    DISKTYPE=drbd
+elif dmsetup info $BLOCKDEV > /dev/null 2>&1; then
+    DISKTYPE=lvm
+else
+    echo "Unknown disk type"
+    #exit 1
+    DISKTYPE=unknown
+fi
+
+mount -o bind /dev $TARGET/dev
+CLEANUP+=("umount $TARGET/dev")
+
+mount -t proc proc $TARGET/proc
+CLEANUP+=("umount $TARGET/proc")
+
+# For some reason, /dev/disk/by-uuid/<UUID> is not created. This results in
+# grub refusing to specify the root fs uuid on the commandline, instead it
+# will use $ROOTDEV which is not available in the VM...
+ROOTUUID=$(blkid -o value -s UUID $FSYSDEV)
+#ln -s $FSYSDEV /dev/disk/by-uuid/$ROOTUUID
+CLEANUP+=("rm /dev/disk/by-uuid/$ROOTUUID")
+
+chroot "$TARGET" apt-get update
+chroot "$TARGET" /usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install grub2
+
+# install grub to make all the modules available ... serial.mod is not available otherwise
+chroot "$TARGET" update-grub
+
+case $DISKTYPE in
+    lvm)
+
+        # When using LVM, grub thinks we're installing to a partition. Using a loop dev fools it
+        LODEV=$(losetup --show -f $BLOCKDEV)
+        CLEANUP+=("losetup -d $LODEV")
+
+
+        # BLOCKDEV has the format /dev/<vgname>/<lvname>, but Grub will be looking
+        # for /dev/mapper/<vgname>-<mangled-lvname> ...
+        # This adds the mapper device to device.map, which is used to translate
+        # the root device node into grub-syntax (i.e., (hd0))
+
+        MAPPERDEV=/dev/mapper/$(dmsetup info -C --noheadings -o name $BLOCKDEV)
+        echo "(hd0) $MAPPERDEV" > $TARGET/boot/grub/device.map
+        chroot "$TARGET" grub-install --no-floppy $LODEV
+        ;;
+    *)
+        chroot "$TARGET" grub-install --no-floppy $BLOCKDEV
+        ;;
+esac
+
+cat >> $TARGET/etc/default/grub <<EOF
+GRUB_CMDLINE_LINUX="text console=ttyS0,115200n8"
+GRUB_TERMINAL=serial
+GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
+EOF
+
+# and do it again, serial.mod should now be available
+chroot "$TARGET" update-grub
+
+case $DISKTYPE in
+    lvm)
+        chroot "$TARGET" grub-install $LODEV
+        ;;
+    *)
+        chroot "$TARGET" grub-install $BLOCKDEV
+        ;;
+esac
+
+# For some reason, the loopback device is still busy/open if this sleep is removed ...
+sleep 2
+
+# execute cleanups
+cleanup
+trap - EXIT
+
index 1e976f4..35db0c9 100755 (executable)
@@ -4,7 +4,7 @@
 # smart-megaraid.sh '^# 1'             # default without args
 # SMART="-t long" smart-megaraid.sh    # execute smart command
 
-pattern='(^# [1-2]|test remaining|Hours|Error|Serial|Model|Firmware|Load)'
+pattern='(^# [1-2]|test remaining|Hours|Error|Serial|Model|Firmware|Load|Reallocated|Pending|failure)'
 test ! -z "$1" && pattern=$*
 
 did_megaraid=0
@@ -31,4 +31,4 @@ lsblk --noheadings --scsi -o name | while read drive ; do
        fi
 done
 
-egrep "$pattern" /dev/shm/smart.* | grep -v -- '-  *0$' | cut -d. -f2- | sed -e 's/:/\t/'
+egrep -i "$pattern" /dev/shm/smart.* | grep -v -- '-  *0$' | cut -d. -f2- | sed -e 's/:/\t/'