Statistics
| Branch: | Tag: | Revision:

root / doc / admin.rst @ 79829d23

History | View | Annotate | Download (59.4 kB)

1
Ganeti administrator's guide
2
============================
3

    
4
Documents Ganeti version |version|
5

    
6
.. contents::
7

    
8
.. highlight:: shell-example
9

    
10
Introduction
11
------------
12

    
13
Ganeti is a virtualization cluster management software. You are expected
14
to be a system administrator familiar with your Linux distribution and
15
the Xen or KVM virtualization environments before using it.
16

    
17
The various components of Ganeti all have man pages and interactive
18
help. This manual though will help you getting familiar with the system
19
by explaining the most common operations, grouped by related use.
20

    
21
After a terminology glossary and a section on the prerequisites needed
22
to use this manual, the rest of this document is divided in sections
23
for the different targets that a command affects: instance, nodes, etc.
24

    
25
.. _terminology-label:
26

    
27
Ganeti terminology
28
++++++++++++++++++
29

    
30
This section provides a small introduction to Ganeti terminology, which
31
might be useful when reading the rest of the document.
32

    
33
Cluster
34
~~~~~~~
35

    
36
A set of machines (nodes) that cooperate to offer a coherent, highly
37
available virtualization service under a single administration domain.
38

    
39
Node
40
~~~~
41

    
42
A physical machine which is member of a cluster.  Nodes are the basic
43
cluster infrastructure, and they don't need to be fault tolerant in
44
order to achieve high availability for instances.
45

    
46
Node can be added and removed (if they host no instances) at will from
47
the cluster. In a HA cluster and only with HA instances, the loss of any
48
single node will not cause disk data loss for any instance; of course,
49
a node crash will cause the crash of the its primary instances.
50

    
51
A node belonging to a cluster can be in one of the following roles at a
52
given time:
53

    
54
- *master* node, which is the node from which the cluster is controlled
55
- *master candidate* node, only nodes in this role have the full cluster
56
  configuration and knowledge, and only master candidates can become the
57
  master node
58
- *regular* node, which is the state in which most nodes will be on
59
  bigger clusters (>20 nodes)
60
- *drained* node, nodes in this state are functioning normally but the
61
  cannot receive new instances; the intention is that nodes in this role
62
  have some issue and they are being evacuated for hardware repairs
63
- *offline* node, in which there is a record in the cluster
64
  configuration about the node, but the daemons on the master node will
65
  not talk to this node; any instances declared as having an offline
66
  node as either primary or secondary will be flagged as an error in the
67
  cluster verify operation
68

    
69
Depending on the role, each node will run a set of daemons:
70

    
71
- the :command:`ganeti-noded` daemon, which control the manipulation of
72
  this node's hardware resources; it runs on all nodes which are in a
73
  cluster
74
- the :command:`ganeti-confd` daemon (Ganeti 2.1+) which runs on all
75
  nodes, but is only functional on master candidate nodes; this daemon
76
  can be disabled at configuration time if you don't need its
77
  functionality
78
- the :command:`ganeti-rapi` daemon which runs on the master node and
79
  offers an HTTP-based API for the cluster
80
- the :command:`ganeti-masterd` daemon which runs on the master node and
81
  allows control of the cluster
82

    
83
Beside the node role, there are other node flags that influence its
84
behaviour:
85

    
86
- the *master_capable* flag denotes whether the node can ever become a
87
  master candidate; setting this to 'no' means that auto-promotion will
88
  never make this node a master candidate; this flag can be useful for a
89
  remote node that only runs local instances, and having it become a
90
  master is impractical due to networking or other constraints
91
- the *vm_capable* flag denotes whether the node can host instances or
92
  not; for example, one might use a non-vm_capable node just as a master
93
  candidate, for configuration backups; setting this flag to no
94
  disallows placement of instances of this node, deactivates hypervisor
95
  and related checks on it (e.g. bridge checks, LVM check, etc.), and
96
  removes it from cluster capacity computations
97

    
98

    
99
Instance
100
~~~~~~~~
101

    
102
A virtual machine which runs on a cluster. It can be a fault tolerant,
103
highly available entity.
104

    
105
An instance has various parameters, which are classified in three
106
categories: hypervisor related-parameters (called ``hvparams``), general
107
parameters (called ``beparams``) and per network-card parameters (called
108
``nicparams``). All these parameters can be modified either at instance
109
level or via defaults at cluster level.
110

    
111
Disk template
112
~~~~~~~~~~~~~
113

    
114
The are multiple options for the storage provided to an instance; while
115
the instance sees the same virtual drive in all cases, the node-level
116
configuration varies between them.
117

    
118
There are five disk templates you can choose from:
119

    
120
diskless
121
  The instance has no disks. Only used for special purpose operating
122
  systems or for testing.
123

    
124
file
125
  The instance will use plain files as backend for its disks. No
126
  redundancy is provided, and this is somewhat more difficult to
127
  configure for high performance.
128

    
129
plain
130
  The instance will use LVM devices as backend for its disks. No
131
  redundancy is provided.
132

    
133
drbd
134
  .. note:: This is only valid for multi-node clusters using DRBD 8.0+
135

    
136
  A mirror is set between the local node and a remote one, which must be
137
  specified with the second value of the --node option. Use this option
138
  to obtain a highly available instance that can be failed over to a
139
  remote node should the primary one fail.
140

    
141
rbd
142
  The instance will use Volumes inside a RADOS cluster as backend for its
143
  disks. It will access them using the RADOS block device (RBD).
144

    
145
IAllocator
146
~~~~~~~~~~
147

    
148
A framework for using external (user-provided) scripts to compute the
149
placement of instances on the cluster nodes. This eliminates the need to
150
manually specify nodes in instance add, instance moves, node evacuate,
151
etc.
152

    
153
In order for Ganeti to be able to use these scripts, they must be place
154
in the iallocator directory (usually ``lib/ganeti/iallocators`` under
155
the installation prefix, e.g. ``/usr/local``).
156

    
157
“Primary” and “secondary” concepts
158
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
159

    
160
An instance has a primary and depending on the disk configuration, might
161
also have a secondary node. The instance always runs on the primary node
162
and only uses its secondary node for disk replication.
163

    
164
Similarly, the term of primary and secondary instances when talking
165
about a node refers to the set of instances having the given node as
166
primary, respectively secondary.
167

    
168
Tags
169
~~~~
170

    
171
Tags are short strings that can be attached to either to cluster itself,
172
or to nodes or instances. They are useful as a very simplistic
173
information store for helping with cluster administration, for example
174
by attaching owner information to each instance after it's created::
175

    
176
  $ gnt-instance add … %instance1%
177
  $ gnt-instance add-tags %instance1% %owner:user2%
178

    
179
And then by listing each instance and its tags, this information could
180
be used for contacting the users of each instance.
181

    
182
Jobs and OpCodes
183
~~~~~~~~~~~~~~~~
184

    
185
While not directly visible by an end-user, it's useful to know that a
186
basic cluster operation (e.g. starting an instance) is represented
187
internally by Ganeti as an *OpCode* (abbreviation from operation
188
code). These OpCodes are executed as part of a *Job*. The OpCodes in a
189
single Job are processed serially by Ganeti, but different Jobs will be
190
processed (depending on resource availability) in parallel. They will
191
not be executed in the submission order, but depending on resource
192
availability, locks and (starting with Ganeti 2.3) priority. An earlier
193
job may have to wait for a lock while a newer job doesn't need any locks
194
and can be executed right away. Operations requiring a certain order
195
need to be submitted as a single job, or the client must submit one job
196
at a time and wait for it to finish before continuing.
197

    
198
For example, shutting down the entire cluster can be done by running the
199
command ``gnt-instance shutdown --all``, which will submit for each
200
instance a separate job containing the “shutdown instance” OpCode.
201

    
202

    
203
Prerequisites
204
+++++++++++++
205

    
206
You need to have your Ganeti cluster installed and configured before you
207
try any of the commands in this document. Please follow the
208
:doc:`install` for instructions on how to do that.
209

    
210
Instance management
211
-------------------
212

    
213
Adding an instance
214
++++++++++++++++++
215

    
216
The add operation might seem complex due to the many parameters it
217
accepts, but once you have understood the (few) required parameters and
218
the customisation capabilities you will see it is an easy operation.
219

    
220
The add operation requires at minimum five parameters:
221

    
222
- the OS for the instance
223
- the disk template
224
- the disk count and size
225
- the node specification or alternatively the iallocator to use
226
- and finally the instance name
227

    
228
The OS for the instance must be visible in the output of the command
229
``gnt-os list`` and specifies which guest OS to install on the instance.
230

    
231
The disk template specifies what kind of storage to use as backend for
232
the (virtual) disks presented to the instance; note that for instances
233
with multiple virtual disks, they all must be of the same type.
234

    
235
The node(s) on which the instance will run can be given either manually,
236
via the ``-n`` option, or computed automatically by Ganeti, if you have
237
installed any iallocator script.
238

    
239
With the above parameters in mind, the command is::
240

    
241
  $ gnt-instance add \
