Statistics
| Branch: | Tag: | Revision:

root / doc / install.rst @ 18e2b6e4

History | View | Annotate | Download (23.7 kB)

1 28e15341 Iustin Pop
Ganeti installation tutorial
2 28e15341 Iustin Pop
============================
3 28e15341 Iustin Pop
4 fd07c6b3 Iustin Pop
Documents Ganeti version |version|
5 28e15341 Iustin Pop
6 28e15341 Iustin Pop
.. contents::
7 28e15341 Iustin Pop
8 c71a1a3d Iustin Pop
.. highlight:: text
9 c71a1a3d Iustin Pop
10 28e15341 Iustin Pop
Introduction
11 28e15341 Iustin Pop
------------
12 28e15341 Iustin Pop
13 28e15341 Iustin Pop
Ganeti is a cluster virtualization management system based on Xen or
14 c71a1a3d Iustin Pop
KVM. This document explains how to bootstrap a Ganeti node (Xen *dom0*,
15 c71a1a3d Iustin Pop
the host Linux system for KVM), create a running cluster and install
16 c71a1a3d Iustin Pop
virtual instances (Xen *domUs*, KVM guests).  You need to repeat most of
17 c71a1a3d Iustin Pop
the steps in this document for every node you want to install, but of
18 c71a1a3d Iustin Pop
course we recommend creating some semi-automatic procedure if you plan
19 c71a1a3d Iustin Pop
to deploy Ganeti on a medium/large scale.
20 28e15341 Iustin Pop
21 28e15341 Iustin Pop
A basic Ganeti terminology glossary is provided in the introductory
22 c71a1a3d Iustin Pop
section of the :doc:`admin`. Please refer to that document if you are
23 c71a1a3d Iustin Pop
uncertain about the terms we are using.
24 28e15341 Iustin Pop
25 c71a1a3d Iustin Pop
Ganeti has been developed for Linux and should be distribution-agnostic.
26 28e15341 Iustin Pop
This documentation will use Debian Lenny as an example system but the
27 c71a1a3d Iustin Pop
examples can be translated to any other distribution. You are expected
28 c71a1a3d Iustin Pop
to be familiar with your distribution, its package management system,
29 c71a1a3d Iustin Pop
and Xen or KVM before trying to use Ganeti.
30 28e15341 Iustin Pop
31 28e15341 Iustin Pop
This document is divided into two main sections:
32 28e15341 Iustin Pop
33 28e15341 Iustin Pop
- Installation of the base system and base components
34 28e15341 Iustin Pop
35 28e15341 Iustin Pop
- Configuration of the environment for Ganeti
36 28e15341 Iustin Pop
37 28e15341 Iustin Pop
Each of these is divided into sub-sections. While a full Ganeti system
38 c71a1a3d Iustin Pop
will need all of the steps specified, some are not strictly required for
39 c71a1a3d Iustin Pop
every environment. Which ones they are, and why, is specified in the
40 c71a1a3d Iustin Pop
corresponding sections.
41 28e15341 Iustin Pop
42 28e15341 Iustin Pop
Installing the base system and base components
43 28e15341 Iustin Pop
----------------------------------------------
44 28e15341 Iustin Pop
45 28e15341 Iustin Pop
Hardware requirements
46 28e15341 Iustin Pop
+++++++++++++++++++++
47 28e15341 Iustin Pop
48 c71a1a3d Iustin Pop
Any system supported by your Linux distribution is fine. 64-bit systems
49 c71a1a3d Iustin Pop
are better as they can support more memory.
50 28e15341 Iustin Pop
51 c71a1a3d Iustin Pop
Any disk drive recognized by Linux (``IDE``/``SCSI``/``SATA``/etc.) is
52 c71a1a3d Iustin Pop
supported in Ganeti. Note that no shared storage (e.g. ``SAN``) is
53 c71a1a3d Iustin Pop
needed to get high-availability features (but of course, one can be used
54 c71a1a3d Iustin Pop
to store the images). It is highly recommended to use more than one disk
55 c71a1a3d Iustin Pop
drive to improve speed. But Ganeti also works with one disk per machine.
56 28e15341 Iustin Pop
57 28e15341 Iustin Pop
Installing the base system
58 28e15341 Iustin Pop
++++++++++++++++++++++++++
59 28e15341 Iustin Pop
60 28e15341 Iustin Pop
**Mandatory** on all nodes.
61 28e15341 Iustin Pop
62 28e15341 Iustin Pop
It is advised to start with a clean, minimal install of the operating
63 c71a1a3d Iustin Pop
system. The only requirement you need to be aware of at this stage is to
64 c71a1a3d Iustin Pop
partition leaving enough space for a big (**minimum** 20GiB) LVM volume
65 c71a1a3d Iustin Pop
group which will then host your instance filesystems, if you want to use
66 c71a1a3d Iustin Pop
all Ganeti features. The volume group name Ganeti uses (by default) is
67 c71a1a3d Iustin Pop
``xenvg``.
68 28e15341 Iustin Pop
69 c71a1a3d Iustin Pop
You can also use file-based storage only, without LVM, but this setup is
70 c71a1a3d Iustin Pop
not detailed in this document.
71 28e15341 Iustin Pop
72 28e15341 Iustin Pop
While you can use an existing system, please note that the Ganeti
73 28e15341 Iustin Pop
installation is intrusive in terms of changes to the system
74 28e15341 Iustin Pop
configuration, and it's best to use a newly-installed system without
75 28e15341 Iustin Pop
important data on it.
76 28e15341 Iustin Pop
77 28e15341 Iustin Pop
Also, for best results, it's advised that the nodes have as much as
78 28e15341 Iustin Pop
possible the same hardware and software configuration. This will make
79 28e15341 Iustin Pop
administration much easier.
80 28e15341 Iustin Pop
81 28e15341 Iustin Pop
Hostname issues
82 28e15341 Iustin Pop
~~~~~~~~~~~~~~~
83 28e15341 Iustin Pop
84 28e15341 Iustin Pop
Note that Ganeti requires the hostnames of the systems (i.e. what the
85 28e15341 Iustin Pop
``hostname`` command outputs to be a fully-qualified name, not a short
86 28e15341 Iustin Pop
name. In other words, you should use *node1.example.com* as a hostname
87 28e15341 Iustin Pop
and not just *node1*.
88 28e15341 Iustin Pop
89 28e15341 Iustin Pop
.. admonition:: Debian
90 28e15341 Iustin Pop
91 28e15341 Iustin Pop
   Debian Lenny and Etch configures the hostname differently than you
92 28e15341 Iustin Pop
   need it for Ganeti. For example, this is what Etch puts in
93 28e15341 Iustin Pop
   ``/etc/hosts`` in certain situations::
94 28e15341 Iustin Pop
95 28e15341 Iustin Pop
     127.0.0.1       localhost
96 28e15341 Iustin Pop
     127.0.1.1       node1.example.com node1
97 28e15341 Iustin Pop
98 28e15341 Iustin Pop
   but for Ganeti you need to have::
99 28e15341 Iustin Pop
100 28e15341 Iustin Pop
     127.0.0.1       localhost
101 926feaf1 Manuel Franceschini
     192.0.2.1     node1.example.com node1
102 28e15341 Iustin Pop
103 926feaf1 Manuel Franceschini
   replacing ``192.0.2.1`` with your node's address. Also, the file
104 28e15341 Iustin Pop
   ``/etc/hostname`` which configures the hostname of the system
105 28e15341 Iustin Pop
   should contain ``node1.example.com`` and not just ``node1`` (you
106 28e15341 Iustin Pop
   need to run the command ``/etc/init.d/hostname.sh start`` after
107 28e15341 Iustin Pop
   changing the file).
108 28e15341 Iustin Pop
109 1232284c Guido Trotter
.. admonition:: Why a fully qualified host name
110 1232284c Guido Trotter
111 7faf5110 Michael Hanselmann
   Although most distributions use only the short name in the
112 7faf5110 Michael Hanselmann
   /etc/hostname file, we still think Ganeti nodes should use the full
113 7faf5110 Michael Hanselmann
   name. The reason for this is that calling 'hostname --fqdn' requires
114 7faf5110 Michael Hanselmann
   the resolver library to work and is a 'guess' via heuristics at what
115 7faf5110 Michael Hanselmann
   is your domain name. Since Ganeti can be used among other things to
116 7faf5110 Michael Hanselmann
   host DNS servers, we don't want to depend on them as much as
117 7faf5110 Michael Hanselmann
   possible, and we'd rather have the uname() syscall return the full
118 7faf5110 Michael Hanselmann
   node name.
119 7faf5110 Michael Hanselmann
120 7faf5110 Michael Hanselmann
   We haven't ever found any breakage in using a full hostname on a
121 7faf5110 Michael Hanselmann
   Linux system, and anyway we recommend to have only a minimal
122 7faf5110 Michael Hanselmann
   installation on Ganeti nodes, and to use instances (or other
123 7faf5110 Michael Hanselmann
   dedicated machines) to run the rest of your network services. By
124 7faf5110 Michael Hanselmann
   doing this you can change the /etc/hostname file to contain an FQDN
125 7faf5110 Michael Hanselmann
   without the fear of breaking anything unrelated.
126 1232284c Guido Trotter
127 1232284c Guido Trotter
128 756d5ec3 Guido Trotter
Installing The Hypervisor
129 756d5ec3 Guido Trotter
+++++++++++++++++++++++++
130 28e15341 Iustin Pop
131 28e15341 Iustin Pop
**Mandatory** on all nodes.
132 28e15341 Iustin Pop
133 756d5ec3 Guido Trotter
While Ganeti is developed with the ability to modularly run on different
134 7faf5110 Michael Hanselmann
virtualization environments in mind the only two currently useable on a
135 7faf5110 Michael Hanselmann
live system are Xen and KVM. Supported Xen versions are: 3.0.3, 3.0.4
136 7faf5110 Michael Hanselmann
and 3.1.  Supported KVM version are 72 and above.
137 28e15341 Iustin Pop
138 c71a1a3d Iustin Pop
Please follow your distribution's recommended way to install and set up
139 c71a1a3d Iustin Pop
Xen, or install Xen from the upstream source, if you wish, following
140 c71a1a3d Iustin Pop
their manual. For KVM, make sure you have a KVM-enabled kernel and the
141 c71a1a3d Iustin Pop
KVM tools.
142 28e15341 Iustin Pop
143 756d5ec3 Guido Trotter
After installing Xen, you need to reboot into your new system. On some
144 7faf5110 Michael Hanselmann
distributions this might involve configuring GRUB appropriately, whereas
145 7faf5110 Michael Hanselmann
others will configure it automatically when you install the respective
146 7faf5110 Michael Hanselmann
kernels. For KVM no reboot should be necessary.
147 28e15341 Iustin Pop
148 756d5ec3 Guido Trotter
.. admonition:: Xen on Debian
149 28e15341 Iustin Pop
150 c71a1a3d Iustin Pop
   Under Lenny or Etch you can install the relevant ``xen-linux-system``
151 c71a1a3d Iustin Pop
   package, which will pull in both the hypervisor and the relevant
152 c71a1a3d Iustin Pop
   kernel. Also, if you are installing a 32-bit Lenny/Etch, you should
153 c71a1a3d Iustin Pop
   install the ``libc6-xen`` package (run ``apt-get install
154 c71a1a3d Iustin Pop
   libc6-xen``).
155 28e15341 Iustin Pop
156 28e15341 Iustin Pop
Xen settings
157 28e15341 Iustin Pop
~~~~~~~~~~~~
158 28e15341 Iustin Pop
159 28e15341 Iustin Pop
It's recommended that dom0 is restricted to a low amount of memory
160 c71a1a3d Iustin Pop
(512MiB or 1GiB is reasonable) and that memory ballooning is disabled in
161 c71a1a3d Iustin Pop
the file ``/etc/xen/xend-config.sxp`` by setting the value
162 c71a1a3d Iustin Pop
``dom0-min-mem`` to 0, like this::
163 28e15341 Iustin Pop
164 28e15341 Iustin Pop
  (dom0-min-mem 0)
165 28e15341 Iustin Pop
166 28e15341 Iustin Pop
For optimum performance when running both CPU and I/O intensive
167 c71a1a3d Iustin Pop
instances, it's also recommended that the dom0 is restricted to one CPU
168 c71a1a3d Iustin Pop
only, for example by booting with the kernel parameter ``nosmp``.
169 28e15341 Iustin Pop
170 28e15341 Iustin Pop
It is recommended that you disable xen's automatic save of virtual
171 28e15341 Iustin Pop
machines at system shutdown and subsequent restore of them at reboot.
172 28e15341 Iustin Pop
To obtain this make sure the variable ``XENDOMAINS_SAVE`` in the file
173 28e15341 Iustin Pop
``/etc/default/xendomains`` is set to an empty value.
174 28e15341 Iustin Pop
175 aeaa2ea2 Guido Trotter
If you want to use live migration make sure you have, in the xen config
176 aeaa2ea2 Guido Trotter
file, something that allows the nodes to migrate instances between each
177 aeaa2ea2 Guido Trotter
other. For example::
178 8ab90d80 Guido Trotter
179 8ab90d80 Guido Trotter
  (xend-relocation-server yes)
180 8ab90d80 Guido Trotter
  (xend-relocation-port 8002)
181 8ab90d80 Guido Trotter
  (xend-relocation-address '')
182 926feaf1 Manuel Franceschini
  (xend-relocation-hosts-allow '^192\\.0\\.2\\.[0-9]+$')
183 8ab90d80 Guido Trotter
184 e8a3bf18 Iustin Pop
185 e8a3bf18 Iustin Pop
The second line assumess that the hypervisor parameter
186 e8a3bf18 Iustin Pop
``migration_port`` is set 8002, otherwise modify it to match. The last
187 e8a3bf18 Iustin Pop
line assumes that all your nodes have secondary IPs in the
188 926feaf1 Manuel Franceschini
192.0.2.0/24 network, adjust it accordingly to your setup.
189 8ab90d80 Guido Trotter
190 28e15341 Iustin Pop
.. admonition:: Debian
191 28e15341 Iustin Pop
192 28e15341 Iustin Pop
   Besides the ballooning change which you need to set in
193 28e15341 Iustin Pop
   ``/etc/xen/xend-config.sxp``, you need to set the memory and nosmp
194 28e15341 Iustin Pop
   parameters in the file ``/boot/grub/menu.lst``. You need to modify
195 28e15341 Iustin Pop
   the variable ``xenhopt`` to add ``dom0_mem=1024M`` like this::
196 28e15341 Iustin Pop
197 28e15341 Iustin Pop
     ## Xen hypervisor options to use with the default Xen boot option
198 28e15341 Iustin Pop
     # xenhopt=dom0_mem=1024M
199 28e15341 Iustin Pop
200 c71a1a3d Iustin Pop
   and the ``xenkopt`` needs to include the ``nosmp`` option like this::
201 28e15341 Iustin Pop
202 28e15341 Iustin Pop
     ## Xen Linux kernel options to use with the default Xen boot option
203 28e15341 Iustin Pop
     # xenkopt=nosmp
204 28e15341 Iustin Pop
205 28e15341 Iustin Pop
   Any existing parameters can be left in place: it's ok to have
206 28e15341 Iustin Pop
   ``xenkopt=console=tty0 nosmp``, for example. After modifying the
207 28e15341 Iustin Pop
   files, you need to run::
208 28e15341 Iustin Pop
209 28e15341 Iustin Pop
     /sbin/update-grub
210 28e15341 Iustin Pop
211 c71a1a3d Iustin Pop
If you want to run HVM instances too with Ganeti and want VNC access to
212 c71a1a3d Iustin Pop
the console of your instances, set the following two entries in
213 28e15341 Iustin Pop
``/etc/xen/xend-config.sxp``::
214 28e15341 Iustin Pop
215 28e15341 Iustin Pop
  (vnc-listen '0.0.0.0') (vncpasswd '')
216 28e15341 Iustin Pop
217 28e15341 Iustin Pop
You need to restart the Xen daemon for these settings to take effect::
218 28e15341 Iustin Pop
219 28e15341 Iustin Pop
  /etc/init.d/xend restart
220 28e15341 Iustin Pop
221 28e15341 Iustin Pop
Selecting the instance kernel
222 28e15341 Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223 28e15341 Iustin Pop
224 28e15341 Iustin Pop
After you have installed Xen, you need to tell Ganeti exactly what
225 c71a1a3d Iustin Pop
kernel to use for the instances it will create. This is done by creating
226 c71a1a3d Iustin Pop
a symlink from your actual kernel to ``/boot/vmlinuz-2.6-xenU``, and one
227 c71a1a3d Iustin Pop
from your initrd to ``/boot/initrd-2.6-xenU`` [#defkernel]_. Note that
228 c71a1a3d Iustin Pop
if you don't use an initrd for the domU kernel, you don't need to create
229 c71a1a3d Iustin Pop
the initrd symlink.
230 28e15341 Iustin Pop
231 28e15341 Iustin Pop
.. admonition:: Debian
232 28e15341 Iustin Pop
233 28e15341 Iustin Pop
   After installation of the ``xen-linux-system`` package, you need to
234 28e15341 Iustin Pop
   run (replace the exact version number with the one you have)::
235 28e15341 Iustin Pop
236 28e15341 Iustin Pop
     cd /boot
237 28e15341 Iustin Pop
     ln -s vmlinuz-2.6.26-1-xen-amd64 vmlinuz-2.6-xenU
238 28e15341 Iustin Pop
     ln -s initrd.img-2.6.26-1-xen-amd64 initrd-2.6-xenU
239 28e15341 Iustin Pop
240 28e15341 Iustin Pop
Installing DRBD
241 28e15341 Iustin Pop
+++++++++++++++
242 28e15341 Iustin Pop
243 c71a1a3d Iustin Pop
Recommended on all nodes: DRBD_ is required if you want to use the high
244 c71a1a3d Iustin Pop
availability (HA) features of Ganeti, but optional if you don't require
245 c71a1a3d Iustin Pop
them or only run Ganeti on single-node clusters. You can upgrade a
246 c71a1a3d Iustin Pop
non-HA cluster to an HA one later, but you might need to export and
247 28e15341 Iustin Pop
re-import all your instances to take advantage of the new features.
248 28e15341 Iustin Pop
249 28e15341 Iustin Pop
.. _DRBD: http://www.drbd.org/
250 28e15341 Iustin Pop
251 c71a1a3d Iustin Pop
Supported DRBD versions: 8.0+. It's recommended to have at least version
252 c71a1a3d Iustin Pop
8.0.12. Note that for version 8.2 and newer it is needed to pass the
253 c71a1a3d Iustin Pop
``usermode_helper=/bin/true`` parameter to the module, either by
254 c71a1a3d Iustin Pop
configuring ``/etc/modules`` or when inserting it manually.
255 28e15341 Iustin Pop
256 28e15341 Iustin Pop
Now the bad news: unless your distribution already provides it
257 c71a1a3d Iustin Pop
installing DRBD might involve recompiling your kernel or anyway fiddling
258 c71a1a3d Iustin Pop
with it. Hopefully at least the Xen-ified kernel source to start from
259 c71a1a3d Iustin Pop
will be provided (if you intend to use Xen).
260 28e15341 Iustin Pop
261 28e15341 Iustin Pop
The good news is that you don't need to configure DRBD at all. Ganeti
262 c71a1a3d Iustin Pop
will do it for you for every instance you set up.  If you have the DRBD
263 c71a1a3d Iustin Pop
utils installed and the module in your kernel you're fine. Please check
264 c71a1a3d Iustin Pop
that your system is configured to load the module at every boot, and
265 c71a1a3d Iustin Pop
that it passes the following option to the module:
266 c71a1a3d Iustin Pop
``minor_count=NUMBER``. We recommend that you use 128 as the value of
267 c71a1a3d Iustin Pop
the minor_count - this will allow you to use up to 64 instances in total
268 c71a1a3d Iustin Pop
per node (both primary and secondary, when using only one disk per
269 c71a1a3d Iustin Pop
instance). You can increase the number up to 255 if you need more
270 c71a1a3d Iustin Pop
instances on a node.
271 c71a1a3d Iustin Pop
272 28e15341 Iustin Pop
273 28e15341 Iustin Pop
.. admonition:: Debian
274 28e15341 Iustin Pop
275 c71a1a3d Iustin Pop
   On Debian, you can just install (build) the DRBD module with the
276 c71a1a3d Iustin Pop
   following commands, making sure you are running the target (Xen or
277 c71a1a3d Iustin Pop
   KVM) kernel::
278 28e15341 Iustin Pop
279 28e15341 Iustin Pop
     apt-get install drbd8-source drbd8-utils
280 28e15341 Iustin Pop
     m-a update
281 28e15341 Iustin Pop
     m-a a-i drbd8
282 c71a1a3d Iustin Pop
     echo drbd minor_count=128 usermode_helper=/bin/true >> /etc/modules
283 28e15341 Iustin Pop
     depmod -a
284 c71a1a3d Iustin Pop
     modprobe drbd minor_count=128 usermode_helper=/bin/true
285 28e15341 Iustin Pop
286 c71a1a3d Iustin Pop
   It is also recommended that you comment out the default resources in
287 c71a1a3d Iustin Pop
   the ``/etc/drbd.conf`` file, so that the init script doesn't try to
288 c71a1a3d Iustin Pop
   configure any drbd devices. You can do this by prefixing all
289 28e15341 Iustin Pop
   *resource* lines in the file with the keyword *skip*, like this::
290 28e15341 Iustin Pop
291 92c1ea55 Iustin Pop
     skip {
292 92c1ea55 Iustin Pop
       resource r0 {
293 92c1ea55 Iustin Pop
         ...
294 92c1ea55 Iustin Pop
       }
295 28e15341 Iustin Pop
     }
296 28e15341 Iustin Pop
297 92c1ea55 Iustin Pop
     skip {
298 92c1ea55 Iustin Pop
       resource "r1" {
299 92c1ea55 Iustin Pop
         ...
300 92c1ea55 Iustin Pop
       }
301 28e15341 Iustin Pop
     }
302 28e15341 Iustin Pop
303 28e15341 Iustin Pop
Other required software
304 28e15341 Iustin Pop
+++++++++++++++++++++++
305 28e15341 Iustin Pop
306 cbf3d64b Michael Hanselmann
See :doc:`install-quick`.
307 28e15341 Iustin Pop
308 28e15341 Iustin Pop
Setting up the environment for Ganeti
309 28e15341 Iustin Pop
-------------------------------------
310 28e15341 Iustin Pop
311 28e15341 Iustin Pop
Configuring the network
312 28e15341 Iustin Pop
+++++++++++++++++++++++
313 28e15341 Iustin Pop
314 28e15341 Iustin Pop
**Mandatory** on all nodes.
315 28e15341 Iustin Pop
316 7faf5110 Michael Hanselmann
You can run Ganeti either in "bridge mode" or in "routed mode". In
317 7faf5110 Michael Hanselmann
bridge mode, the default, the instances network interfaces will be
318 7faf5110 Michael Hanselmann
attached to a software bridge running in dom0. Xen by default creates
319 7faf5110 Michael Hanselmann
such a bridge at startup, but your distribution might have a different
320 7faf5110 Michael Hanselmann
way to do things, and you'll definitely need to manually set it up under
321 7faf5110 Michael Hanselmann
KVM.
322 28e15341 Iustin Pop
323 c71a1a3d Iustin Pop
Beware that the default name Ganeti uses is ``xen-br0`` (which was used
324 e721c742 Guido Trotter
in Xen 2.0) while Xen 3.0 uses ``xenbr0`` by default. See the
325 e721c742 Guido Trotter
`Initializing the cluster`_ section to learn how to choose a different
326 e721c742 Guido Trotter
bridge, or not to use one at all and use "routed mode".
327 28e15341 Iustin Pop
328 e721c742 Guido Trotter
In order to use "routed mode" under Xen, you'll need to change the
329 7faf5110 Michael Hanselmann
relevant parameters in the Xen config file. Under KVM instead, no config
330 7faf5110 Michael Hanselmann
change is necessary, but you still need to set up your network
331 7faf5110 Michael Hanselmann
interfaces correctly.
332 9f83899a Guido Trotter
333 9f83899a Guido Trotter
By default, under KVM, the "link" parameter you specify per-nic will
334 7faf5110 Michael Hanselmann
represent, if non-empty, a different routing table name or number to use
335 7faf5110 Michael Hanselmann
for your instances. This allows insulation between different instance
336 7faf5110 Michael Hanselmann
groups, and different routing policies between node traffic and instance
337 7faf5110 Michael Hanselmann
traffic.
338 9f83899a Guido Trotter
339 7faf5110 Michael Hanselmann
You will need to configure your routing table basic routes and rules
340 7faf5110 Michael Hanselmann
outside of ganeti. The vif scripts will only add /32 routes to your
341 7faf5110 Michael Hanselmann
instances, through their interface, in the table you specified (under
342 7faf5110 Michael Hanselmann
KVM, and in the main table under Xen).
343 9f83899a Guido Trotter
344 9f83899a Guido Trotter
.. admonition:: Bridging under Debian
345 28e15341 Iustin Pop
346 28e15341 Iustin Pop
   The recommended way to configure the Xen bridge is to edit your
347 28e15341 Iustin Pop
   ``/etc/network/interfaces`` file and substitute your normal
348 28e15341 Iustin Pop
   Ethernet stanza with the following snippet::
349 28e15341 Iustin Pop
350 28e15341 Iustin Pop
     auto xen-br0
351 28e15341 Iustin Pop
     iface xen-br0 inet static
352 28e15341 Iustin Pop
        address YOUR_IP_ADDRESS
353 28e15341 Iustin Pop
        netmask YOUR_NETMASK
354 28e15341 Iustin Pop
        network YOUR_NETWORK
355 28e15341 Iustin Pop
        broadcast YOUR_BROADCAST_ADDRESS
356 28e15341 Iustin Pop
        gateway YOUR_GATEWAY
357 28e15341 Iustin Pop
        bridge_ports eth0
358 28e15341 Iustin Pop
        bridge_stp off
359 28e15341 Iustin Pop
        bridge_fd 0
360 28e15341 Iustin Pop
361 28e15341 Iustin Pop
The following commands need to be executed on the local console:
362 28e15341 Iustin Pop
363 28e15341 Iustin Pop
  ifdown eth0
364 28e15341 Iustin Pop
  ifup xen-br0
365 28e15341 Iustin Pop
366 28e15341 Iustin Pop
To check if the bridge is setup, use the ``ip`` and ``brctl show``
367 28e15341 Iustin Pop
commands::
368 28e15341 Iustin Pop
369 28e15341 Iustin Pop
  # ip a show xen-br0
370 28e15341 Iustin Pop
  9: xen-br0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc noqueue
371 28e15341 Iustin Pop
      link/ether 00:20:fc:1e:d5:5d brd ff:ff:ff:ff:ff:ff
372 28e15341 Iustin Pop
      inet 10.1.1.200/24 brd 10.1.1.255 scope global xen-br0
373 28e15341 Iustin Pop
      inet6 fe80::220:fcff:fe1e:d55d/64 scope link
374 28e15341 Iustin Pop
         valid_lft forever preferred_lft forever
375 28e15341 Iustin Pop
376 28e15341 Iustin Pop
  # brctl show xen-br0
377 28e15341 Iustin Pop
  bridge name     bridge id               STP enabled     interfaces
378 28e15341 Iustin Pop
  xen-br0         8000.0020fc1ed55d       no              eth0
379 28e15341 Iustin Pop
380 c71a1a3d Iustin Pop
.. _configure-lvm-label:
381 c71a1a3d Iustin Pop
382 28e15341 Iustin Pop
Configuring LVM
383 28e15341 Iustin Pop
+++++++++++++++
384 28e15341 Iustin Pop
385 28e15341 Iustin Pop
**Mandatory** on all nodes.
386 28e15341 Iustin Pop
387 28e15341 Iustin Pop
The volume group is required to be at least 20GiB.
388 28e15341 Iustin Pop
389 c71a1a3d Iustin Pop
If you haven't configured your LVM volume group at install time you need
390 c71a1a3d Iustin Pop
to do it before trying to initialize the Ganeti cluster. This is done by
391 c71a1a3d Iustin Pop
formatting the devices/partitions you want to use for it and then adding
392 c71a1a3d Iustin Pop
them to the relevant volume group::
393 28e15341 Iustin Pop
394 28e15341 Iustin Pop
  pvcreate /dev/sda3
395 28e15341 Iustin Pop
  vgcreate xenvg /dev/sda3
396 28e15341 Iustin Pop
397 28e15341 Iustin Pop
or::
398 28e15341 Iustin Pop
399 28e15341 Iustin Pop
  pvcreate /dev/sdb1
400 28e15341 Iustin Pop
  pvcreate /dev/sdc1
401 28e15341 Iustin Pop
  vgcreate xenvg /dev/sdb1 /dev/sdc1
402 28e15341 Iustin Pop
403 28e15341 Iustin Pop
If you want to add a device later you can do so with the *vgextend*
404 28e15341 Iustin Pop
command::
405 28e15341 Iustin Pop
406 28e15341 Iustin Pop
  pvcreate /dev/sdd1
407 28e15341 Iustin Pop
  vgextend xenvg /dev/sdd1
408 28e15341 Iustin Pop
409 28e15341 Iustin Pop
Optional: it is recommended to configure LVM not to scan the DRBD
410 28e15341 Iustin Pop
devices for physical volumes. This can be accomplished by editing
411 c71a1a3d Iustin Pop
``/etc/lvm/lvm.conf`` and adding the ``/dev/drbd[0-9]+`` regular
412 c71a1a3d Iustin Pop
expression to the ``filter`` variable, like this::
413 28e15341 Iustin Pop
414 28e15341 Iustin Pop
  filter = ["r|/dev/cdrom|", "r|/dev/drbd[0-9]+|" ]
415 28e15341 Iustin Pop
416 c71a1a3d Iustin Pop
Note that with Ganeti a helper script is provided - ``lvmstrap`` which
417 c71a1a3d Iustin Pop
will erase and configure as LVM any not in-use disk on your system. This
418 c71a1a3d Iustin Pop
is dangerous and it's recommended to read its ``--help`` output if you
419 c71a1a3d Iustin Pop
want to use it.
420 c71a1a3d Iustin Pop
421 28e15341 Iustin Pop
Installing Ganeti
422 28e15341 Iustin Pop
+++++++++++++++++
423 28e15341 Iustin Pop
424 28e15341 Iustin Pop
**Mandatory** on all nodes.
425 28e15341 Iustin Pop
426 28e15341 Iustin Pop
It's now time to install the Ganeti software itself.  Download the
427 28e15341 Iustin Pop
source from the project page at `<http://code.google.com/p/ganeti/>`_,
428 28e15341 Iustin Pop
and install it (replace 2.0.0 with the latest version)::
429 28e15341 Iustin Pop
430 28e15341 Iustin Pop
  tar xvzf ganeti-2.0.0.tar.gz
431 28e15341 Iustin Pop
  cd ganeti-2.0.0
432 28e15341 Iustin Pop
  ./configure --localstatedir=/var --sysconfdir=/etc
433 28e15341 Iustin Pop
  make
434 28e15341 Iustin Pop
  make install
435 28e15341 Iustin Pop
  mkdir /srv/ganeti/ /srv/ganeti/os /srv/ganeti/export
436 28e15341 Iustin Pop
437 c71a1a3d Iustin Pop
You also need to copy the file ``doc/examples/ganeti.initd`` from the
438 c71a1a3d Iustin Pop
source archive to ``/etc/init.d/ganeti`` and register it with your
439 28e15341 Iustin Pop
distribution's startup scripts, for example in Debian::
440 28e15341 Iustin Pop
441 28e15341 Iustin Pop
  update-rc.d ganeti defaults 20 80
442 28e15341 Iustin Pop
443 c71a1a3d Iustin Pop
In order to automatically restart failed instances, you need to setup a
444 c71a1a3d Iustin Pop
cron job run the *ganeti-watcher* command. A sample cron file is
445 c71a1a3d Iustin Pop
provided in the source at ``doc/examples/ganeti.cron`` and you can copy
446 c71a1a3d Iustin Pop
that (eventually altering the path) to ``/etc/cron.d/ganeti``.
447 c71a1a3d Iustin Pop
448 c71a1a3d Iustin Pop
What gets installed
449 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~
450 c71a1a3d Iustin Pop
451 c71a1a3d Iustin Pop
The above ``make install`` invocation, or installing via your
452 c71a1a3d Iustin Pop
distribution mechanisms, will install on the system:
453 c71a1a3d Iustin Pop
454 c71a1a3d Iustin Pop
- a set of python libraries under the *ganeti* namespace (depending on
455 c71a1a3d Iustin Pop
  the python version this can be located in either
456 c71a1a3d Iustin Pop
  ``lib/python-$ver/site-packages`` or various other locations)
457 c71a1a3d Iustin Pop
- a set of programs under ``/usr/local/sbin`` or ``/usr/sbin``
458 c71a1a3d Iustin Pop
- man pages for the above programs
459 c71a1a3d Iustin Pop
- a set of tools under the ``lib/ganeti/tools`` directory
460 c71a1a3d Iustin Pop
- an example iallocator script (see the admin guide for details) under
461 c71a1a3d Iustin Pop
  ``lib/ganeti/iallocators``
462 c71a1a3d Iustin Pop
- a cron job that is needed for cluster maintenance
463 c71a1a3d Iustin Pop
- an init script for automatic startup of Ganeti daemons
464 c71a1a3d Iustin Pop
- provided but not installed automatically by ``make install`` is a bash
465 c71a1a3d Iustin Pop
  completion script that hopefully will ease working with the many
466 c71a1a3d Iustin Pop
  cluster commands
467 28e15341 Iustin Pop
468 28e15341 Iustin Pop
Installing the Operating System support packages
469 28e15341 Iustin Pop
++++++++++++++++++++++++++++++++++++++++++++++++
470 28e15341 Iustin Pop
471 28e15341 Iustin Pop
**Mandatory** on all nodes.
472 28e15341 Iustin Pop
473 28e15341 Iustin Pop
To be able to install instances you need to have an Operating System
474 28e15341 Iustin Pop
installation script. An example OS that works under Debian and can
475 28e15341 Iustin Pop
install Debian and Ubuntu instace OSes is provided on the project web
476 c71a1a3d Iustin Pop
site.  Download it from the project page and follow the instructions in
477 a425810f Guido Trotter
the ``README`` file.  Here is the installation procedure (replace 0.9
478 c71a1a3d Iustin Pop
with the latest version that is compatible with your ganeti version)::
479 28e15341 Iustin Pop
480 28e15341 Iustin Pop
  cd /usr/local/src/
481 a425810f Guido Trotter
  wget http://ganeti.googlecode.com/files/ganeti-instance-debootstrap-0.9.tar.gz
482 a425810f Guido Trotter
  tar xzf ganeti-instance-debootstrap-0.9.tar.gz
483 a425810f Guido Trotter
  cd ganeti-instance-debootstrap-0.9
484 28e15341 Iustin Pop
  ./configure
485 28e15341 Iustin Pop
  make
486 28e15341 Iustin Pop
  make install
487 28e15341 Iustin Pop
488 28e15341 Iustin Pop
In order to use this OS definition, you need to have internet access
489 28e15341 Iustin Pop
from your nodes and have the *debootstrap*, *dump* and *restore*
490 28e15341 Iustin Pop
commands installed on all nodes. Also, if the OS is configured to
491 28e15341 Iustin Pop
partition the instance's disk in
492 28e15341 Iustin Pop
``/etc/default/ganeti-instance-debootstrap``, you will need *kpartx*
493 28e15341 Iustin Pop
installed.
494 28e15341 Iustin Pop
495 28e15341 Iustin Pop
.. admonition:: Debian
496 28e15341 Iustin Pop
497 28e15341 Iustin Pop
   Use this command on all nodes to install the required packages::
498 28e15341 Iustin Pop
499 28e15341 Iustin Pop
     apt-get install debootstrap dump kpartx
500 28e15341 Iustin Pop
501 a425810f Guido Trotter
.. admonition:: KVM
502 a425810f Guido Trotter
503 a425810f Guido Trotter
   In order for debootstrap instances to be able to shutdown cleanly
504 a425810f Guido Trotter
   they must install have basic acpi support inside the instance. Which
505 a425810f Guido Trotter
   packages are needed depend on the exact flavor of debian or ubuntu
506 a425810f Guido Trotter
   which you're installing, but the example defaults file has a
507 a425810f Guido Trotter
   commented out configuration line that works for debian lenny and
508 a425810f Guido Trotter
   squeeze::
509 a425810f Guido Trotter
510 a425810f Guido Trotter
     EXTRA_PKGS="acpi-support-base,console-tools,udev"
511 a425810f Guido Trotter
512 a425810f Guido Trotter
   kbd can be used instead of console-tools, and more packages can be
513 a425810f Guido Trotter
   added, of course, if needed.
514 a425810f Guido Trotter
515 28e15341 Iustin Pop
Alternatively, you can create your own OS definitions. See the manpage
516 fd07c6b3 Iustin Pop
:manpage:`ganeti-os-interface`.
517 28e15341 Iustin Pop
518 28e15341 Iustin Pop
Initializing the cluster
519 28e15341 Iustin Pop
++++++++++++++++++++++++
520 28e15341 Iustin Pop
521 c71a1a3d Iustin Pop
**Mandatory** once per cluster, on the first node.
522 28e15341 Iustin Pop
523 c71a1a3d Iustin Pop
The last step is to initialize the cluster. After you have repeated the
524 28e15341 Iustin Pop
above process on all of your nodes, choose one as the master, and
525 28e15341 Iustin Pop
execute::
526 28e15341 Iustin Pop
527 28e15341 Iustin Pop
  gnt-cluster init <CLUSTERNAME>
528 28e15341 Iustin Pop
529 c71a1a3d Iustin Pop
The *CLUSTERNAME* is a hostname, which must be resolvable (e.g. it must
530 c71a1a3d Iustin Pop
exist in DNS or in ``/etc/hosts``) by all the nodes in the cluster. You
531 c71a1a3d Iustin Pop
must choose a name different from any of the nodes names for a
532 c71a1a3d Iustin Pop
multi-node cluster. In general the best choice is to have a unique name
533 c71a1a3d Iustin Pop
for a cluster, even if it consists of only one machine, as you will be
534 c71a1a3d Iustin Pop
able to expand it later without any problems. Please note that the
535 c71a1a3d Iustin Pop
hostname used for this must resolve to an IP address reserved
536 28e15341 Iustin Pop
**exclusively** for this purpose, and cannot be the name of the first
537 28e15341 Iustin Pop
(master) node.
538 28e15341 Iustin Pop
539 7faf5110 Michael Hanselmann
If you want to use a bridge which is not ``xen-br0``, or no bridge at
540 e721c742 Guido Trotter
all, change it with the ``--nic-parameters`` option. For example to
541 e721c742 Guido Trotter
bridge on br0 you can say::
542 e721c742 Guido Trotter
543 e721c742 Guido Trotter
  --nic-parameters link=br0
544 e721c742 Guido Trotter
545 e721c742 Guido Trotter
Or to not bridge at all, and use a separate routing table::
546 e721c742 Guido Trotter
547 e721c742 Guido Trotter
  --nic-parameters mode=routed,link=100
548 9f83899a Guido Trotter
549 e721c742 Guido Trotter
If you don't have a xen-br0 interface you also have to specify a
550 e721c742 Guido Trotter
different network interface which will get the cluster ip, on the master
551 e721c742 Guido Trotter
node, by using the ``--master-netdev <device>`` option.
552 28e15341 Iustin Pop
553 28e15341 Iustin Pop
You can use a different name than ``xenvg`` for the volume group (but
554 28e15341 Iustin Pop
note that the name must be identical on all nodes). In this case you
555 c71a1a3d Iustin Pop
need to specify it by passing the *-g <VGNAME>* option to ``gnt-cluster
556 c71a1a3d Iustin Pop
init``.
557 28e15341 Iustin Pop
558 c71a1a3d Iustin Pop
To set up the cluster as an Xen HVM cluster, use the
559 28e15341 Iustin Pop
``--enabled-hypervisors=xen-hvm`` option to enable the HVM hypervisor
560 c71a1a3d Iustin Pop
(you can also add ``,xen-pvm`` to enable the PVM one too). You will also
561 c71a1a3d Iustin Pop
need to create the VNC cluster password file
562 28e15341 Iustin Pop
``/etc/ganeti/vnc-cluster-password`` which contains one line with the
563 28e15341 Iustin Pop
default VNC password for the cluster.
564 28e15341 Iustin Pop
565 28e15341 Iustin Pop
To setup the cluster for KVM-only usage (KVM and Xen cannot be mixed),
566 28e15341 Iustin Pop
pass ``--enabled-hypervisors=kvm`` to the init command.
567 28e15341 Iustin Pop
568 28e15341 Iustin Pop
You can also invoke the command with the ``--help`` option in order to
569 28e15341 Iustin Pop
see all the possibilities.
570 28e15341 Iustin Pop
571 b8313b29 Guido Trotter
Hypervisor/Network/Cluster parameters
572 b8313b29 Guido Trotter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
573 b8313b29 Guido Trotter
574 b8313b29 Guido Trotter
Please note that the default hypervisor/network/cluster parameters may
575 b8313b29 Guido Trotter
not be the correct one for your environment. Carefully check them, and
576 b8313b29 Guido Trotter
change them at cluster init time, or later with ``gnt-cluster modify``.
577 b8313b29 Guido Trotter
578 b8313b29 Guido Trotter
Your instance types, networking environment, hypervisor type and version
579 b8313b29 Guido Trotter
may all affect what kind of parameters should be used on your cluster.
580 b8313b29 Guido Trotter
581 b8313b29 Guido Trotter
For example kvm instances are by default configured to use a host
582 b8313b29 Guido Trotter
kernel, and to be reached via serial console, which works nice for linux
583 b8313b29 Guido Trotter
paravirtualized instances. If you want fully virtualized instances you
584 b8313b29 Guido Trotter
may want to handle their kernel inside the instance, and to use VNC.
585 b8313b29 Guido Trotter
586 28e15341 Iustin Pop
Joining the nodes to the cluster
587 28e15341 Iustin Pop
++++++++++++++++++++++++++++++++
588 28e15341 Iustin Pop
589 28e15341 Iustin Pop
**Mandatory** for all the other nodes.
590 28e15341 Iustin Pop
591 c71a1a3d Iustin Pop
After you have initialized your cluster you need to join the other nodes
592 c71a1a3d Iustin Pop
to it. You can do so by executing the following command on the master
593 c71a1a3d Iustin Pop
node::
594 28e15341 Iustin Pop
595 28e15341 Iustin Pop
  gnt-node add <NODENAME>
596 28e15341 Iustin Pop
597 28e15341 Iustin Pop
Separate replication network
598 28e15341 Iustin Pop
++++++++++++++++++++++++++++
599 28e15341 Iustin Pop
600 28e15341 Iustin Pop
**Optional**
601 28e15341 Iustin Pop
602 28e15341 Iustin Pop
Ganeti uses DRBD to mirror the disk of the virtual instances between
603 28e15341 Iustin Pop
nodes. To use a dedicated network interface for this (in order to
604 28e15341 Iustin Pop
improve performance or to enhance security) you need to configure an
605 28e15341 Iustin Pop
additional interface for each node.  Use the *-s* option with
606 28e15341 Iustin Pop
``gnt-cluster init`` and ``gnt-node add`` to specify the IP address of
607 28e15341 Iustin Pop
this secondary interface to use for each node. Note that if you
608 c71a1a3d Iustin Pop
specified this option at cluster setup time, you must afterwards use it
609 c71a1a3d Iustin Pop
for every node add operation.
610 28e15341 Iustin Pop
611 28e15341 Iustin Pop
Testing the setup
612 28e15341 Iustin Pop
+++++++++++++++++
613 28e15341 Iustin Pop
614 c71a1a3d Iustin Pop
Execute the ``gnt-node list`` command to see all nodes in the cluster::
615 28e15341 Iustin Pop
616 28e15341 Iustin Pop
  # gnt-node list
617 28e15341 Iustin Pop
  Node              DTotal  DFree MTotal MNode MFree Pinst Sinst
618 28e15341 Iustin Pop
  node1.example.com 197404 197404   2047  1896   125     0     0
619 28e15341 Iustin Pop
620 c71a1a3d Iustin Pop
The above shows a couple of things:
621 28e15341 Iustin Pop
622 c71a1a3d Iustin Pop
- The various Ganeti daemons can talk to each other
623 c71a1a3d Iustin Pop
- Ganeti can examine the storage of the node (DTotal/DFree)
624 c71a1a3d Iustin Pop
- Ganeti can talk to the selected hypervisor (MTotal/MNode/MFree)
625 28e15341 Iustin Pop
626 c71a1a3d Iustin Pop
Cluster burnin
627 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~
628 28e15341 Iustin Pop
629 c71a1a3d Iustin Pop
With Ganeti a tool called :command:`burnin` is provided that can test
630 c71a1a3d Iustin Pop
most of the Ganeti functionality. The tool is installed under the
631 c71a1a3d Iustin Pop
``lib/ganeti/tools`` directory (either under ``/usr`` or ``/usr/local``
632 c71a1a3d Iustin Pop
based on the installation method). See more details under
633 c71a1a3d Iustin Pop
:ref:`burnin-label`.
634 28e15341 Iustin Pop
635 c71a1a3d Iustin Pop
Further steps
636 c71a1a3d Iustin Pop
-------------
637 28e15341 Iustin Pop
638 c71a1a3d Iustin Pop
You can now proceed either to the :doc:`admin`, or read the manpages of
639 c71a1a3d Iustin Pop
the various commands (:manpage:`ganeti(7)`, :manpage:`gnt-cluster(8)`,
640 c71a1a3d Iustin Pop
:manpage:`gnt-node(8)`, :manpage:`gnt-instance(8)`,
641 c71a1a3d Iustin Pop
:manpage:`gnt-job(8)`).
642 28e15341 Iustin Pop
643 c71a1a3d Iustin Pop
.. rubric:: Footnotes
644 28e15341 Iustin Pop
645 c71a1a3d Iustin Pop
.. [#defkernel] The kernel and initrd paths can be changed at either
646 c71a1a3d Iustin Pop
   cluster level (which changes the default for all instances) or at
647 c71a1a3d Iustin Pop
   instance level.
648 558fd122 Michael Hanselmann
649 558fd122 Michael Hanselmann
.. vim: set textwidth=72 :
650 c71a1a3d Iustin Pop
.. Local Variables:
651 c71a1a3d Iustin Pop
.. mode: rst
652 c71a1a3d Iustin Pop
.. fill-column: 72
653 c71a1a3d Iustin Pop
.. End: