From 949557fd43dab090671a884e8509dc0ec9bb0e60 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 24 Apr 2014 07:26:24 +0000 Subject: [PATCH] split master and storage node, support machines with dash in name git-svn-id: svn://svn.rot13.org/sysadmin-cookbook@316 191e9f34-6774-4a6d-acfc-7664dacd4a2a --- recepies/ganeti/migrate-lxc/0-ganeti.sh | 10 ++++++++++ recepies/ganeti/migrate-lxc/0-host.sh | 4 +++- recepies/ganeti/migrate-lxc/3-ganeti-root-lvm.sh | 15 +++++++-------- .../ganeti/migrate-lxc/5-lxc-rsync-snapshot.sh | 2 +- .../ganeti/migrate-lxc/7-lxc-stop-container.sh | 2 +- recepies/ganeti/migrate-lxc/A-ganeti-fix-root.sh | 14 +++++++------- .../migrate-lxc/B-ganeti-network-interfaces.sh | 6 +++--- recepies/ganeti/migrate-lxc/C-ganeti-swap.sh | 6 +++--- .../migrate-lxc/D-ganeti-create-instance.sh | 6 +++--- recepies/ganeti/migrate-lxc/I-acpi-restart.sh | 2 +- 10 files changed, 39 insertions(+), 28 deletions(-) diff --git a/recepies/ganeti/migrate-lxc/0-ganeti.sh b/recepies/ganeti/migrate-lxc/0-ganeti.sh index 226b6e9..4adf38e 100644 --- a/recepies/ganeti/migrate-lxc/0-ganeti.sh +++ b/recepies/ganeti/migrate-lxc/0-ganeti.sh @@ -5,6 +5,11 @@ #fi master=10.60.0.112 +storage=10.60.0.112 +storage_node=vmh12 + +storage=10.60.0.202 +storage_node=lib20 test -d ganeti || mkdir ganeti @@ -16,3 +21,8 @@ ssh_master() { ssh root@$master $* | tee ganeti/$log fi } + +ssh_storage() { + log=`basename $1` + ssh root@$storage $* | tee ganeti/$log +} diff --git a/recepies/ganeti/migrate-lxc/0-host.sh b/recepies/ganeti/migrate-lxc/0-host.sh index 878d7e2..eec8c7d 100644 --- a/recepies/ganeti/migrate-lxc/0-host.sh +++ b/recepies/ganeti/migrate-lxc/0-host.sh @@ -1,8 +1,10 @@ -export host_fqdn=narada.vbz.ffzg.hr +export host_fqdn=koha-dev.rot13.org test -z "$host" && host=`echo $host_fqdn | cut -d. -f1` export host test -d $host || mkdir $host +hostlv=`echo $host | sed 's/-/--/g'` + ssh_host() { log=`basename $1` ssh root@$host $* | tee $host/$log diff --git a/recepies/ganeti/migrate-lxc/3-ganeti-root-lvm.sh b/recepies/ganeti/migrate-lxc/3-ganeti-root-lvm.sh index ef2a995..ac6b97b 100755 --- a/recepies/ganeti/migrate-lxc/3-ganeti-root-lvm.sh +++ b/recepies/ganeti/migrate-lxc/3-ganeti-root-lvm.sh @@ -3,14 +3,13 @@ . ./0-host.sh . ./0-ganeti.sh +ssh_storage lvcreate --size `cat $host/size` --name $host ffzgvg +ssh_storage lvextend --size 4G /dev/mapper/ffzgvg-$hostlv -ssh_master lvcreate --size `cat $host/size` --name $host ffzgvg -ssh_master lvextend --size 4G /dev/mapper/ffzgvg-$host +ssh_storage parted -s /dev/mapper/ffzgvg-$hostlv 'mklabel msdos mkpart primary 0% 100% set 1 boot on' -ssh_master parted -s /dev/mapper/ffzgvg-$host 'mklabel msdos mkpart primary 0% 100% set 1 boot on' +ssh_storage mkfs.ext4 -L root /dev/mapper/ffzgvg-${hostlv}p1 -ssh_master mkfs.ext4 -L root /dev/mapper/ffzgvg-${host}p1 - -ssh_master mkdir /tmp/$host -ssh_master mount /dev/mapper/ffzgvg-${host}p1 /tmp/$host -ssh_master df -h /tmp/$host +ssh_storage mkdir /tmp/$host +ssh_storage mount /dev/mapper/ffzgvg-${hostlv}p1 /tmp/$host +ssh_storage df -h /tmp/$host diff --git a/recepies/ganeti/migrate-lxc/5-lxc-rsync-snapshot.sh b/recepies/ganeti/migrate-lxc/5-lxc-rsync-snapshot.sh index 1c28b40..54cb35f 100755 --- a/recepies/ganeti/migrate-lxc/5-lxc-rsync-snapshot.sh +++ b/recepies/ganeti/migrate-lxc/5-lxc-rsync-snapshot.sh @@ -4,4 +4,4 @@ . ./0-lxc.sh . ./0-ganeti.sh -ssh_lxc rsync -ravH --numeric-ids --sparse --delete --exclude /tmp --exclude /var/tmp /tmp/ganeti-$host/ $master:/tmp/$host/ +ssh_lxc rsync -ravH --numeric-ids --sparse --delete --exclude /tmp --exclude /var/tmp /tmp/ganeti-$host/ $storage:/tmp/$host/ diff --git a/recepies/ganeti/migrate-lxc/7-lxc-stop-container.sh b/recepies/ganeti/migrate-lxc/7-lxc-stop-container.sh index 317d324..b6de545 100755 --- a/recepies/ganeti/migrate-lxc/7-lxc-stop-container.sh +++ b/recepies/ganeti/migrate-lxc/7-lxc-stop-container.sh @@ -8,4 +8,4 @@ ssh_lxc /etc/init.d/lxc-watchdog stop $host ssh_lxc rm -v /var/lib/lxc/$host/on_boot -ssh_lxc rsync -ravH --numeric-ids --sparse --delete --exclude /tmp --exclude /var/tmp /mnt/$host/ $master:/tmp/$host/ +ssh_lxc rsync -ravH --numeric-ids --sparse --delete --exclude /tmp --exclude /var/tmp /mnt/$host/ $storage:/tmp/$host/ diff --git a/recepies/ganeti/migrate-lxc/A-ganeti-fix-root.sh b/recepies/ganeti/migrate-lxc/A-ganeti-fix-root.sh index 2c4c4ae..7961bdc 100755 --- a/recepies/ganeti/migrate-lxc/A-ganeti-fix-root.sh +++ b/recepies/ganeti/migrate-lxc/A-ganeti-fix-root.sh @@ -3,15 +3,15 @@ . ./0-host.sh . ./0-ganeti.sh -ssh_master ls -d /tmp/$host/rootfs > $host/rootfs_boot +ssh_storage ls -d /tmp/$host/rootfs > $host/rootfs_boot if [ -s $host/rootfs_boot ] ; then - ssh_master mv /tmp/$host/rootfs/* /tmp/$host/ - ssh_master mv /tmp/$host/rootfs/.?* /tmp/$host/ - ssh_master rmdir /tmp/$host/rootfs + ssh_storage mv /tmp/$host/rootfs/* /tmp/$host/ + ssh_storage mv /tmp/$host/rootfs/.?* /tmp/$host/ + ssh_storage rmdir /tmp/$host/rootfs fi -ssh_master mkdir -p /tmp/$host/lib/modules -ssh_master cp -ra /lib/modules/3.2.0-4-amd64 /tmp/$host/lib/modules +ssh_storage mkdir -p /tmp/$host/lib/modules +ssh_storage cp -ra /lib/modules/3.2.0-4-amd64 /tmp/$host/lib/modules -ssh_master chroot /tmp/$host apt-get install --reinstall -y initscripts acpid +ssh_storage chroot /tmp/$host apt-get install --reinstall -y initscripts acpid diff --git a/recepies/ganeti/migrate-lxc/B-ganeti-network-interfaces.sh b/recepies/ganeti/migrate-lxc/B-ganeti-network-interfaces.sh index cfedad7..7a7794c 100755 --- a/recepies/ganeti/migrate-lxc/B-ganeti-network-interfaces.sh +++ b/recepies/ganeti/migrate-lxc/B-ganeti-network-interfaces.sh @@ -24,8 +24,8 @@ iface eth1 inet static __INTERFACES__ # this will backup file on original machine which is still running! -ping -c 1 $host && ssh_master chroot /tmp/$host bak add,commit /etc/network/interfaces +ping -c 1 $host && ssh_storage chroot /tmp/$host bak add,commit /etc/network/interfaces -scp /tmp/network-interfaces-$host root@$master:/tmp/ +scp /tmp/network-interfaces-$host root@$storage:/tmp/ -ssh_master mv -v /tmp/network-interfaces-$host /tmp/$host/etc/network/interfaces +ssh_storage mv -v /tmp/network-interfaces-$host /tmp/$host/etc/network/interfaces diff --git a/recepies/ganeti/migrate-lxc/C-ganeti-swap.sh b/recepies/ganeti/migrate-lxc/C-ganeti-swap.sh index b3783d2..a5b9148 100755 --- a/recepies/ganeti/migrate-lxc/C-ganeti-swap.sh +++ b/recepies/ganeti/migrate-lxc/C-ganeti-swap.sh @@ -3,8 +3,8 @@ . ./0-host.sh . ./0-ganeti.sh -ssh_master lvcreate -L 1G -n $host-swap ffzgvg +ssh_storage lvcreate -L 1G -n $host-swap ffzgvg -ssh_master parted -s /dev/mapper/ffzgvg-$host--swap 'mklabel msdos mkpartfs primary linux-swap 0% 100%' +ssh_storage parted -s /dev/mapper/ffzgvg-$hostlv--swap 'mklabel msdos mkpartfs primary linux-swap 0% 100%' -ssh_master dmsetup remove ffzgvg-${host}--swapp1 +ssh_storage dmsetup remove ffzgvg-${hostlv}--swapp1 diff --git a/recepies/ganeti/migrate-lxc/D-ganeti-create-instance.sh b/recepies/ganeti/migrate-lxc/D-ganeti-create-instance.sh index 7a52ec5..8507a6b 100755 --- a/recepies/ganeti/migrate-lxc/D-ganeti-create-instance.sh +++ b/recepies/ganeti/migrate-lxc/D-ganeti-create-instance.sh @@ -4,9 +4,9 @@ . ./0-lxc.sh . ./0-ganeti.sh -ssh_master umount /tmp/$host +ssh_storage umount /tmp/$host -ssh_master dmsetup remove ffzgvg-${host}p1 +ssh_storage dmsetup remove ffzgvg-${hostlv}p1 -ssh_master gnt-instance add -H kvm:kernel_path=/boot/vmlinuz-3.2-kvmU,initrd_path=/boot/initrd.img-3.2-kvmU -B maxmem=1G,minmem=1G,vcpus=2 -t plain -n vmh12 -o debootstrap+default --disk 0:adopt=$host --disk 1:adopt=$host-swap --no-start --no-ip-check --no-name-check $host_fqdn +ssh_master gnt-instance add -H kvm:kernel_path=/boot/vmlinuz-3.2-kvmU,initrd_path=/boot/initrd.img-3.2-kvmU -B maxmem=1G,minmem=1G,vcpus=2 -t plain -n $storage_node -o debootstrap+default --disk 0:adopt=$host --disk 1:adopt=$host-swap --no-start --no-ip-check --no-name-check $host_fqdn diff --git a/recepies/ganeti/migrate-lxc/I-acpi-restart.sh b/recepies/ganeti/migrate-lxc/I-acpi-restart.sh index 7f35fb4..e901a25 100755 --- a/recepies/ganeti/migrate-lxc/I-acpi-restart.sh +++ b/recepies/ganeti/migrate-lxc/I-acpi-restart.sh @@ -2,7 +2,7 @@ . ./0-host.sh -#ssh_host apt-get install --reinstall -y initscripts acpid +ssh_host apt-get install --reinstall -y initscripts acpid ssh_host /etc/init.d/acpid restart ssh_host lsmod | grep button ssh_host tail -2 /var/log/messages -- 2.20.1