242
    -n %TARGET_NODE%:%SECONDARY_NODE% \
243
    -o %OS_TYPE% \
244
    -t %DISK_TEMPLATE% -s %DISK_SIZE% \
245
    %INSTANCE_NAME%
246

    
247
The instance name must be resolvable (e.g. exist in DNS) and usually
248
points to an address in the same subnet as the cluster itself.
249

    
250
The above command has the minimum required options; other options you
251
can give include, among others:
252

    
253
- The maximum/minimum memory size (``-B maxmem``, ``-B minmem``)
254
  (``-B memory`` can be used to specify only one size)
255

    
256
- The number of virtual CPUs (``-B vcpus``)
257

    
258
- Arguments for the NICs of the instance; by default, a single-NIC
259
  instance is created. The IP and/or bridge of the NIC can be changed
260
  via ``--nic 0:ip=IP,bridge=BRIDGE``
261

    
262
See the manpage for gnt-instance for the detailed option list.
263

    
264
For example if you want to create an highly available instance, with a
265
single disk of 50GB and the default memory size, having primary node
266
``node1`` and secondary node ``node3``, use the following command::
267

    
268
  $ gnt-instance add -n node1:node3 -o debootstrap -t drbd -s 50G \
269
    instance1
270

    
271
There is a also a command for batch instance creation from a
272
specification file, see the ``batch-create`` operation in the
273
gnt-instance manual page.
274

    
275
Regular instance operations
276
+++++++++++++++++++++++++++
277

    
278
Removal
279
~~~~~~~
280

    
281
Removing an instance is even easier than creating one. This operation is
282
irreversible and destroys all the contents of your instance. Use with
283
care::
284

    
285
  $ gnt-instance remove %INSTANCE_NAME%
286

    
287
.. _instance-startup-label:
288

    
289
Startup/shutdown
290
~~~~~~~~~~~~~~~~
291

    
292
Instances are automatically started at instance creation time. To
293
manually start one which is currently stopped you can run::
294

    
295
  $ gnt-instance startup %INSTANCE_NAME%
296

    
297
Ganeti will start an instance with up to its maximum instance memory. If
298
not enough memory is available Ganeti will use all the available memory
299
down to the instance minumum memory. If not even that amount of memory
300
is free Ganeti will refuse to start the instance.
301

    
302
Note, that this will not work when an instance is in a permanently
303
stopped state ``offline``. In this case, you will first have to
304
put it back to online mode by running::
305

    
306
  $ gnt-instance modify --online %INSTANCE_NAME%
307

    
308
The command to stop the running instance is::
309

    
310
  $ gnt-instance shutdown %INSTANCE_NAME%
311

    
312
If you want to shut the instance down more permanently, so that it
313
does not require dynamically allocated resources (memory and vcpus),
314
after shutting down an instance, execute the following::
315

    
316
  $ gnt-instance modify --offline %INSTANCE_NAME%
317

    
318
.. warning:: Do not use the Xen or KVM commands directly to stop
319
   instances. If you run for example ``xm shutdown`` or ``xm destroy``
320
   on an instance Ganeti will automatically restart it (via
321
   the :command:`ganeti-watcher` command which is launched via cron).
322

    
323
Querying instances
324
~~~~~~~~~~~~~~~~~~
325

    
326
There are two ways to get information about instances: listing
327
instances, which does a tabular output containing a given set of fields
328
about each instance, and querying detailed information about a set of
329
instances.
330

    
331
The command to see all the instances configured and their status is::
332

    
333
  $ gnt-instance list
334

    
335
The command can return a custom set of information when using the ``-o``
336
option (as always, check the manpage for a detailed specification). Each
337
instance will be represented on a line, thus making it easy to parse
338
this output via the usual shell utilities (grep, sed, etc.).
339

    
340
To get more detailed information about an instance, you can run::
341

    
342
  $ gnt-instance info %INSTANCE%
343

    
344
which will give a multi-line block of information about the instance,
345
it's hardware resources (especially its disks and their redundancy
346
status), etc. This is harder to parse and is more expensive than the
347
list operation, but returns much more detailed information.
348

    
349
Changing an instance's runtime memory
350
+++++++++++++++++++++++++++++++++++++
351

    
352
Ganeti will always make sure an instance has a value between its maximum
353
and its minimum memory available as runtime memory. As of version 2.6
354
Ganeti will only choose a size different than the maximum size when
355
starting up, failing over, or migrating an instance on a node with less
356
than the maximum memory available. It won't resize other instances in
357
order to free up space for an instance.
358

    
359
If you find that you need more memory on a node any instance can be
360
manually resized without downtime, with the command::
361

    
362
  $ gnt-instance modify -m %SIZE% %INSTANCE_NAME%
363

    
364
The same command can also be used to increase the memory available on an
365
instance, provided that enough free memory is available on its node, and
366
the specified size is not larger than the maximum memory size the
367
instance had when it was first booted (an instance will be unable to see
368
new memory above the maximum that was specified to the hypervisor at its
369
boot time, if it needs to grow further a reboot becomes necessary).
370

    
371
Export/Import
372
+++++++++++++
373

    
374
You can create a snapshot of an instance disk and its Ganeti
375
configuration, which then you can backup, or import into another
376
cluster. The way to export an instance is::
377

    
378
  $ gnt-backup export -n %TARGET_NODE% %INSTANCE_NAME%
379

    
380

    
381
The target node can be any node in the cluster with enough space under
382
``/srv/ganeti`` to hold the instance image. Use the ``--noshutdown``
383
option to snapshot an instance without rebooting it. Note that Ganeti
384
only keeps one snapshot for an instance - any previous snapshot of the
385
same instance existing cluster-wide under ``/srv/ganeti`` will be
386
removed by this operation: if you want to keep them, you need to move
387
them out of the Ganeti exports directory.
388

    
389
Importing an instance is similar to creating a new one, but additionally
390
one must specify the location of the snapshot. The command is::
391

    
392
  $ gnt-backup import -n %TARGET_NODE% \
393
    --src-node=%NODE% --src-dir=%DIR% %INSTANCE_NAME%
394

    
395
By default, parameters will be read from the export information, but you
396
can of course pass them in via the command line - most of the options
397
available for the command :command:`gnt-instance add` are supported here
398
too.
399

    
400
Import of foreign instances
401
+++++++++++++++++++++++++++
402

    
403
There is a possibility to import a foreign instance whose disk data is
404
already stored as LVM volumes without going through copying it: the disk
405
adoption mode.
406

    
407
For this, ensure that the original, non-managed instance is stopped,
408
then create a Ganeti instance in the usual way, except that instead of
409
passing the disk information you specify the current volumes::
410

    
411
  $ gnt-instance add -t plain -n %HOME_NODE% ... \
412
    --disk 0:adopt=%lv_name%[,vg=%vg_name%] %INSTANCE_NAME%
413

    
414
This will take over the given logical volumes, rename them to the Ganeti
415
standard (UUID-based), and without installing the OS on them start
416
directly the instance. If you configure the hypervisor similar to the
417
non-managed configuration that the instance had, the transition should
418
be seamless for the instance. For more than one disk, just pass another
419
disk parameter (e.g. ``--disk 1:adopt=...``).
420

    
421
Instance kernel selection
422
+++++++++++++++++++++++++
423

    
424
The kernel that instances uses to bootup can come either from the node,
425
or from instances themselves, depending on the setup.
426

    
427
Xen-PVM
428
~~~~~~~
429

    
430
With Xen PVM, there are three options.
431

    
432
First, you can use a kernel from the node, by setting the hypervisor
433
parameters as such:
434

    
435
- ``kernel_path`` to a valid file on the node (and appropriately
436
  ``initrd_path``)
