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