acd4125e0261e55a81a51fe4d72934ea4cb23fb1
[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 }}}
52
53 === configure networking ===
54
55 On each node, ensure that br0 (not eth0) and eth1 are configured.
56
57 The bridge interface, br0, is used by the guest virtual machines to reach the
58 public network.
59
60 If the guest virtual machines need to access the private network, then br1
61 should be configured rather than eth1.
62
63 To prevent the link address changing due to startup/shutdown of virtual
64 machines, explicitly set the value.
65
66 {{{
67     # /etc/networking/interfaces for foo.debian.org
68
69     auto br0
70     iface br0 inet static
71       bridge_ports eth0
72       bridge_maxwait 0
73       bridge_fd 0
74       address A.B.C.2
75       netmask 255.255.255.0
76       gateway A.B.C.254
77       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
78
79     auto eth1
80     iface eth1 inet static
81       address E.F.G.2
82       netmask 255.255.255.0
83 }}}
84
85 {{{
86     # /etc/networking/interfaces for bar.debian.org
87
88     auto br0
89     iface br0 inet static
90       bridge_ports eth0
91       bridge_maxwait 0
92       bridge_fd 0
93       address A.B.C.3
94       netmask 255.255.255.0
95       gateway A.B.C.254
96       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
97
98     auto eth1
99     iface eth1 inet static
100       address E.F.G.3
101       netmask 255.255.255.0
102 }}}
103
104 === configure lvm ===
105
106 On each node, configure lvm to ignore drbd devices and to prefer
107 {{{/dev/cciss}}} devices names over {{{/dev/block}}} device names
108 ([[http://code.google.com/p/ganeti/issues/detail?id=93|why?]]):
109
110 {{{
111     ssed -i \
112       -e 's#^\(\s*filter\s\).*#\1= [ "a|.*|", "r|/dev/drbd[0-9]+|" ]#' \
113       -e 's#^\(\s*preferred_names\s\).*#\1= [ "^/dev/dm-*/", "^/dev/cciss/" ]#' \
114       /etc/lvm/lvm.conf
115     service lvm2 restart
116 }}}
117
118 === create lvm volume groups ===
119
120 On each node, create a volume group:
121
122 {{{
123     vgcreate vg_ganeti /dev/cciss/c0d0p3
124 }}}
125
126 === create kvmU symbolic links ===
127
128 On each node, create vmlinuz and initrd symlinks as expected by the kvm
129 hypervisor (not strictly required if all guests will boot from their own
130 kernels):
131
132 {{{
133     ln -s -T /boot/vmlinuz-2.6.32-5-amd64 /boot/vmlinuz-2.6-kvmU
134     ln -s -T /boot/initrd.img-2.6.32-5-amd64 /boot/initrd.img-2.6-kvmU
135 }}}
136
137 === exchange ssh keys ===
138
139 on each node:
140
141 {{{
142    mkdir -m 0700 -p /root/.ssh &&
143    ln -s /etc/ssh/ssh_host_rsa_key /root/.ssh/id_rsa
144 }}}
145
146 === configure iptables (via ferm) ===
147
148 ipsum loren bacon puppet: the nodes must connect to each other over the private network for drbd purposes; puppet can handle this (poorly; needs improvement)
149
150 === instantiate the cluster ===
151
152 On the master node (foo) only:
153
154 {{{
155     gnt-cluster init \
156       --master-netdev br0 \
157       --vg-name vg_ganeti \
158       --secondary-ip E.F.G.2 \
159       --enabled-hypervisors kvm \
160       --nic-parameters link=br0 \
161       --mac-prefix 00:16:37 \
162       --no-ssh-init \
163       --no-etc-hosts \
164       --hypervisor-parameters kvm:initrd_path=/boot/initrd.img-2.6-kvmU,kernel_path=/boot/vmlinuz-2.6-kvmU \
165       foobar.debian.org
166 }}}
167
168 Note the following:
169
170 * the master network device is set to br0, matching the public network bridge interface created above
171 * the volume group is set to vg_ganeti, matching the volume group created above
172 * the secondary IP address is set to the value of the master node's interface on the private network
173 * the nic parameters for instances is set to use br0 as default bridge
174 * the MAC prefix is registered in the dsa-kvm git repo
175
176 === add slave nodes ===
177
178 For each slave node (only bar for this example):
179
180 on the slave, append the master's /etc/ssh/ssh_host_rsa_key.pub to
181 /etc/ssh/userkeys/root.  This is only required temporarily - once
182 everything works puppet will put it/keep it there.
183
184 on the master node (foo):
185
186 {{{
187     gnt-node add \
188       --secondary-ip E.F.G.3 \
189       --no-ssh-key-check \
190       --no-node-setup \
191       bar.debian.org
192 }}}
193
194 Note the following:
195
196 * the secondary IP address is set to the value of the slave node's interface on the private network
197
198 === verify cluster ===
199
200 On the master node (foo):
201
202 {{{
203     gnt-cluster verify
204 }}}
205
206 If everything has been configured correctly, no errors should be reported.
207
208 === create the 'dsa' variant ===
209
210 ipsum loren bacon deboostrap+dsa
211
212 * create /etc/ganeti/instance-debootstrap/variants/dsa.conf
213 * add 'dsa' to /etc/ganeti/instance-debootstrap/variants.list
214 * obtain ??-dsa-* from tristano:/etc/ganeti/instance-debootstrap/hooks
215
216 ----
217
218 == How To Install Ganeti Instances ==
219
220 Suppose that qux.debian.org will be an instance (a virtual machine) hosted on
221 the foobar.debian.org ganeti cluster.
222
223 Before adding the instance, an LDAP entry must be created so that an A record
224 for the instance (A.B.C.4) exists.
225
226 === create the instance ===
227
228 On the master node (foo):
229
230 {{{
231     gnt-instance add \
232       --node foo:bar \
233       --disk-template drbd \
234       --os-size 4GiB \
235       --os-type debootstrap+dsa \
236       --hypervisor-parameters kvm:initrd_path=,kernel_path= \
237       --net 0:ip=A.B.C.4 \
238       qux.debian.org
239 }}}
240
241 Note the following:
242
243 * the primary and secondary nodes have been explicitly set
244 * the operating system type is 'debootstrap+dsa'
245 * the network interfarce 0 (eth1 on the system) is set to the instance's interface on the public network
246
247 ----
248
249 == Variations ==
250
251 If the instances require access to the private network, then there are two modifications necessary.
252
253 === re-configure networking ===
254
255 Ensure that br1 is configured (rather than eth1).
256
257 {{{
258     # /etc/networking/interfaces for foo.debian.org
259
260     auto br0
261     iface br0 inet static
262       bridge_ports eth0
263       bridge_maxwait 0
264       bridge_fd 0
265       address A.B.C.2
266       netmask 255.255.255.0
267       gateway A.B.C.254
268       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
269
270     auto br1
271     iface br1 inet static
272       bridge_ports eth1
273       bridge_maxwait 0
274       bridge_fd 0
275       address E.F.G.2
276       netmask 255.255.255.0
277       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
278 }}}
279
280 === create or update the instance  ===
281
282 When creating the instance, indicate both netwokrs:
283
284 {{{
285     gnt-instance add \
286       --node foo:bar \
287       --disk-template drbd \
288       --os-size 4GiB \
289       --os-type debootstrap+dsa \
290       --hypervisor-parameters kvm:initrd_path=,kernel_path= \
291       --net 0:ip=A.B.C.4,1:ip=E.F.G.4 \
292       qux.debian.org
293 }}}
294
295 Please note that the dsa bootscript will only configure eth1 (nic0).  If
296 specifying a second internface, the guest operating system must be updated
297 manually.
298
299 When updating an existing instance, add the interface:
300
301 {{{
302     gnt-instance shutdown qux.debian.org
303     gnt-instance modify \
304       --net add:ip=E.F.G.4 \
305       qux.debian.org
306     gnt-instance startup qux.debian.org
307 }}}
308
309 Please note that the hook scripts are run only at instance instantiation.  When
310 adding interfaces to an instance, the guest opearting system must be updated
311 manually.
312