437
- ``kernel_args`` optionally set to a valid Linux setting (e.g. ``ro``)
438
- ``root_path`` to a valid setting (e.g. ``/dev/xvda1``)
439
- ``bootloader_path`` and ``bootloader_args`` to empty
440

    
441
Alternatively, you can delegate the kernel management to instances, and
442
use either ``pvgrub`` or the deprecated ``pygrub``. For this, you must
443
install the kernels and initrds in the instance and create a valid GRUB
444
v1 configuration file.
445

    
446
For ``pvgrub`` (new in version 2.4.2), you need to set:
447

    
448
- ``kernel_path`` to point to the ``pvgrub`` loader present on the node
449
  (e.g. ``/usr/lib/xen/boot/pv-grub-x86_32.gz``)
450
- ``kernel_args`` to the path to the GRUB config file, relative to the
451
  instance (e.g. ``(hd0,0)/grub/menu.lst``)
452
- ``root_path`` **must** be empty
453
- ``bootloader_path`` and ``bootloader_args`` to empty
454

    
455
While ``pygrub`` is deprecated, here is how you can configure it:
456

    
457
- ``bootloader_path`` to the pygrub binary (e.g. ``/usr/bin/pygrub``)
458
- the other settings are not important
459

    
460
More information can be found in the Xen wiki pages for `pvgrub
461
<http://wiki.xensource.com/xenwiki/PvGrub>`_ and `pygrub
462
<http://wiki.xensource.com/xenwiki/PyGrub>`_.
463

    
464
KVM
465
~~~
466

    
467
For KVM also the kernel can be loaded either way.
468

    
469
For loading the kernels from the node, you need to set:
470

    
471
- ``kernel_path`` to a valid value
472
- ``initrd_path`` optionally set if you use an initrd
473
- ``kernel_args`` optionally set to a valid value (e.g. ``ro``)
474

    
475
If you want instead to have the instance boot from its disk (and execute
476
its bootloader), simply set the ``kernel_path`` parameter to an empty
477
string, and all the others will be ignored.
478

    
479
Instance HA features
480
--------------------
481

    
482
.. note:: This section only applies to multi-node clusters
483

    
484
.. _instance-change-primary-label:
485

    
486
Changing the primary node
487
+++++++++++++++++++++++++
488

    
489
There are three ways to exchange an instance's primary and secondary
490
nodes; the right one to choose depends on how the instance has been
491
created and the status of its current primary node. See
492
:ref:`rest-redundancy-label` for information on changing the secondary
493
node. Note that it's only possible to change the primary node to the
494
secondary and vice-versa; a direct change of the primary node with a
495
third node, while keeping the current secondary is not possible in a
496
single step, only via multiple operations as detailed in
497
:ref:`instance-relocation-label`.
498

    
499
Failing over an instance
500
~~~~~~~~~~~~~~~~~~~~~~~~
501

    
502
If an instance is built in highly available mode you can at any time
503
fail it over to its secondary node, even if the primary has somehow
504
failed and it's not up anymore. Doing it is really easy, on the master
505
node you can just run::
506

    
507
  $ gnt-instance failover %INSTANCE_NAME%
508

    
509
That's it. After the command completes the secondary node is now the
510
primary, and vice-versa.
511

    
512
The instance will be started with an amount of memory between its
513
``maxmem`` and its ``minmem`` value, depending on the free memory on its
514
target node, or the operation will fail if that's not possible. See
515
:ref:`instance-startup-label` for details.
516

    
517
If the instance's disk template is of type rbd, then you can specify
518
the target node (which can be any node) explicitly, or specify an
519
iallocator plugin. If you omit both, the default iallocator will be
520
used to determine the target node::
521

    
522
  $ gnt-instance failover -n %TARGET_NODE% %INSTANCE_NAME%
523

    
524
Live migrating an instance
525
~~~~~~~~~~~~~~~~~~~~~~~~~~
526

    
527
If an instance is built in highly available mode, it currently runs and
528
both its nodes are running fine, you can at migrate it over to its
529
secondary node, without downtime. On the master node you need to run::
530

    
531
  $ gnt-instance migrate %INSTANCE_NAME%
532

    
533
The current load on the instance and its memory size will influence how
534
long the migration will take. In any case, for both KVM and Xen
535
hypervisors, the migration will be transparent to the instance.
536

    
537
If the destination node has less memory than the instance's current
538
runtime memory, but at least the instance's minimum memory available
539
Ganeti will automatically reduce the instance runtime memory before
540
migrating it, unless the ``--no-runtime-changes`` option is passed, in
541
which case the target node should have at least the instance's current
542
runtime memory free.
543

    
544
If the instance's disk template is of type rbd, then you can specify
545
the target node (which can be any node) explicitly, or specify an
546
iallocator plugin. If you omit both, the default iallocator will be
547
used to determine the target node::
548

    
549
   $ gnt-instance migrate -n %TARGET_NODE% %INSTANCE_NAME%
550

    
551
Moving an instance (offline)
552
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
553

    
554
If an instance has not been create as mirrored, then the only way to
555
change its primary node is to execute the move command::
556

    
557
  $ gnt-instance move -n %NEW_NODE% %INSTANCE%
558

    
559
This has a few prerequisites:
560

    
561
- the instance must be stopped
562
- its current primary node must be on-line and healthy
563
- the disks of the instance must not have any errors
564

    
565
Since this operation actually copies the data from the old node to the
566
new node, expect it to take proportional to the size of the instance's
567
disks and the speed of both the nodes' I/O system and their networking.
568

    
569
Disk operations
570
+++++++++++++++
571

    
572
Disk failures are a common cause of errors in any server
573
deployment. Ganeti offers protection from single-node failure if your
574
instances were created in HA mode, and it also offers ways to restore
575
redundancy after a failure.
576

    
577
Preparing for disk operations
578
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
579

    
580
It is important to note that for Ganeti to be able to do any disk
581
operation, the Linux machines on top of which Ganeti must be consistent;
582
for LVM, this means that the LVM commands must not return failures; it
583
is common that after a complete disk failure, any LVM command aborts
584
with an error similar to::
585

    
586
  $ vgs
587
  /dev/sdb1: read failed after 0 of 4096 at 0: Input/output error
588
  /dev/sdb1: read failed after 0 of 4096 at 750153695232: Input/output error
589
  /dev/sdb1: read failed after 0 of 4096 at 0: Input/output error
590
  Couldn't find device with uuid 't30jmN-4Rcf-Fr5e-CURS-pawt-z0jU-m1TgeJ'.
591
  Couldn't find all physical volumes for volume group xenvg.
592

    
593
Before restoring an instance's disks to healthy status, it's needed to
594
fix the volume group used by Ganeti so that we can actually create and
595
manage the logical volumes. This is usually done in a multi-step
596
process:
597

    
598
#. first, if the disk is completely gone and LVM commands exit with
599
   “Couldn't find device with uuid…” then you need to run the command::
600

    
601
    $ vgreduce --removemissing %VOLUME_GROUP%
602

    
603
#. after the above command, the LVM commands should be executing
604
   normally (warnings are normal, but the commands will not fail
605
   completely).
606

    
607
#. if the failed disk is still visible in the output of the ``pvs``
608
   command, you need to deactivate it from allocations by running::
609

    
610
    $ pvs -x n /dev/%DISK%
611

    
612
At this point, the volume group should be consistent and any bad
613
physical volumes should not longer be available for allocation.
614

    
615
Note that since version 2.1 Ganeti provides some commands to automate
616
these two operations, see :ref:`storage-units-label`.
617

    
618
.. _rest-redundancy-label:
619

    
620
Restoring redundancy for DRBD-based instances
621
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
622

    
623
A DRBD instance has two nodes, and the storage on one of them has
624
failed. Depending on which node (primary or secondary) has failed, you
625
have three options at hand:
626

    
627
- if the storage on the primary node has failed, you need to re-create
628
  the disks on it
629
- if the storage on the secondary node has failed, you can either
630
  re-create the disks on it or change the secondary and recreate
631
  redundancy on the new secondary node
632

    
633
Of course, at any point it's possible to force re-creation of disks even
634
though everything is already fine.
635

    
636
For all three cases, the ``replace-disks`` operation can be used::
637

    
638
  # re-create disks on the primary node
639
  $ gnt-instance replace-disks -p %INSTANCE_NAME%
640
  # re-create disks on the current secondary
