6e4d9101e67c4b14aa04b68ff3506a808c1d460f
[mirror/dsa-wiki.git] / input / howto / move-a-vm.mdwn
1 # Move a VM from one cluster to another
2
3 * set `dnsTTL` to 30 in ldap for adayevskaya
4 * on the target create a new LV to accept the instance
5     ```
6     lvcreate -n install-adayevskaya -L 5g vg_ganeti
7     ```
8 * on the source, shut down the instance
9     ```
10     gnt-instance shutdown adayevskaya.debian.orgĀ·
11     ```
12 * give the source host ssh access to the target:
13   * `cat /etc/ssh/ssh_host_rsa_key.pub`
14   * `tee -a /etc/ssh/userkeys/root`
15   * `iptables -I INPUT -s bm-bl1 -j ACCEPT`
16 * copy it over:
17     ```
18     cat /dev/mapper/adayevskaya | ssh root@manda-node03 'cat > /dev/vg_ganeti/install-adayevskaya'
19     # pidof cat, and cat /proc/<pid>/fdinfo/[01]  to check on progress
20     ```
21 * clean up ssh and the firewall again:
22     ```
23     puppet agent -t
24     ferm -i /etc/ferm/ferm.conf
25     ```
26 * resize partitions if the new block device is larger using `fdisk`.  Delete and create the partition at the same starting position.
27 * open the partition table:
28     ```
29     kpartx -a -v -p -part /dev/vg_ganeti/install-adayevskaya
30     ```
31 * fsck the filesystem if required, resize if necessary
32     ```
33     fsck.ext4 /dev/mapper/vg_ganeti-install--adayevskaya-part1
34     resize2fs /dev/mapper/vg_ganeti-install--adayevskaya-part1
35     ```
36 * mount the partition and fix etc/network/interfaces:
37     ```
38     mkdir /mnt/target-adayevskaya
39     mount /dev/mapper/vg_ganeti-install--adayevskaya-part1 /mnt/target-adayevskaya
40     cd /mnt/target-adayevskaya
41     vi etc/hosts etc/network/interfaces
42     cd /
43     umount /mnt/target-adayevskaya
44     rmdir /mnt/target-adayevskaya
45
46     ```
47 * remove partitions
48     ```
49     kpartx -d -v -p -part /dev/vg_ganeti/install-adayevskaya
50     ```
51 * create the instance, adopting the block device
52     ```
53     gnt-instance add \
54       --no-ip-check \
55       --no-name-check \
56       -t blockdev \
57       --no-start \
58       -t plain \
59       --disk=0:adopt=install-adayevskaya \
60       --backend-parameters memory=2g,vcpus=2 \
61       --os-type noop \
62       -n manda-node03 \
63       adayevskaya.debian.org
64
65     gnt-instance modify \
66       --disk-template drbd \
67       -n manda-node04.debian.org \
68       adayevskaya.debian.org
69     ```
70 * start the instance, check everything works
71     ```
72     gnt-instance start adayevskaya.debian.org
73     gnt-instance console adayevskaya.debian.org
74     ```
75 * update ud-ldap (ip addresses, physicalHost, sponsor, location, dnsTTL) and ud-generate
76 * ud-replicate on denis
77 * check puppet and ssh authkeys on all hosts for the old IP address
78 * update nagios
79 * remove the instance on the old cluster, remove volumes from puppet/multipath/storage arrays
80