47ead839e8f95afede8d648bcb023fd3700787d7
[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 -t squeeze-backports drbd8-utils ganeti2 ganeti-instance-debootstrap ganeti-htools
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 === create kvmU symbolic links ===
128
129 On each node, create vmlinuz and initrd symlinks as expected by the kvm
130 hypervisor (not strictly required if all guests will boot from their own
131 kernels):
132
133 {{{
134     ln -s -T /boot/vmlinuz-2.6.32-5-amd64 /boot/vmlinuz-2.6-kvmU
135     ln -s -T /boot/initrd.img-2.6.32-5-amd64 /boot/initrd.img-2.6-kvmU
136 }}}
137
138 === exchange ssh keys ===
139
140 on each node:
141
142 {{{
143    mkdir -m 0700 -p /root/.ssh &&
144    ln -s /etc/ssh/ssh_host_rsa_key /root/.ssh/id_rsa
145 }}}
146
147 === configure iptables (via ferm) ===
148
149 the nodes must connect to each other over the public and private networks for a number of reasons; see the ganeti2 module in puppet
150
151 === instantiate the cluster ===
152
153 On the master node (foo) only:
154
155 {{{
156     gnt-cluster init \
157       --master-netdev br0 \
158       --vg-name vg_ganeti \
159       --secondary-ip E.F.G.2 \
160       --enabled-hypervisors kvm \
161       --nic-parameters link=br0 \
162       --mac-prefix 00:16:37 \
163       --no-ssh-init \
164       --no-etc-hosts \
165       --hypervisor-parameters kvm:initrd_path=/boot/initrd.img-2.6-kvmU,kernel_path=/boot/vmlinuz-2.6-kvmU \
166       foobar.debian.org
167 }}}
168
169 Note the following:
170
171 * the master network device is set to br0, matching the public network bridge interface created above
172 * the volume group is set to vg_ganeti, matching the volume group created above
173 * the secondary IP address is set to the value of the master node's interface on the private network
174 * the nic parameters for instances is set to use br0 as default bridge
175 * the MAC prefix is registered in the dsa-kvm git repo
176
177 === add slave nodes ===
178
179 For each slave node (only bar for this example):
180
181 on the slave, append the master's /etc/ssh/ssh_host_rsa_key.pub to
182 /etc/ssh/userkeys/root.  This is only required temporarily - once
183 everything works, puppet will put it/keep it there.
184
185 on the master node (foo):
186
187 {{{
188     gnt-node add \
189       --secondary-ip E.F.G.3 \
190       --no-ssh-key-check \
191       --no-node-setup \
192       bar.debian.org
193 }}}
194
195 Note the following:
196
197 * the secondary IP address is set to the value of the slave node's interface on the private network
198
199 === verify cluster ===
200
201 On the master node (foo):
202
203 {{{
204     gnt-cluster verify
205 }}}
206
207 If everything has been configured correctly, no errors should be reported.
208
209 === create the 'dsa' variant ===
210
211 Ensure that the debootstrap+dsa variant has been installed by puppet (see ganeti2 module in dsa-puppet).
212
213 ----
214
215 == How To Install Ganeti Instances ==
216
217 Suppose that qux.debian.org will be an instance (a virtual machine) hosted on
218 the foobar.debian.org ganeti cluster.
219
220 Before adding the instance, an LDAP entry must be created so that an A record
221 for the instance (A.B.C.4) exists.
222
223 === create the instance ===
224
225 On the master node (foo):
226
227 {{{
228     gnt-instance add \
229       --node foo:bar \
230       --disk-template drbd \
231       --os-size 4GiB \
232       --os-type debootstrap+dsa \
233       --hypervisor-parameters kvm:initrd_path=,kernel_path= \
234       --net 0:ip=A.B.C.4 \
235       qux.debian.org
236 }}}
237
238 Note the following:
239
240 * the primary and secondary nodes have been explicitly set
241 * the operating system type is 'debootstrap+dsa'
242 * the network interfarce 0 (eth0 on the system) is set to the instance's interface on the public network
243 * 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!
244
245 ----
246
247 == Variations ==
248
249 If the instances require access to the private network, then there are two modifications necessary.
250
251 === re-configure networking ===
252
253 On the nodes, ensure that br1 is configured (rather than eth1).
254
255 This is the interfaces file for foo.debian.org:
256
257 {{{
258     auto br0
259     iface br0 inet static
260       bridge_ports eth0
261       bridge_maxwait 0
262       bridge_fd 0
263       address A.B.C.2
264       netmask 255.255.255.0
265       gateway A.B.C.254
266       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
267
268     auto br1
269     iface br1 inet static
270       bridge_ports eth1
271       bridge_maxwait 0
272       bridge_fd 0
273       address E.F.G.2
274       netmask 255.255.255.0
275       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
276 }}}
277
278 This is the interfaces file for bar.debian.org:
279
280 {{{
281     auto br0
282     iface br0 inet static
283       bridge_ports eth0
284       bridge_maxwait 0
285       bridge_fd 0
286       address A.B.C.3
287       netmask 255.255.255.0
288       gateway A.B.C.254
289       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
290
291     auto br1
292     iface br1 inet static
293       bridge_ports eth1
294       bridge_maxwait 0
295       bridge_fd 0
296       address E.F.G.3
297       netmask 255.255.255.0
298       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
299 }}}
300
301 === create or update the instance  ===
302
303 When creating the instance, indicate both networks:
304
305 {{{
306     gnt-instance add \
307       --node foo:bar \
308       --disk-template drbd \
309       --os-size 4GiB \
310       --os-type debootstrap+dsa \
311       --hypervisor-parameters kvm:initrd_path=,kernel_path= \
312       --net 0:ip=A.B.C.4 \
313       --net 1:link=br1,ip=E.F.G.4 \
314       qux.debian.org
315 }}}
316
317 * 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!
318
319 When updating an existing instance, add the interface:
320
321 {{{
322     gnt-instance shutdown qux.debian.org
323     gnt-instance modify \
324       --net add:link=br1,ip=E.F.G.4 \
325       qux.debian.org
326     gnt-instance startup qux.debian.org
327 }}}
328
329 Please note that the hook scripts are run only at instance instantiation.  When
330 adding interfaces to an instance, the guest opearting system must be updated
331 manually.
332