641
  $ gnt-instance replace-disks -s %INSTANCE_NAME%
642
  # change the secondary node, via manual specification
643
  $ gnt-instance replace-disks -n %NODE% %INSTANCE_NAME%
644
  # change the secondary node, via an iallocator script
645
  $ gnt-instance replace-disks -I %SCRIPT% %INSTANCE_NAME%
646
  # since Ganeti 2.1: automatically fix the primary or secondary node
647
  $ gnt-instance replace-disks -a %INSTANCE_NAME%
648

    
649
Since the process involves copying all data from the working node to the
650
target node, it will take a while, depending on the instance's disk
651
size, node I/O system and network speed. But it is (barring any network
652
interruption) completely transparent for the instance.
653

    
654
Re-creating disks for non-redundant instances
655
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
656

    
657
.. versionadded:: 2.1
658

    
659
For non-redundant instances, there isn't a copy (except backups) to
660
re-create the disks. But it's possible to at-least re-create empty
661
disks, after which a reinstall can be run, via the ``recreate-disks``
662
command::
663

    
664
  $ gnt-instance recreate-disks %INSTANCE%
665

    
666
Note that this will fail if the disks already exists.
667

    
668
Conversion of an instance's disk type
669
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
670

    
671
It is possible to convert between a non-redundant instance of type
672
``plain`` (LVM storage) and redundant ``drbd`` via the ``gnt-instance
673
modify`` command::
674

    
675
  # start with a non-redundant instance
676
  $ gnt-instance add -t plain ... %INSTANCE%
677

    
678
  # later convert it to redundant
679
  $ gnt-instance stop %INSTANCE%
680
  $ gnt-instance modify -t drbd -n %NEW_SECONDARY% %INSTANCE%
681
  $ gnt-instance start %INSTANCE%
682

    
683
  # and convert it back
684
  $ gnt-instance stop %INSTANCE%
685
  $ gnt-instance modify -t plain %INSTANCE%
686
  $ gnt-instance start %INSTANCE%
687

    
688
The conversion must be done while the instance is stopped, and
689
converting from plain to drbd template presents a small risk, especially
690
if the instance has multiple disks and/or if one node fails during the
691
conversion procedure). As such, it's recommended (as always) to make
692
sure that downtime for manual recovery is acceptable and that the
693
instance has up-to-date backups.
694

    
695
Debugging instances
696
+++++++++++++++++++
697

    
698
Accessing an instance's disks
699
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
700

    
701
From an instance's primary node you can have access to its disks. Never
702
ever mount the underlying logical volume manually on a fault tolerant
703
instance, or will break replication and your data will be
704
inconsistent. The correct way to access an instance's disks is to run
705
(on the master node, as usual) the command::
706

    
707
  $ gnt-instance activate-disks %INSTANCE%
708

    
709
And then, *on the primary node of the instance*, access the device that
710
gets created. For example, you could mount the given disks, then edit
711
files on the filesystem, etc.
712

    
713
Note that with partitioned disks (as opposed to whole-disk filesystems),
714
you will need to use a tool like :manpage:`kpartx(8)`::
715

    
716
  # on node1
717
  $ gnt-instance activate-disks %instance1%
718
  node3:disk/0:…
719
  $ ssh node3
720
  # on node 3
721
  $ kpartx -l /dev/…
722
  $ kpartx -a /dev/…
723
  $ mount /dev/mapper/… /mnt/
724
  # edit files under mnt as desired
725
  $ umount /mnt/
726
  $ kpartx -d /dev/…
727
  $ exit
728
  # back to node 1
729

    
730
After you've finished you can deactivate them with the deactivate-disks
731
command, which works in the same way::
732

    
733
  $ gnt-instance deactivate-disks %INSTANCE%
734

    
735
Note that if any process started by you is still using the disks, the
736
above command will error out, and you **must** cleanup and ensure that
737
the above command runs successfully before you start the instance,
738
otherwise the instance will suffer corruption.
739

    
740
Accessing an instance's console
741
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
742

    
743
The command to access a running instance's console is::
744

    
745
  $ gnt-instance console %INSTANCE_NAME%
746

    
747
Use the console normally and then type ``^]`` when done, to exit.
748

    
749
Other instance operations
750
+++++++++++++++++++++++++
751

    
752
Reboot
753
~~~~~~
754

    
755
There is a wrapper command for rebooting instances::
756

    
757
  $ gnt-instance reboot %instance2%
758

    
759
By default, this does the equivalent of shutting down and then starting
760
the instance, but it accepts parameters to perform a soft-reboot (via
761
the hypervisor), a hard reboot (hypervisor shutdown and then startup) or
762
a full one (the default, which also de-configures and then configures
763
again the disks of the instance).
764

    
765
Instance OS definitions debugging
766
+++++++++++++++++++++++++++++++++
767

    
768
Should you have any problems with instance operating systems the command
769
to see a complete status for all your nodes is::
770

    
771
   $ gnt-os diagnose
772

    
773
.. _instance-relocation-label:
774

    
775
Instance relocation
776
~~~~~~~~~~~~~~~~~~~
777

    
778
While it is not possible to move an instance from nodes ``(A, B)`` to
779
nodes ``(C, D)`` in a single move, it is possible to do so in a few
780
steps::
781

    
782
  # instance is located on A, B
783
  $ gnt-instance replace -n %nodeC% %instance1%
784
  # instance has moved from (A, B) to (A, C)
785
  # we now flip the primary/secondary nodes
786
  $ gnt-instance migrate %instance1%
787
  # instance lives on (C, A)
788
  # we can then change A to D via:
789
  $ gnt-instance replace -n %nodeD% %instance1%
790

    
791
Which brings it into the final configuration of ``(C, D)``. Note that we
792
needed to do two replace-disks operation (two copies of the instance
793
disks), because we needed to get rid of both the original nodes (A and
794
B).
795

    
796
Node operations
797
---------------
798

    
799
There are much fewer node operations available than for instances, but
800
they are equivalently important for maintaining a healthy cluster.
801

    
802
Add/readd
803
+++++++++
804

    
805
It is at any time possible to extend the cluster with one more node, by
806
using the node add operation::
807

    
808
  $ gnt-node add %NEW_NODE%
809

    
810
If the cluster has a replication network defined, then you need to pass
811
the ``-s REPLICATION_IP`` parameter to this option.
812

    
813
A variation of this command can be used to re-configure a node if its
814
Ganeti configuration is broken, for example if it has been reinstalled
815
by mistake::
816

    
817
  $ gnt-node add --readd %EXISTING_NODE%
818

    
819
This will reinitialise the node as if it's been newly added, but while
820
keeping its existing configuration in the cluster (primary/secondary IP,
821
etc.), in other words you won't need to use ``-s`` here.
822

    
823
Changing the node role
824
++++++++++++++++++++++
825

    
826
A node can be in different roles, as explained in the
827
:ref:`terminology-label` section. Promoting a node to the master role is
828
special, while the other roles are handled all via a single command.
829

    
830
Failing over the master node
831
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
832

    
833
If you want to promote a different node to the master role (for whatever
834
reason), run on any other master-candidate node the command::
835

    
836
  $ gnt-cluster master-failover
837

    
838
and the node you ran it on is now the new master. In case you try to run
839
this on a non master-candidate node, you will get an error telling you
840
which nodes are valid.
841

    
842
Changing between the other roles
843
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
844

    
845
The ``gnt-node modify`` command can be used to select a new role::
846

    
847
  # change to master candidate
848
  $ gnt-node modify -C yes %NODE%
849
  # change to drained status
850
  $ gnt-node modify -D yes %NODE%
851
  # change to offline status
852
  $ gnt-node modify -O yes %NODE%
853
  # change to regular mode (reset all flags)
854
  $ gnt-node modify -O no -D no -C no %NODE%
855

    
856
Note that the cluster requires that at any point in time, a certain
857
number of nodes are master candidates, so changing from master candidate
858
to other roles might fail. It is recommended to either force the
859
operation (via the ``--force`` option) or first change the number of
860
master candidates in the cluster - see :ref:`cluster-config-label`.
861

    
862
Evacuating nodes
863
++++++++++++++++
864

    
865
There are two steps of moving instances off a node:
866

    
867
- moving the primary instances (actually converting them into secondary
868
  instances)
869
- moving the secondary instances (including any instances converted in
870
  the step above)
