install less stuff
[mirror/dsa-wiki.git] / input / howto / install-ganeti.creole
1 == How To Install Ganeti Clusters and Instances ==
2
3 === suppositions ===
4
5 Suppose that there are two identical hosts: foo.debian.org and bar.debian.org.
6
7 They are running squeeze and have been integrated into Debian infrastructure.
8
9 They will serve as nodes in a ganeti cluster named foobar.debian.org.
10
11 They have a RAID1 array exposing three partitions: c0d0p1 for /, c0d0p2 for
12 swap and c0d0p3 for lvm volume groups to be used by ganeti via drbd.
13
14 They have two network interfaces: eth0 (public) and eth1 (private).
15
16 The public network is A.B.C.0/24 with gateway A.B.C.254.
17
18 The private network is E.F.G.0/24 with no gateway.
19
20 Suppose that the first instance to be hosted on foobar.debian.org is
21 qux.debian.org.
22
23 The following DNS records exist:
24
25 {{{
26     foobar.debian.org.                  IN A   A.B.C.1
27     foo.debian.org.                     IN A   A.B.C.2
28     bar.debian.org.                     IN A   A.B.C.3
29     qux.debian.org.                     IN A   A.B.C.4
30     foo.debprivate-hoster.debian.org.   IN A   E.F.G.2
31     bar.debprivate-hoster.debian.org.   IN A   E.F.G.3
32 }}}
33
34 === install required packages ===
35
36 On each node, install the required packages:
37
38 {{{
39     # maybe: apt-get install drbd8-utils
40     # maybe: apt-get install ganeti-instance-debootstrap
41     apt-get install ganeti2 ganeti-htools qemu-kvm
42 }}}
43
44 === configure kernel modules ===
45
46 On each node, ensure that the required kernel modules are loaded at boot:
47
48 {{{
49     ainsl /etc/modules 'drbd minor_count=255 usermode_helper=/bin/true'
50     ainsl /etc/modules 'hmac'
51     ainsl /etc/modules 'tun'
52     ainsl /etc/modules 'ext3'
53     ainsl /etc/modules 'ext4'
54 }}}
55
56 === configure networking ===
57
58 On each node, ensure that br0 (not eth0) and eth1 are configured.
59
60 The bridge interface, br0, is used by the guest virtual machines to reach the
61 public network.
62
63 If the guest virtual machines need to access the private network, then br1
64 should be configured rather than eth1.
65
66 To prevent the link address changing due to startup/shutdown of virtual
67 machines, explicitly set the value.
68
69 This is the interfaces file for foo.debian.org:
70
71 {{{
72     auto br0
73     iface br0 inet static
74       bridge_ports eth0
75       bridge_maxwait 0
76       bridge_fd 0
77       address A.B.C.2
78       netmask 255.255.255.0
79       gateway A.B.C.254
80       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
81
82     auto eth1
83     iface eth1 inet static
84       address E.F.G.2
85       netmask 255.255.255.0
86 }}}
87
88 This is the interfaces file for bar.debian.org:
89
90 {{{
91     auto br0
92     iface br0 inet static
93       bridge_ports eth0
94       bridge_maxwait 0
95       bridge_fd 0
96       address A.B.C.3
97       netmask 255.255.255.0
98       gateway A.B.C.254
99       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
100
101     auto eth1
102     iface eth1 inet static
103       address E.F.G.3
104       netmask 255.255.255.0
105 }}}
106
107 === configure lvm ===
108
109 On each node, configure lvm to ignore drbd devices and to prefer
110 {{{/dev/cciss}}} devices names over {{{/dev/block}}} device names
111 ([[http://code.google.com/p/ganeti/issues/detail?id=93|why?]]):
112
113 {{{
114     ssed -i \
115       -e 's#^\(\s*filter\s\).*#\1= [ "a|.*|", "r|/dev/drbd[0-9]+|" ]#' \
116       -e 's#^\(\s*preferred_names\s\).*#\1= [ "^/dev/dm-*/", "^/dev/cciss/" ]#' \
117       /etc/lvm/lvm.conf
118     service lvm2 restart
119 }}}
120
121 === create lvm volume groups ===
122
123 On each node, create a volume group:
124
125 {{{
126     vgcreate vg_ganeti /dev/cciss/c0d0p3
127 }}}
128
129 === exchange ssh keys ===
130
131 on each node:
132
133 {{{
134    mkdir -m 0700 -p /root/.ssh &&
135    ln -s /etc/ssh/ssh_host_rsa_key /root/.ssh/id_rsa
136 }}}
137
138 === configure iptables (via ferm) ===
139
140 the nodes must connect to each other over the public and private networks for a number of reasons; see the ganeti2 module in puppet
141
142 === instantiate the cluster ===
143
144 On the master node (foo) only:
145
146 {{{
147     gnt-cluster init \
148       --master-netdev br0 \
149       --vg-name vg_ganeti \
150       --secondary-ip E.F.G.2 \
151       --enabled-hypervisors kvm \
152       --nic-parameters link=br0 \
153       --mac-prefix 00:16:37 \
154       --no-ssh-init \
155       --no-etc-hosts \
156       --hypervisor-parameters kvm:initrd_path=,kernel_path= \
157       foobar.debian.org
158 }}}
159
160 Note the following:
161
162 * the master network device is set to br0, matching the public network bridge interface created above
163 * the volume group is set to vg_ganeti, matching the volume group created above
164 * the secondary IP address is set to the value of the master node's interface on the private network
165 * the nic parameters for instances is set to use br0 as default bridge
166 * the MAC prefix is registered in the dsa-kvm git repo
167
168 === add slave nodes ===
169
170 For each slave node (only bar for this example):
171
172 on the slave, append the master's /etc/ssh/ssh_host_rsa_key.pub to
173 /etc/ssh/userkeys/root.  This is only required temporarily - once
174 everything works, puppet will put it/keep it there.
175
176 on the master node (foo):
177
178 {{{
179     gnt-node add \
180       --secondary-ip E.F.G.3 \
181       --no-ssh-key-check \
182       --no-node-setup \
183       bar.debian.org
184 }}}
185
186 Note the following:
187
188 * the secondary IP address is set to the value of the slave node's interface on the private network
189
190 === verify cluster ===
191
192 On the master node (foo):
193
194 {{{
195     gnt-cluster verify
196 }}}
197
198 If everything has been configured correctly, no errors should be reported.
199
200 === create the 'dsa' variant ===
201
202 Ensure that the debootstrap+dsa variant has been installed by puppet (see ganeti2 module in dsa-puppet).
203
204 ----
205
206 == How To Install Ganeti Instances ==
207
208 Suppose that qux.debian.org will be an instance (a virtual machine) hosted on
209 the foobar.debian.org ganeti cluster.
210
211 Before adding the instance, an LDAP entry must be created so that an A record
212 for the instance (A.B.C.4) exists.
213
214 === create the instance ===
215
216 On the master node (foo):
217
218 {{{
219     gnt-instance add \
220       --node foo:bar \
221       --disk-template drbd \
222       --os-size 4GiB \
223       --os-type debootstrap+dsa \
224       --hypervisor-parameters kvm:initrd_path=,kernel_path= \
225       --net 0:ip=A.B.C.4 \
226       qux.debian.org
227 }}}
228
229 Note the following:
230
231 * the primary and secondary nodes have been explicitly set
232 * the operating system type is 'debootstrap+dsa'
233 * the network interfarce 0 (eth0 on the system) is set to the instance's interface on the public network
234 * If qux.d.o does not yet exist in DNS/LDAP, you may need --no-ip-check --no-name-check.  Be careful that the hostname and IP address are not taken already!
235
236 ----
237
238 == Variations ==
239
240 If the instances require access to the private network, then there are two modifications necessary.
241
242 === re-configure networking ===
243
244 On the nodes, ensure that br1 is configured (rather than eth1).
245
246 This is the interfaces file for foo.debian.org:
247
248 {{{
249     auto br0
250     iface br0 inet static
251       bridge_ports eth0
252       bridge_maxwait 0
253       bridge_fd 0
254       address A.B.C.2
255       netmask 255.255.255.0
256       gateway A.B.C.254
257       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
258
259     auto br1
260     iface br1 inet static
261       bridge_ports eth1
262       bridge_maxwait 0
263       bridge_fd 0
264       address E.F.G.2
265       netmask 255.255.255.0
266       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
267 }}}
268
269 This is the interfaces file for bar.debian.org:
270
271 {{{
272     auto br0
273     iface br0 inet static
274       bridge_ports eth0
275       bridge_maxwait 0
276       bridge_fd 0
277       address A.B.C.3
278       netmask 255.255.255.0
279       gateway A.B.C.254
280       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
281
282     auto br1
283     iface br1 inet static
284       bridge_ports eth1
285       bridge_maxwait 0
286       bridge_fd 0
287       address E.F.G.3
288       netmask 255.255.255.0
289       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
290 }}}
291
292 === create or update the instance  ===
293
294 When creating the instance, indicate both networks:
295
296 {{{
297     gnt-instance add \
298       --node foo:bar \
299       --disk-template drbd \
300       --os-size 4GiB \
301       --os-type debootstrap+dsa \
302       --hypervisor-parameters kvm:initrd_path=,kernel_path= \
303       --net 0:ip=A.B.C.4 \
304       --net 1:link=br1,ip=E.F.G.4 \
305       qux.debian.org
306 }}}
307
308 * If qux.d.o does not yet exist in DNS/LDAP, you may need --no-ip-check --no-name-check.  Be careful that the hostname and IP address are not taken already!
309
310 When updating an existing instance, add the interface:
311
312 {{{
313     gnt-instance shutdown qux.debian.org
314     gnt-instance modify \
315       --net add:link=br1,ip=E.F.G.4 \
316       qux.debian.org
317     gnt-instance startup qux.debian.org
318 }}}
319
320 Please note that the hook scripts are run only at instance instantiation.  When
321 adding interfaces to an instance, the guest opearting system must be updated
322 manually.
323
324
325 * If you are importing an instance from libvirt with LVM setup, you can adopt LVs:
326
327 {{{
328     gnt-instance add -t plain --os-type debootstrap+dsa-wheezy \
329       --disk 0:adopt=lully-boot \
330       --disk 1:adopt=lully-root \
331       --disk 2:adopt=lully-swap \
332       --disk 3:adopt=lully-log  \
333       --hypervisor-parameters kvm:initrd_path=,kernel_path= \
334       --net 0:ip=82.195.75.99 -n clementi.debian.org  lully.debian.org
335 }}}
336
337 And you want to convert it to use DRBD afterwards and start it on the other cluster node, so we can ensure that DRBD is correctly working.
338 {{{
339     gnt-instance shutdown lully.debian.org
340     gnt-instance modify -t drbd -n czerny.debian.org lully.debian.org
341     gnt-instance failover lully.debian.org
342     gnt-instance startup lully.debian.org
343 }}}
344
345 * Some instances NEED ide instead of virtio
346
347 {{{
348     gnt-instance modify --hypervisor-parameters disk_type=ide fils.debian.org
349 }}}
350
351 * To import instances with SAN volumes
352
353 {{{
354     gnt-instance add -t blockdev --os-type debootstrap+dsa \
355       --disk 0:adopt=/dev/disk/by-id/scsi-reger-boot \
356       --disk 1:adopt=/dev/disk/by-id/scsi-reger-root \
357       --hypervisor-parameters kvm:initrd_path=,kernel_path= \
358       --net 0:ip=206.12.19.124 -n rossini.debian.org reger.debian.org
359 }}}
360
361 * How to add new LUNs to Bytemark Cluster
362
363 {{{
364   + Add a new LUN in the MSA and export it to all blades
365
366   then:
367   gnt-cluster command "echo 1 > /sys/bus/pci/devices/0000:0e:00.0/cciss0/rescan"
368   
369   then:
370   reload multipath-tools on gnt-master (normaly bm-bl1):
371   service multipath-tools reload
372   add the WWNs to dsa-puppet/modules/multipath/files/bm-multipath.conf and define the alias and commit that file to git.
373
374   then:
375   gnt-cluster command "puppet agent -t"
376
377   This will update the multipath config on all cluster nodes. WITHOUT doing this, you can't migrate VMs between nodes.
378 }}}