871

    
872
Primary instance conversion
873
~~~~~~~~~~~~~~~~~~~~~~~~~~~
874

    
875
For this step, you can use either individual instance move
876
commands (as seen in :ref:`instance-change-primary-label`) or the bulk
877
per-node versions; these are::
878

    
879
  $ gnt-node migrate %NODE%
880
  $ gnt-node evacuate -s %NODE%
881

    
882
Note that the instance “move” command doesn't currently have a node
883
equivalent.
884

    
885
Both these commands, or the equivalent per-instance command, will make
886
this node the secondary node for the respective instances, whereas their
887
current secondary node will become primary. Note that it is not possible
888
to change in one step the primary node to another node as primary, while
889
keeping the same secondary node.
890

    
891
Secondary instance evacuation
892
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
893

    
894
For the evacuation of secondary instances, a command called
895
:command:`gnt-node evacuate` is provided and its syntax is::
896

    
897
  $ gnt-node evacuate -I %IALLOCATOR_SCRIPT% %NODE%
898
  $ gnt-node evacuate -n %DESTINATION_NODE% %NODE%
899

    
900
The first version will compute the new secondary for each instance in
901
turn using the given iallocator script, whereas the second one will
902
simply move all instances to DESTINATION_NODE.
903

    
904
Removal
905
+++++++
906

    
907
Once a node no longer has any instances (neither primary nor secondary),
908
it's easy to remove it from the cluster::
909

    
910
  $ gnt-node remove %NODE_NAME%
911

    
912
This will deconfigure the node, stop the ganeti daemons on it and leave
913
it hopefully like before it joined to the cluster.
914

    
915
Replication network changes
916
+++++++++++++++++++++++++++
917

    
918
The :command:`gnt-node modify -s` command can be used to change the
919
secondary IP of a node. This operation can only be performed if:
920

    
921
- No instance is active on the target node
922
- The new target IP is reachable from the master's secondary IP
923

    
924
Also this operation will not allow to change a node from single-homed
925
(same primary and secondary ip) to multi-homed (separate replication
926
network) or vice versa, unless:
927

    
928
- The target node is the master node and `--force` is passed.
929
- The target cluster is single-homed and the new primary ip is a change
930
  to single homed for a particular node.
931
- The target cluster is multi-homed and the new primary ip is a change
932
  to multi homed for a particular node.
933

    
934
For example to do a single-homed to multi-homed conversion::
935

    
936
  $ gnt-node modify --force -s %SECONDARY_IP% %MASTER_NAME%
937
  $ gnt-node modify -s %SECONDARY_IP% %NODE1_NAME%
938
  $ gnt-node modify -s %SECONDARY_IP% %NODE2_NAME%
939
  $ gnt-node modify -s %SECONDARY_IP% %NODE3_NAME%
940
  ...
941

    
942
The same commands can be used for multi-homed to single-homed except the
943
secondary IPs should be the same as the primaries for each node, for
944
that case.
945

    
946
Storage handling
947
++++++++++++++++
948

    
949
When using LVM (either standalone or with DRBD), it can become tedious
950
to debug and fix it in case of errors. Furthermore, even file-based
951
storage can become complicated to handle manually on many hosts. Ganeti
952
provides a couple of commands to help with automation.
953

    
954
Logical volumes
955
~~~~~~~~~~~~~~~
956

    
957
This is a command specific to LVM handling. It allows listing the
958
logical volumes on a given node or on all nodes and their association to
959
instances via the ``volumes`` command::
960

    
961
  $ gnt-node volumes
962
  Node  PhysDev   VG    Name             Size Instance
963
  node1 /dev/sdb1 xenvg e61fbc97-….disk0 512M instance17
964
  node1 /dev/sdb1 xenvg ebd1a7d1-….disk0 512M instance19
965
  node2 /dev/sdb1 xenvg 0af08a3d-….disk0 512M instance20
966
  node2 /dev/sdb1 xenvg cc012285-….disk0 512M instance16
967
  node2 /dev/sdb1 xenvg f0fac192-….disk0 512M instance18
968

    
969
The above command maps each logical volume to a volume group and
970
underlying physical volume and (possibly) to an instance.
971

    
972
.. _storage-units-label:
973

    
974
Generalized storage handling
975
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
976

    
977
.. versionadded:: 2.1
978

    
979
Starting with Ganeti 2.1, a new storage framework has been implemented
980
that tries to abstract the handling of the storage type the cluster
981
uses.
982

    
983
First is listing the backend storage and their space situation::
984

    
985
  $ gnt-node list-storage
986
  Node  Name        Size Used   Free
987
  node1 /dev/sda7 673.8G   0M 673.8G
988
  node1 /dev/sdb1 698.6G 1.5G 697.1G
989
  node2 /dev/sda7 673.8G   0M 673.8G
990
  node2 /dev/sdb1 698.6G 1.0G 697.6G
991

    
992
The default is to list LVM physical volumes. It's also possible to list
993
the LVM volume groups::
994

    
995
  $ gnt-node list-storage -t lvm-vg
996
  Node  Name  Size
997
  node1 xenvg 1.3T
998
  node2 xenvg 1.3T
999

    
1000
Next is repairing storage units, which is currently only implemented for
1001
volume groups and does the equivalent of ``vgreduce --removemissing``::
1002

    
1003
  $ gnt-node repair-storage %node2% lvm-vg xenvg
1004
  Sun Oct 25 22:21:45 2009 Repairing storage unit 'xenvg' on node2 ...
1005

    
1006
Last is the modification of volume properties, which is (again) only
1007
implemented for LVM physical volumes and allows toggling the
1008
``allocatable`` value::
1009

    
1010
  $ gnt-node modify-storage --allocatable=no %node2% lvm-pv /dev/%sdb1%
1011

    
1012
Use of the storage commands
1013
~~~~~~~~~~~~~~~~~~~~~~~~~~~
1014

    
1015
All these commands are needed when recovering a node from a disk
1016
failure:
1017

    
1018
- first, we need to recover from complete LVM failure (due to missing
1019
  disk), by running the ``repair-storage`` command
1020
- second, we need to change allocation on any partially-broken disk
1021
  (i.e. LVM still sees it, but it has bad blocks) by running
1022
  ``modify-storage``
1023
- then we can evacuate the instances as needed
1024

    
1025

    
1026
Cluster operations
1027
------------------
1028

    
1029
Beside the cluster initialisation command (which is detailed in the
1030
:doc:`install` document) and the master failover command which is
1031
explained under node handling, there are a couple of other cluster
1032
operations available.
1033

    
1034
.. _cluster-config-label:
1035

    
1036
Standard operations
1037
+++++++++++++++++++
1038

    
1039
One of the few commands that can be run on any node (not only the
1040
master) is the ``getmaster`` command::
1041

    
1042
  # on node2
1043
  $ gnt-cluster getmaster
1044
  node1.example.com
1045

    
1046
It is possible to query and change global cluster parameters via the
1047
``info`` and ``modify`` commands::
1048

    
1049
  $ gnt-cluster info
1050
  Cluster name: cluster.example.com
1051
  Cluster UUID: 07805e6f-f0af-4310-95f1-572862ee939c
1052
  Creation time: 2009-09-25 05:04:15
1053
  Modification time: 2009-10-18 22:11:47
1054
  Master node: node1.example.com
1055
  Architecture (this node): 64bit (x86_64)
1056
1057
  Tags: foo
1058
  Default hypervisor: xen-pvm
1059
  Enabled hypervisors: xen-pvm
1060
  Hypervisor parameters:
1061
    - xen-pvm:
1062
        root_path: /dev/sda1
1063
1064
  Cluster parameters:
1065
    - candidate pool size: 10
1066
1067
  Default instance parameters:
1068
    - default:
1069
        memory: 128
1070
1071
  Default nic parameters:
1072
    - default:
1073
        link: xen-br0
1074
1075

    
1076
There various parameters above can be changed via the ``modify``
1077
commands as follows:
1078

    
1079
- the hypervisor parameters can be changed via ``modify -H
1080
  xen-pvm:root_path=…``, and so on for other hypervisors/key/values
1081
- the "default instance parameters" are changeable via ``modify -B
1082
  parameter=value…`` syntax
1083
- the cluster parameters are changeable via separate options to the
1084
  modify command (e.g. ``--candidate-pool-size``, etc.)
1085

    
1086
For detailed option list see the :manpage:`gnt-cluster(8)` man page.
1087

    
1088
The cluster version can be obtained via the ``version`` command::
1089
  $ gnt-cluster version
1090
  Software version: 2.1.0
1091
  Internode protocol: 20
1092
  Configuration format: 2010000
1093
  OS api version: 15
1094
  Export interface: 0
1095

    
1096
This is not very useful except when debugging Ganeti.
1097

    
1098
Global node commands
1099
++++++++++++++++++++
1100

    
1101
There are two commands provided for replicating files to all nodes of a
1102
cluster and for running commands on all the nodes::
1103

    
1104
  $ gnt-cluster copyfile %/path/to/file%
1105
  $ gnt-cluster command %ls -l /path/to/file%
1106

    
1107
These are simple wrappers over scp/ssh and more advanced usage can be
1108
obtained using :manpage:`dsh(1)` and similar commands. But they are
1109
useful to update an OS script from the master node, for example.
1110

    
1111
Cluster verification
1112
++++++++++++++++++++
1113

    
1114
There are three commands that relate to global cluster checks. The first
1115
one is ``verify`` which gives an overview on the cluster state,
1116
highlighting any issues. In normal operation, this command should return
1117
no ``ERROR`` messages::
1118

    
1119
  $ gnt-cluster verify
1120
  Sun Oct 25 23:08:58 2009 * Verifying global settings
1121
  Sun Oct 25 23:08:58 2009 * Gathering data (2 nodes)
1122
  Sun Oct 25 23:09:00 2009 * Verifying node status
1123
  Sun Oct 25 23:09:00 2009 * Verifying instance status
1124
  Sun Oct 25 23:09:00 2009 * Verifying orphan volumes
1125
  Sun Oct 25 23:09:00 2009 * Verifying remaining instances
1126
  Sun Oct 25 23:09:00 2009 * Verifying N+1 Memory redundancy
1127
  Sun Oct 25 23:09:00 2009 * Other Notes
1128
  Sun Oct 25 23:09:00 2009   - NOTICE: 5 non-redundant instance(s) found.
1129
  Sun Oct 25 23:09:00 2009 * Hooks Results
1130

    
1131
The second command is ``verify-disks``, which checks that the instance's
1132
disks have the correct status based on the desired instance state
1133
(up/down)::
1134

    
1135
  $ gnt-cluster verify-disks
1136

    
1137
Note that this command will show no output when disks are healthy.
1138

    
1139
The last command is used to repair any discrepancies in Ganeti's
1140
recorded disk size and the actual disk size (disk size information is
1141
needed for proper activation and growth of DRBD-based disks)::
1142

    
1143
  $ gnt-cluster repair-disk-sizes
1144
  Sun Oct 25 23:13:16 2009  - INFO: Disk 0 of instance instance1 has mismatched size, correcting: recorded 512, actual 2048
1145
  Sun Oct 25 23:13:17 2009  - WARNING: Invalid result from node node4, ignoring node results
1146

    
1147
The above shows one instance having wrong disk size, and a node which
1148
returned invalid data, and thus we ignored all primary instances of that
1149
node.
1150

    
1151
Configuration redistribution
1152
++++++++++++++++++++++++++++
1153

    
1154
If the verify command complains about file mismatches between the master
1155
and other nodes, due to some node problems or if you manually modified
1156
configuration files, you can force an push of the master configuration
1157
to all other nodes via the ``redist-conf`` command::
1158

    
1159
  $ gnt-cluster redist-conf
1160

    
1161
This command will be silent unless there are problems sending updates to
1162
the other nodes.
1163

    
1164

    
1165
Cluster renaming
1166
++++++++++++++++
1167

    
1168
It is possible to rename a cluster, or to change its IP address, via the
1169
``rename`` command. If only the IP has changed, you need to pass the
1170
current name and Ganeti will realise its IP has changed::
1171

    
1172
  $ gnt-cluster rename %cluster.example.com%
1173
  This will rename the cluster to 'cluster.example.com'. If
1174
  you are connected over the network to the cluster name, the operation
1175
  is very dangerous as the IP address will be removed from the node and
1176
  the change may not go through. Continue?
1177
  y/[n]/?: %y%
1178
  Failure: prerequisites not met for this operation:
1179
  Neither the name nor the IP address of the cluster has changed
1180

    
1181
In the above output, neither value has changed since the cluster
1182
initialisation so the operation is not completed.
1183

    
1184
Queue operations
1185
++++++++++++++++
1186

    
1187
The job queue execution in Ganeti 2.0 and higher can be inspected,
1188
suspended and resumed via the ``queue`` command::
1189

    
1190
  $ gnt-cluster queue info
1191
  The drain flag is unset
1192
  $ gnt-cluster queue drain
1193
  $ gnt-instance stop %instance1%
1194
  Failed to submit job for instance1: Job queue is drained, refusing job
1195
  $ gnt-cluster queue info
1196
  The drain flag is set
1197
  $ gnt-cluster queue undrain
1198

    
1199
This is most useful if you have an active cluster and you need to
1200
upgrade the Ganeti software, or simply restart the software on any node:
1201

    
1202
#. suspend the queue via ``queue drain``
1203
#. wait until there are no more running jobs via ``gnt-job list``
1204
#. restart the master or another node, or upgrade the software
1205
#. resume the queue via ``queue undrain``
1206

    
1207
.. note:: this command only stores a local flag file, and if you
1208
   failover the master, it will not have effect on the new master.
1209

    
1210

    
1211
Watcher control
1212
+++++++++++++++
1213

    
1214
The :manpage:`ganeti-watcher` is a program, usually scheduled via
1215
``cron``, that takes care of cluster maintenance operations (restarting
1216
downed instances, activating down DRBD disks, etc.). However, during
1217
maintenance and troubleshooting, this can get in your way; disabling it
1218
via commenting out the cron job is not so good as this can be
1219
forgotten. Thus there are some commands for automated control of the
1220
watcher: ``pause``, ``info`` and ``continue``::
1221

    
1222
  $ gnt-cluster watcher info
1223
  The watcher is not paused.
1224
  $ gnt-cluster watcher pause %1h%
1225
  The watcher is paused until Mon Oct 26 00:30:37 2009.
1226
  $ gnt-cluster watcher info
1227
  The watcher is paused until Mon Oct 26 00:30:37 2009.
1228
  $ ganeti-watcher -d
1229
  2009-10-25 23:30:47,984:  pid=28867 ganeti-watcher:486 DEBUG Pause has been set, exiting
1230
  $ gnt-cluster watcher continue
1231
  The watcher is no longer paused.
1232
  $ ganeti-watcher -d
1233
  2009-10-25 23:31:04,789:  pid=28976 ganeti-watcher:345 DEBUG Archived 0 jobs, left 0
1234
  2009-10-25 23:31:05,884:  pid=28976 ganeti-watcher:280 DEBUG Got data from cluster, writing instance status file
1235
  2009-10-25 23:31:06,061:  pid=28976 ganeti-watcher:150 DEBUG Data didn't change, just touching status file
1236
  $ gnt-cluster watcher info
1237
  The watcher is not paused.
1238

    
1239
The exact details of the argument to the ``pause`` command are available
1240
in the manpage.
1241

    
1242
.. note:: this command only stores a local flag file, and if you
1243
   failover the master, it will not have effect on the new master.
1244

    
1245
Node auto-maintenance
1246
+++++++++++++++++++++
1247

    
1248
If the cluster parameter ``maintain_node_health`` is enabled (see the
1249
manpage for :command:`gnt-cluster`, the init and modify subcommands),
1250
then the following will happen automatically:
1251

    
1252
- the watcher will shutdown any instances running on offline nodes
1253
- the watcher will deactivate any DRBD devices on offline nodes
1254

    
1255
In the future, more actions are planned, so only enable this parameter
1256
if the nodes are completely dedicated to Ganeti; otherwise it might be
1257
possible to lose data due to auto-maintenance actions.
1258

    
1259
Removing a cluster entirely
1260
+++++++++++++++++++++++++++
1261

    
1262
The usual method to cleanup a cluster is to run ``gnt-cluster destroy``
1263
however if the Ganeti installation is broken in any way then this will
1264
not run.
1265

    
1266
It is possible in such a case to cleanup manually most if not all traces
1267
of a cluster installation by following these steps on all of the nodes:
1268

    
1269
1. Shutdown all instances. This depends on the virtualisation method
1270
   used (Xen, KVM, etc.):
1271

    
1272
  - Xen: run ``xm list`` and ``xm destroy`` on all the non-Domain-0
1273
    instances
1274
  - KVM: kill all the KVM processes
1275
  - chroot: kill all processes under the chroot mountpoints
1276

    
1277
2. If using DRBD, shutdown all DRBD minors (which should by at this time
1278
   no-longer in use by instances); on each node, run ``drbdsetup
1279
   /dev/drbdN down`` for each active DRBD minor.
1280

    
1281
3. If using LVM, cleanup the Ganeti volume group; if only Ganeti created
1282
   logical volumes (and you are not sharing the volume group with the
1283
   OS, for example), then simply running ``lvremove -f xenvg`` (replace
1284
   'xenvg' with your volume group name) should do the required cleanup.
1285

    
1286
4. If using file-based storage, remove recursively all files and
1287
   directories under your file-storage directory: ``rm -rf
1288
   /srv/ganeti/file-storage/*`` replacing the path with the correct path
1289
   for your cluster.
1290

    
1291
5. Stop the ganeti daemons (``/etc/init.d/ganeti stop``) and kill any
1292
   that remain alive (``pgrep ganeti`` and ``pkill ganeti``).
1293

    
1294
6. Remove the ganeti state directory (``rm -rf /var/lib/ganeti/*``),
1295
   replacing the path with the correct path for your installation.
1296

    
1297
7. If using RBD, run ``rbd unmap /dev/rbdN`` to unmap the RBD disks.
1298
   Then remove the RBD disk images used by Ganeti, identified by their
1299
   UUIDs (``rbd rm uuid.rbd.diskN``).
1300

    
1301
On the master node, remove the cluster from the master-netdev (usually
1302
``xen-br0`` for bridged mode, otherwise ``eth0`` or similar), by running
1303
``ip a del $clusterip/32 dev xen-br0`` (use the correct cluster ip and
1304
network device name).
1305

    
1306
At this point, the machines are ready for a cluster creation; in case
1307
you want to remove Ganeti completely, you need to also undo some of the
1308
SSH changes and log directories:
1309

    
1310
- ``rm -rf /var/log/ganeti /srv/ganeti`` (replace with the correct
1311
  paths)
1312
- remove from ``/root/.ssh`` the keys that Ganeti added (check the
1313
  ``authorized_keys`` and ``id_dsa`` files)
1314
- regenerate the host's SSH keys (check the OpenSSH startup scripts)
1315
- uninstall Ganeti
1316

    
1317
Otherwise, if you plan to re-create the cluster, you can just go ahead
1318
and rerun ``gnt-cluster init``.
1319

    
1320
Tags handling
1321
-------------
1322

    
1323
The tags handling (addition, removal, listing) is similar for all the
1324
objects that support it (instances, nodes, and the cluster).
1325

    
1326
Limitations
1327
+++++++++++
1328

    
1329
Note that the set of characters present in a tag and the maximum tag
1330
length are restricted. Currently the maximum length is 128 characters,
1331
there can be at most 4096 tags per object, and the set of characters is
1332
comprised by alphanumeric characters and additionally ``.+*/:@-``.
1333

    
1334
Operations
1335
++++++++++
1336

    
1337
Tags can be added via ``add-tags``::
1338

    
1339
  $ gnt-instance add-tags %INSTANCE% %a% %b% %c%
1340
  $ gnt-node add-tags %INSTANCE% %a% %b% %c%
1341
  $ gnt-cluster add-tags %a% %b% %c%
1342

    
1343

    
1344
The above commands add three tags to an instance, to a node and to the
1345
cluster. Note that the cluster command only takes tags as arguments,
1346
whereas the node and instance commands first required the node and
1347
instance name.
1348

    
1349
Tags can also be added from a file, via the ``--from=FILENAME``
1350
argument. The file is expected to contain one tag per line.
1351

    
1352
Tags can also be remove via a syntax very similar to the add one::
1353

    
1354
  $ gnt-instance remove-tags %INSTANCE% %a% %b% %c%
1355

    
1356
And listed via::
1357

    
1358
  $ gnt-instance list-tags
1359
  $ gnt-node list-tags
1360
  $ gnt-cluster list-tags
1361

    
1362
Global tag search
1363
+++++++++++++++++
1364

    
1365
It is also possible to execute a global search on the all tags defined
1366
in the cluster configuration, via a cluster command::
1367

    
1368
  $ gnt-cluster search-tags %REGEXP%
1369

    
1370
The parameter expected is a regular expression (see
1371
:manpage:`regex(7)`). This will return all tags that match the search,
1372
together with the object they are defined in (the names being show in a
1373
hierarchical kind of way)::
1374

    
1375
  $ gnt-cluster search-tags %o%
1376
  /cluster foo
1377
  /instances/instance1 owner:bar
1378

    
1379

    
1380
Job operations
1381
--------------
1382

    
1383
The various jobs submitted by the instance/node/cluster commands can be
1384
examined, canceled and archived by various invocations of the
1385
``gnt-job`` command.
1386

    
1387
First is the job list command::
1388

    
1389
  $ gnt-job list
1390
  17771 success INSTANCE_QUERY_DATA
1391
  17773 success CLUSTER_VERIFY_DISKS
1392
  17775 success CLUSTER_REPAIR_DISK_SIZES
1393
  17776 error   CLUSTER_RENAME(cluster.example.com)
1394
  17780 success CLUSTER_REDIST_CONF
1395
  17792 success INSTANCE_REBOOT(instance1.example.com)
1396

    
1397
More detailed information about a job can be found via the ``info``
1398
command::
1399

    
1400
  $ gnt-job info %17776%
1401
  Job ID: 17776
1402
    Status: error
1403
    Received:         2009-10-25 23:18:02.180569
1404
    Processing start: 2009-10-25 23:18:02.200335 (delta 0.019766s)
1405
    Processing end:   2009-10-25 23:18:02.279743 (delta 0.079408s)
1406
    Total processing time: 0.099174 seconds
1407
    Opcodes:
1408
      OP_CLUSTER_RENAME
1409
        Status: error
1410
        Processing start: 2009-10-25 23:18:02.200335
1411
        Processing end:   2009-10-25 23:18:02.252282
1412
        Input fields:
1413
          name: cluster.example.com
1414
        Result:
1415
          OpPrereqError
1416
          [Neither the name nor the IP address of the cluster has changed]
1417
        Execution log:
1418

    
1419
During the execution of a job, it's possible to follow the output of a
1420
job, similar to the log that one get from the ``gnt-`` commands, via the
1421
watch command::
1422

    
1423
  $ gnt-instance add --submit … %instance1%
1424
  JobID: 17818
1425
  $ gnt-job watch %17818%
1426
  Output from job 17818 follows
1427
  -----------------------------
1428
  Mon Oct 26 00:22:48 2009  - INFO: Selected nodes for instance instance1 via iallocator dumb: node1, node2
1429
  Mon Oct 26 00:22:49 2009 * creating instance disks...
1430
  Mon Oct 26 00:22:52 2009 adding instance instance1 to cluster config
1431
  Mon Oct 26 00:22:52 2009  - INFO: Waiting for instance instance1 to sync disks.
1432
1433
  Mon Oct 26 00:23:03 2009 creating os for instance instance1 on node node1
1434
  Mon Oct 26 00:23:03 2009 * running the instance OS create scripts...
1435
  Mon Oct 26 00:23:13 2009 * starting instance...
1436
  $
1437

    
1438
This is useful if you need to follow a job's progress from multiple
1439
terminals.
1440

    
1441
A job that has not yet started to run can be canceled::
1442

    
1443
  $ gnt-job cancel %17810%
1444

    
1445
But not one that has already started execution::
1446

    
1447
  $ gnt-job cancel %17805%
1448
  Job 17805 is no longer waiting in the queue
1449

    
1450
There are two queues for jobs: the *current* and the *archive*
1451
queue. Jobs are initially submitted to the current queue, and they stay
1452
in that queue until they have finished execution (either successfully or
1453
not). At that point, they can be moved into the archive queue using e.g.
1454
``gnt-job autoarchive all``. The ``ganeti-watcher`` script will do this
1455
automatically 6 hours after a job is finished. The ``ganeti-cleaner``
1456
script will then remove archived the jobs from the archive directory
1457
after three weeks.
1458

    
1459
Note that ``gnt-job list`` only shows jobs in the current queue.
1460
Archived jobs can be viewed using ``gnt-job info <id>``.
1461

    
1462
Special Ganeti deployments
1463
--------------------------
1464

    
1465
Since Ganeti 2.4, it is possible to extend the Ganeti deployment with
1466
two custom scenarios: Ganeti inside Ganeti and multi-site model.
1467

    
1468
Running Ganeti under Ganeti
1469
+++++++++++++++++++++++++++
1470

    
1471
It is sometimes useful to be able to use a Ganeti instance as a Ganeti
1472
node (part of another cluster, usually). One example scenario is two
1473
small clusters, where we want to have an additional master candidate
1474
that holds the cluster configuration and can be used for helping with
1475
the master voting process.
1476

    
1477
However, these Ganeti instance should not host instances themselves, and
1478
should not be considered in the normal capacity planning, evacuation
1479
strategies, etc. In order to accomplish this, mark these nodes as
1480
non-``vm_capable``::
1481

    
1482
  $ gnt-node modify --vm-capable=no %node3%
1483

    
1484
The vm_capable status can be listed as usual via ``gnt-node list``::
1485

    
1486
  $ gnt-node list -oname,vm_capable
1487
  Node  VMCapable
1488
  node1 Y
1489
  node2 Y
1490
  node3 N
1491

    
1492
When this flag is set, the cluster will not do any operations that
1493
relate to instances on such nodes, e.g. hypervisor operations,
1494
disk-related operations, etc. Basically they will just keep the ssconf
1495
files, and if master candidates the full configuration.
1496

    
1497
Multi-site model
1498
++++++++++++++++
1499

    
1500
If Ganeti is deployed in multi-site model, with each site being a node
1501
group (so that instances are not relocated across the WAN by mistake),
1502
it is conceivable that either the WAN latency is high or that some sites
1503
have a lower reliability than others. In this case, it doesn't make
1504
sense to replicate the job information across all sites (or even outside
1505
of a “central” node group), so it should be possible to restrict which
1506
nodes can become master candidates via the auto-promotion algorithm.
1507

    
1508
Ganeti 2.4 introduces for this purpose a new ``master_capable`` flag,
1509
which (when unset) prevents nodes from being marked as master
1510
candidates, either manually or automatically.
1511

    
1512
As usual, the node modify operation can change this flag::
1513

    
1514
  $ gnt-node modify --auto-promote --master-capable=no %node3%
1515
  Fri Jan  7 06:23:07 2011  - INFO: Demoting from master candidate
1516
  Fri Jan  7 06:23:08 2011  - INFO: Promoted nodes to master candidate role: node4
1517
  Modified node node3
1518
   - master_capable -> False
1519
   - master_candidate -> False
1520

    
1521
And the node list operation will list this flag::
1522

    
1523
  $ gnt-node list -oname,master_capable %node1% %node2% %node3%
1524
  Node  MasterCapable
1525
  node1 Y
1526
  node2 Y
1527
  node3 N
1528

    
1529
Note that marking a node both not ``vm_capable`` and not
1530
``master_capable`` makes the node practically unusable from Ganeti's
1531
point of view. Hence these two flags should be used probably in
1532
contrast: some nodes will be only master candidates (master_capable but
1533
not vm_capable), and other nodes will only hold instances (vm_capable
1534
but not master_capable).
1535

    
1536

    
1537
Ganeti tools
1538
------------
1539

    
1540
Beside the usual ``gnt-`` and ``ganeti-`` commands which are provided
1541
and installed in ``$prefix/sbin`` at install time, there are a couple of
1542
other tools installed which are used seldom but can be helpful in some
1543
cases.
1544

    
1545
lvmstrap
1546
++++++++
1547

    
1548
The ``lvmstrap`` tool, introduced in :ref:`configure-lvm-label` section,
1549
has two modes of operation:
1550

    
1551
- ``diskinfo`` shows the discovered disks on the system and their status
1552
- ``create`` takes all not-in-use disks and creates a volume group out
1553
  of them
1554

    
1555
.. warning:: The ``create`` argument to this command causes data-loss!
1556

    
1557
cfgupgrade
1558
++++++++++
1559

    
1560
The ``cfgupgrade`` tools is used to upgrade between major (and minor)
1561
Ganeti versions. Point-releases are usually transparent for the admin.
1562

    
1563
More information about the upgrade procedure is listed on the wiki at
1564
http://code.google.com/p/ganeti/wiki/UpgradeNotes.
1565

    
1566
There is also a script designed to upgrade from Ganeti 1.2 to 2.0,
1567
called ``cfgupgrade12``.
1568

    
1569
cfgshell
1570
++++++++
1571

    
1572
.. note:: This command is not actively maintained; make sure you backup
1573
   your configuration before using it
1574

    
1575
This can be used as an alternative to direct editing of the
1576
main configuration file if Ganeti has a bug and prevents you, for
1577
example, from removing an instance or a node from the configuration
1578
file.
1579

    
1580
.. _burnin-label:
1581

    
1582
burnin
1583
++++++
1584

    
1585
.. warning:: This command will erase existing instances if given as
1586
   arguments!
1587

    
1588
This tool is used to exercise either the hardware of machines or
1589
alternatively the Ganeti software. It is safe to run on an existing
1590
cluster **as long as you don't pass it existing instance names**.
1591

    
1592
The command will, by default, execute a comprehensive set of operations
1593
against a list of instances, these being:
1594

    
1595
- creation
1596
- disk replacement (for redundant instances)
1597
- failover and migration (for redundant instances)
1598
- move (for non-redundant instances)
1599
- disk growth
1600
- add disks, remove disk
1601
- add NICs, remove NICs
1602
- export and then import
1603
- rename
1604
- reboot
1605
- shutdown/startup
1606
- and finally removal of the test instances
1607

    
1608
Executing all these operations will test that the hardware performs
1609
well: the creation, disk replace, disk add and disk growth will exercise
1610
the storage and network; the migrate command will test the memory of the
1611
systems. Depending on the passed options, it can also test that the
1612
instance OS definitions are executing properly the rename, import and
1613
export operations.
1614

    
1615
sanitize-config
1616
+++++++++++++++
1617

    
1618
This tool takes the Ganeti configuration and outputs a "sanitized"
1619
version, by randomizing or clearing:
1620

    
1621
- DRBD secrets and cluster public key (always)
1622
- host names (optional)
1623
- IPs (optional)
1624
- OS names (optional)
1625
- LV names (optional, only useful for very old clusters which still have
1626
  instances whose LVs are based on the instance name)
1627

    
1628
By default, all optional items are activated except the LV name
1629
randomization. When passing ``--no-randomization``, which disables the
1630
optional items (i.e. just the DRBD secrets and cluster public keys are
1631
randomized), the resulting file can be used as a safety copy of the
1632
cluster config - while not trivial, the layout of the cluster can be
1633
recreated from it and if the instance disks have not been lost it
1634
permits recovery from the loss of all master candidates.
1635

    
1636
move-instance
1637
+++++++++++++
1638

    
1639
See :doc:`separate documentation for move-instance <move-instance>`.
1640

    
1641
.. TODO: document cluster-merge tool
1642

    
1643

    
1644
Other Ganeti projects
1645
---------------------
1646

    
1647
Below is a list (which might not be up-to-date) of additional projects
1648
that can be useful in a Ganeti deployment. They can be downloaded from
1649
the project site (http://code.google.com/p/ganeti/) and the repositories
1650
are also on the project git site (http://git.ganeti.org).
1651

    
1652
NBMA tools
1653
++++++++++
1654

    
1655
The ``ganeti-nbma`` software is designed to allow instances to live on a
1656
separate, virtual network from the nodes, and in an environment where
1657
nodes are not guaranteed to be able to reach each other via multicasting
1658
or broadcasting. For more information see the README in the source
1659
archive.
1660

    
1661
ganeti-htools
1662
+++++++++++++
1663

    
1664
Before Ganeti version 2.5, this was a standalone project; since that
1665
version it is integrated into the Ganeti codebase (see
1666
:doc:`install-quick` for instructions on how to enable it). If you run
1667
an older Ganeti version, you will have to download and build it
1668
separately.
1669

    
1670
For more information and installation instructions, see the README file
1671
in the source archive.
1672

    
1673
.. vim: set textwidth=72 :
1674
.. Local Variables:
1675
.. mode: rst
1676
.. fill-column: 72
1677
.. End: