Statistics
| Branch: | Tag: | Revision:

root / doc / admin.rst @ 7142485a

History | View | Annotate | Download (58.1 kB)

1 ffa6869f Iustin Pop
Ganeti administrator's guide
2 ffa6869f Iustin Pop
============================
3 ffa6869f Iustin Pop
4 fd07c6b3 Iustin Pop
Documents Ganeti version |version|
5 ffa6869f Iustin Pop
6 ffa6869f Iustin Pop
.. contents::
7 ffa6869f Iustin Pop
8 c71a1a3d Iustin Pop
.. highlight:: text
9 c71a1a3d Iustin Pop
10 ffa6869f Iustin Pop
Introduction
11 ffa6869f Iustin Pop
------------
12 ffa6869f Iustin Pop
13 c71a1a3d Iustin Pop
Ganeti is a virtualization cluster management software. You are expected
14 c71a1a3d Iustin Pop
to be a system administrator familiar with your Linux distribution and
15 c71a1a3d Iustin Pop
the Xen or KVM virtualization environments before using it.
16 ffa6869f Iustin Pop
17 ffa6869f Iustin Pop
The various components of Ganeti all have man pages and interactive
18 c71a1a3d Iustin Pop
help. This manual though will help you getting familiar with the system
19 c71a1a3d Iustin Pop
by explaining the most common operations, grouped by related use.
20 ffa6869f Iustin Pop
21 ffa6869f Iustin Pop
After a terminology glossary and a section on the prerequisites needed
22 c71a1a3d Iustin Pop
to use this manual, the rest of this document is divided in sections
23 c71a1a3d Iustin Pop
for the different targets that a command affects: instance, nodes, etc.
24 ffa6869f Iustin Pop
25 c71a1a3d Iustin Pop
.. _terminology-label:
26 ffa6869f Iustin Pop
27 ffa6869f Iustin Pop
Ganeti terminology
28 c71a1a3d Iustin Pop
++++++++++++++++++
29 ffa6869f Iustin Pop
30 c71a1a3d Iustin Pop
This section provides a small introduction to Ganeti terminology, which
31 c71a1a3d Iustin Pop
might be useful when reading the rest of the document.
32 ffa6869f Iustin Pop
33 ffa6869f Iustin Pop
Cluster
34 c71a1a3d Iustin Pop
~~~~~~~
35 ffa6869f Iustin Pop
36 c71a1a3d Iustin Pop
A set of machines (nodes) that cooperate to offer a coherent, highly
37 c71a1a3d Iustin Pop
available virtualization service under a single administration domain.
38 ffa6869f Iustin Pop
39 c71a1a3d Iustin Pop
Node
40 c71a1a3d Iustin Pop
~~~~
41 c71a1a3d Iustin Pop
42 c71a1a3d Iustin Pop
A physical machine which is member of a cluster.  Nodes are the basic
43 c71a1a3d Iustin Pop
cluster infrastructure, and they don't need to be fault tolerant in
44 c71a1a3d Iustin Pop
order to achieve high availability for instances.
45 c71a1a3d Iustin Pop
46 c71a1a3d Iustin Pop
Node can be added and removed (if they host no instances) at will from
47 c71a1a3d Iustin Pop
the cluster. In a HA cluster and only with HA instances, the loss of any
48 c71a1a3d Iustin Pop
single node will not cause disk data loss for any instance; of course,
49 c71a1a3d Iustin Pop
a node crash will cause the crash of the its primary instances.
50 c71a1a3d Iustin Pop
51 c71a1a3d Iustin Pop
A node belonging to a cluster can be in one of the following roles at a
52 c71a1a3d Iustin Pop
given time:
53 c71a1a3d Iustin Pop
54 c71a1a3d Iustin Pop
- *master* node, which is the node from which the cluster is controlled
55 c71a1a3d Iustin Pop
- *master candidate* node, only nodes in this role have the full cluster
56 c71a1a3d Iustin Pop
  configuration and knowledge, and only master candidates can become the
57 c71a1a3d Iustin Pop
  master node
58 c71a1a3d Iustin Pop
- *regular* node, which is the state in which most nodes will be on
59 c71a1a3d Iustin Pop
  bigger clusters (>20 nodes)
60 c71a1a3d Iustin Pop
- *drained* node, nodes in this state are functioning normally but the
61 c71a1a3d Iustin Pop
  cannot receive new instances; the intention is that nodes in this role
62 c71a1a3d Iustin Pop
  have some issue and they are being evacuated for hardware repairs
63 c71a1a3d Iustin Pop
- *offline* node, in which there is a record in the cluster
64 c71a1a3d Iustin Pop
  configuration about the node, but the daemons on the master node will
65 c71a1a3d Iustin Pop
  not talk to this node; any instances declared as having an offline
66 c71a1a3d Iustin Pop
  node as either primary or secondary will be flagged as an error in the
67 c71a1a3d Iustin Pop
  cluster verify operation
68 c71a1a3d Iustin Pop
69 c71a1a3d Iustin Pop
Depending on the role, each node will run a set of daemons:
70 c71a1a3d Iustin Pop
71 c71a1a3d Iustin Pop
- the :command:`ganeti-noded` daemon, which control the manipulation of
72 c71a1a3d Iustin Pop
  this node's hardware resources; it runs on all nodes which are in a
73 c71a1a3d Iustin Pop
  cluster
74 c71a1a3d Iustin Pop
- the :command:`ganeti-confd` daemon (Ganeti 2.1+) which runs on all
75 10d3f678 Iustin Pop
  nodes, but is only functional on master candidate nodes; this daemon
76 10d3f678 Iustin Pop
  can be disabled at configuration time if you don't need its
77 10d3f678 Iustin Pop
  functionality
78 c71a1a3d Iustin Pop
- the :command:`ganeti-rapi` daemon which runs on the master node and
79 c71a1a3d Iustin Pop
  offers an HTTP-based API for the cluster
80 c71a1a3d Iustin Pop
- the :command:`ganeti-masterd` daemon which runs on the master node and
81 c71a1a3d Iustin Pop
  allows control of the cluster
82 ffa6869f Iustin Pop
83 feec31d1 Iustin Pop
Beside the node role, there are other node flags that influence its
84 feec31d1 Iustin Pop
behaviour:
85 feec31d1 Iustin Pop
86 feec31d1 Iustin Pop
- the *master_capable* flag denotes whether the node can ever become a
87 feec31d1 Iustin Pop
  master candidate; setting this to 'no' means that auto-promotion will
88 feec31d1 Iustin Pop
  never make this node a master candidate; this flag can be useful for a
89 feec31d1 Iustin Pop
  remote node that only runs local instances, and having it become a
90 feec31d1 Iustin Pop
  master is impractical due to networking or other constraints
91 feec31d1 Iustin Pop
- the *vm_capable* flag denotes whether the node can host instances or
92 feec31d1 Iustin Pop
  not; for example, one might use a non-vm_capable node just as a master
93 feec31d1 Iustin Pop
  candidate, for configuration backups; setting this flag to no
94 feec31d1 Iustin Pop
  disallows placement of instances of this node, deactivates hypervisor
95 feec31d1 Iustin Pop
  and related checks on it (e.g. bridge checks, LVM check, etc.), and
96 feec31d1 Iustin Pop
  removes it from cluster capacity computations
97 feec31d1 Iustin Pop
98 feec31d1 Iustin Pop
99 ffa6869f Iustin Pop
Instance
100 c71a1a3d Iustin Pop
~~~~~~~~
101 ffa6869f Iustin Pop
102 c71a1a3d Iustin Pop
A virtual machine which runs on a cluster. It can be a fault tolerant,
103 c71a1a3d Iustin Pop
highly available entity.
104 ffa6869f Iustin Pop
105 c71a1a3d Iustin Pop
An instance has various parameters, which are classified in three
106 c71a1a3d Iustin Pop
categories: hypervisor related-parameters (called ``hvparams``), general
107 c71a1a3d Iustin Pop
parameters (called ``beparams``) and per network-card parameters (called
108 c71a1a3d Iustin Pop
``nicparams``). All these parameters can be modified either at instance
109 c71a1a3d Iustin Pop
level or via defaults at cluster level.
110 ffa6869f Iustin Pop
111 c71a1a3d Iustin Pop
Disk template
112 ffa6869f Iustin Pop
~~~~~~~~~~~~~
113 ffa6869f Iustin Pop
114 c71a1a3d Iustin Pop
The are multiple options for the storage provided to an instance; while
115 c71a1a3d Iustin Pop
the instance sees the same virtual drive in all cases, the node-level
116 c71a1a3d Iustin Pop
configuration varies between them.
117 ffa6869f Iustin Pop
118 7ed400f0 Stratos Psomadakis
There are five disk templates you can choose from:
119 ffa6869f Iustin Pop
120 c71a1a3d Iustin Pop
diskless
121 c71a1a3d Iustin Pop
  The instance has no disks. Only used for special purpose operating
122 c71a1a3d Iustin Pop
  systems or for testing.
123 c71a1a3d Iustin Pop
124 c71a1a3d Iustin Pop
file
125 c71a1a3d Iustin Pop
  The instance will use plain files as backend for its disks. No
126 c71a1a3d Iustin Pop
  redundancy is provided, and this is somewhat more difficult to
127 c71a1a3d Iustin Pop
  configure for high performance.
128 c71a1a3d Iustin Pop
129 c71a1a3d Iustin Pop
plain
130 c71a1a3d Iustin Pop
  The instance will use LVM devices as backend for its disks. No
131 c71a1a3d Iustin Pop
  redundancy is provided.
132 c71a1a3d Iustin Pop
133 c71a1a3d Iustin Pop
drbd
134 c71a1a3d Iustin Pop
  .. note:: This is only valid for multi-node clusters using DRBD 8.0+
135 c71a1a3d Iustin Pop
136 c71a1a3d Iustin Pop
  A mirror is set between the local node and a remote one, which must be
137 c71a1a3d Iustin Pop
  specified with the second value of the --node option. Use this option
138 c71a1a3d Iustin Pop
  to obtain a highly available instance that can be failed over to a
139 c71a1a3d Iustin Pop
  remote node should the primary one fail.
140 c71a1a3d Iustin Pop
141 7ed400f0 Stratos Psomadakis
rbd
142 7ed400f0 Stratos Psomadakis
  The instance will use Volumes inside a RADOS cluster as backend for its
143 7ed400f0 Stratos Psomadakis
  disks. It will access them using the RADOS block device (RBD).
144 7ed400f0 Stratos Psomadakis
145 c71a1a3d Iustin Pop
IAllocator
146 c71a1a3d Iustin Pop
~~~~~~~~~~
147 c71a1a3d Iustin Pop
148 c71a1a3d Iustin Pop
A framework for using external (user-provided) scripts to compute the
149 c71a1a3d Iustin Pop
placement of instances on the cluster nodes. This eliminates the need to
150 c71a1a3d Iustin Pop
manually specify nodes in instance add, instance moves, node evacuate,
151 c71a1a3d Iustin Pop
etc.
152 c71a1a3d Iustin Pop
153 c71a1a3d Iustin Pop
In order for Ganeti to be able to use these scripts, they must be place
154 c71a1a3d Iustin Pop
in the iallocator directory (usually ``lib/ganeti/iallocators`` under
155 c71a1a3d Iustin Pop
the installation prefix, e.g. ``/usr/local``).
156 c71a1a3d Iustin Pop
157 c71a1a3d Iustin Pop
โ€œPrimaryโ€ and โ€œsecondaryโ€ concepts
158 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
159 c71a1a3d Iustin Pop
160 c71a1a3d Iustin Pop
An instance has a primary and depending on the disk configuration, might
161 c71a1a3d Iustin Pop
also have a secondary node. The instance always runs on the primary node
162 c71a1a3d Iustin Pop
and only uses its secondary node for disk replication.
163 c71a1a3d Iustin Pop
164 c71a1a3d Iustin Pop
Similarly, the term of primary and secondary instances when talking
165 c71a1a3d Iustin Pop
about a node refers to the set of instances having the given node as
166 c71a1a3d Iustin Pop
primary, respectively secondary.
167 c71a1a3d Iustin Pop
168 c71a1a3d Iustin Pop
Tags
169 c71a1a3d Iustin Pop
~~~~
170 c71a1a3d Iustin Pop
171 c71a1a3d Iustin Pop
Tags are short strings that can be attached to either to cluster itself,
172 c71a1a3d Iustin Pop
or to nodes or instances. They are useful as a very simplistic
173 c71a1a3d Iustin Pop
information store for helping with cluster administration, for example
174 c71a1a3d Iustin Pop
by attaching owner information to each instance after it's created::
175 ffa6869f Iustin Pop
176 c71a1a3d Iustin Pop
  gnt-instance add โ€ฆ instance1
177 c71a1a3d Iustin Pop
  gnt-instance add-tags instance1 owner:user2
178 c71a1a3d Iustin Pop
179 c71a1a3d Iustin Pop
And then by listing each instance and its tags, this information could
180 c71a1a3d Iustin Pop
be used for contacting the users of each instance.
181 c71a1a3d Iustin Pop
182 c71a1a3d Iustin Pop
Jobs and OpCodes
183 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~
184 c71a1a3d Iustin Pop
185 c71a1a3d Iustin Pop
While not directly visible by an end-user, it's useful to know that a
186 c71a1a3d Iustin Pop
basic cluster operation (e.g. starting an instance) is represented
187 c71a1a3d Iustin Pop
internall by Ganeti as an *OpCode* (abbreviation from operation
188 c71a1a3d Iustin Pop
code). These OpCodes are executed as part of a *Job*. The OpCodes in a
189 c71a1a3d Iustin Pop
single Job are processed serially by Ganeti, but different Jobs will be
190 f313e7be Michael Hanselmann
processed (depending on resource availability) in parallel. They will
191 f313e7be Michael Hanselmann
not be executed in the submission order, but depending on resource
192 f313e7be Michael Hanselmann
availability, locks and (starting with Ganeti 2.3) priority. An earlier
193 f313e7be Michael Hanselmann
job may have to wait for a lock while a newer job doesn't need any locks
194 f313e7be Michael Hanselmann
and can be executed right away. Operations requiring a certain order
195 f313e7be Michael Hanselmann
need to be submitted as a single job, or the client must submit one job
196 f313e7be Michael Hanselmann
at a time and wait for it to finish before continuing.
197 c71a1a3d Iustin Pop
198 c71a1a3d Iustin Pop
For example, shutting down the entire cluster can be done by running the
199 c71a1a3d Iustin Pop
command ``gnt-instance shutdown --all``, which will submit for each
200 c71a1a3d Iustin Pop
instance a separate job containing the โ€œshutdown instanceโ€ OpCode.
201 c71a1a3d Iustin Pop
202 c71a1a3d Iustin Pop
203 c71a1a3d Iustin Pop
Prerequisites
204 c71a1a3d Iustin Pop
+++++++++++++
205 c71a1a3d Iustin Pop
206 c71a1a3d Iustin Pop
You need to have your Ganeti cluster installed and configured before you
207 c71a1a3d Iustin Pop
try any of the commands in this document. Please follow the
208 c71a1a3d Iustin Pop
:doc:`install` for instructions on how to do that.
209 c71a1a3d Iustin Pop
210 c71a1a3d Iustin Pop
Instance management
211 c71a1a3d Iustin Pop
-------------------
212 c71a1a3d Iustin Pop
213 c71a1a3d Iustin Pop
Adding an instance
214 c71a1a3d Iustin Pop
++++++++++++++++++
215 c71a1a3d Iustin Pop
216 c71a1a3d Iustin Pop
The add operation might seem complex due to the many parameters it
217 c71a1a3d Iustin Pop
accepts, but once you have understood the (few) required parameters and
218 c71a1a3d Iustin Pop
the customisation capabilities you will see it is an easy operation.
219 c71a1a3d Iustin Pop
220 c71a1a3d Iustin Pop
The add operation requires at minimum five parameters:
221 c71a1a3d Iustin Pop
222 c71a1a3d Iustin Pop
- the OS for the instance
223 c71a1a3d Iustin Pop
- the disk template
224 c71a1a3d Iustin Pop
- the disk count and size
225 c71a1a3d Iustin Pop
- the node specification or alternatively the iallocator to use
226 c71a1a3d Iustin Pop
- and finally the instance name
227 c71a1a3d Iustin Pop
228 c71a1a3d Iustin Pop
The OS for the instance must be visible in the output of the command
229 c71a1a3d Iustin Pop
``gnt-os list`` and specifies which guest OS to install on the instance.
230 c71a1a3d Iustin Pop
231 c71a1a3d Iustin Pop
The disk template specifies what kind of storage to use as backend for
232 c71a1a3d Iustin Pop
the (virtual) disks presented to the instance; note that for instances
233 c71a1a3d Iustin Pop
with multiple virtual disks, they all must be of the same type.
234 c71a1a3d Iustin Pop
235 c71a1a3d Iustin Pop
The node(s) on which the instance will run can be given either manually,
236 c71a1a3d Iustin Pop
via the ``-n`` option, or computed automatically by Ganeti, if you have
237 c71a1a3d Iustin Pop
installed any iallocator script.
238 c71a1a3d Iustin Pop
239 c71a1a3d Iustin Pop
With the above parameters in mind, the command is::
240 ffa6869f Iustin Pop
241 ffa6869f Iustin Pop
  gnt-instance add \
242 c71a1a3d Iustin Pop
    -n TARGET_NODE:SECONDARY_NODE \
243 c71a1a3d Iustin Pop
    -o OS_TYPE \
244 c71a1a3d Iustin Pop
    -t DISK_TEMPLATE -s DISK_SIZE \
245 ffa6869f Iustin Pop
    INSTANCE_NAME
246 ffa6869f Iustin Pop
247 ffa6869f Iustin Pop
The instance name must be resolvable (e.g. exist in DNS) and usually
248 c71a1a3d Iustin Pop
points to an address in the same subnet as the cluster itself.
249 ffa6869f Iustin Pop
250 c71a1a3d Iustin Pop
The above command has the minimum required options; other options you
251 c71a1a3d Iustin Pop
can give include, among others:
252 ffa6869f Iustin Pop
253 d4fcd298 Guido Trotter
- The maximum/minimum memory size (``-B maxmem``, ``-B minmem``)
254 d4fcd298 Guido Trotter
  (``-B memory`` can be used to specify only one size)
255 ffa6869f Iustin Pop
256 ffa6869f Iustin Pop
- The number of virtual CPUs (``-B vcpus``)
257 ffa6869f Iustin Pop
258 ffa6869f Iustin Pop
- Arguments for the NICs of the instance; by default, a single-NIC
259 ffa6869f Iustin Pop
  instance is created. The IP and/or bridge of the NIC can be changed
260 ffa6869f Iustin Pop
  via ``--nic 0:ip=IP,bridge=BRIDGE``
261 ffa6869f Iustin Pop
262 c71a1a3d Iustin Pop
See the manpage for gnt-instance for the detailed option list.
263 ffa6869f Iustin Pop
264 c71a1a3d Iustin Pop
For example if you want to create an highly available instance, with a
265 c71a1a3d Iustin Pop
single disk of 50GB and the default memory size, having primary node
266 c71a1a3d Iustin Pop
``node1`` and secondary node ``node3``, use the following command::
267 ffa6869f Iustin Pop
268 c71a1a3d Iustin Pop
  gnt-instance add -n node1:node3 -o debootstrap -t drbd \
269 c71a1a3d Iustin Pop
    instance1
270 ffa6869f Iustin Pop
271 c71a1a3d Iustin Pop
There is a also a command for batch instance creation from a
272 c71a1a3d Iustin Pop
specification file, see the ``batch-create`` operation in the
273 c71a1a3d Iustin Pop
gnt-instance manual page.
274 ffa6869f Iustin Pop
275 c71a1a3d Iustin Pop
Regular instance operations
276 c71a1a3d Iustin Pop
+++++++++++++++++++++++++++
277 ffa6869f Iustin Pop
278 c71a1a3d Iustin Pop
Removal
279 c71a1a3d Iustin Pop
~~~~~~~
280 ffa6869f Iustin Pop
281 c71a1a3d Iustin Pop
Removing an instance is even easier than creating one. This operation is
282 c71a1a3d Iustin Pop
irreversible and destroys all the contents of your instance. Use with
283 c71a1a3d Iustin Pop
care::
284 ffa6869f Iustin Pop
285 ffa6869f Iustin Pop
  gnt-instance remove INSTANCE_NAME
286 ffa6869f Iustin Pop
287 d4fcd298 Guido Trotter
.. _instance-startup-label:
288 d4fcd298 Guido Trotter
289 c71a1a3d Iustin Pop
Startup/shutdown
290 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~
291 ffa6869f Iustin Pop
292 ffa6869f Iustin Pop
Instances are automatically started at instance creation time. To
293 ffa6869f Iustin Pop
manually start one which is currently stopped you can run::
294 ffa6869f Iustin Pop
295 ffa6869f Iustin Pop
  gnt-instance startup INSTANCE_NAME
296 ffa6869f Iustin Pop
297 d4fcd298 Guido Trotter
Ganeti will start an instance with up to its maximum instance memory. If
298 d4fcd298 Guido Trotter
not enough memory is available Ganeti will use all the available memory
299 d4fcd298 Guido Trotter
down to the instance minumum memory. If not even that amount of memory
300 d4fcd298 Guido Trotter
is free Ganeti will refuse to start the instance.
301 d4fcd298 Guido Trotter
302 edc282ad Agata Murawska
Note, that this will not work when an instance is in a permanently
303 edc282ad Agata Murawska
stopped state ``offline``. In this case, you will first have to
304 edc282ad Agata Murawska
put it back to online mode by running::
305 edc282ad Agata Murawska
306 edc282ad Agata Murawska
  gnt-instance modify --online INSTANCE_NAME
307 edc282ad Agata Murawska
308 edc282ad Agata Murawska
The command to stop the running instance is::
309 ffa6869f Iustin Pop
310 ffa6869f Iustin Pop
  gnt-instance shutdown INSTANCE_NAME
311 ffa6869f Iustin Pop
312 edc282ad Agata Murawska
If you want to shut the instance down more permanently, so that it
313 edc282ad Agata Murawska
does not require dynamically allocated resources (memory and vcpus),
314 edc282ad Agata Murawska
after shutting down an instance, execute the following::
315 edc282ad Agata Murawska
316 d4fcd298 Guido Trotter
  gnt-instance modify --offline INSTANCE_NAME
317 edc282ad Agata Murawska
318 c71a1a3d Iustin Pop
.. warning:: Do not use the Xen or KVM commands directly to stop
319 c71a1a3d Iustin Pop
   instances. If you run for example ``xm shutdown`` or ``xm destroy``
320 44275c2d Andrea Spadaccini
   on an instance Ganeti will automatically restart it (via
321 44275c2d Andrea Spadaccini
   the :command:`ganeti-watcher` command which is launched via cron).
322 c71a1a3d Iustin Pop
323 c71a1a3d Iustin Pop
Querying instances
324 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~
325 c71a1a3d Iustin Pop
326 c71a1a3d Iustin Pop
There are two ways to get information about instances: listing
327 c71a1a3d Iustin Pop
instances, which does a tabular output containing a given set of fields
328 c71a1a3d Iustin Pop
about each instance, and querying detailed information about a set of
329 c71a1a3d Iustin Pop
instances.
330 c71a1a3d Iustin Pop
331 ffa6869f Iustin Pop
The command to see all the instances configured and their status is::
332 ffa6869f Iustin Pop
333 ffa6869f Iustin Pop
  gnt-instance list
334 ffa6869f Iustin Pop
335 c71a1a3d Iustin Pop
The command can return a custom set of information when using the ``-o``
336 c71a1a3d Iustin Pop
option (as always, check the manpage for a detailed specification). Each
337 c71a1a3d Iustin Pop
instance will be represented on a line, thus making it easy to parse
338 c71a1a3d Iustin Pop
this output via the usual shell utilities (grep, sed, etc.).
339 c71a1a3d Iustin Pop
340 c71a1a3d Iustin Pop
To get more detailed information about an instance, you can run::
341 c71a1a3d Iustin Pop
342 c71a1a3d Iustin Pop
  gnt-instance info INSTANCE
343 c71a1a3d Iustin Pop
344 c71a1a3d Iustin Pop
which will give a multi-line block of information about the instance,
345 c71a1a3d Iustin Pop
it's hardware resources (especially its disks and their redundancy
346 c71a1a3d Iustin Pop
status), etc. This is harder to parse and is more expensive than the
347 c71a1a3d Iustin Pop
list operation, but returns much more detailed information.
348 ffa6869f Iustin Pop
349 d4fcd298 Guido Trotter
Changing an instance's runtime memory
350 d4fcd298 Guido Trotter
+++++++++++++++++++++++++++++++++++++
351 d4fcd298 Guido Trotter
352 d4fcd298 Guido Trotter
Ganeti will always make sure an instance has a value between its maximum
353 d4fcd298 Guido Trotter
and its minimum memory available as runtime memory. As of version 2.6
354 d4fcd298 Guido Trotter
Ganeti will only choose a size different than the maximum size when
355 d4fcd298 Guido Trotter
starting up, failing over, or migrating an instance on a node with less
356 d4fcd298 Guido Trotter
than the maximum memory available. It won't resize other instances in
357 d4fcd298 Guido Trotter
order to free up space for an instance.
358 d4fcd298 Guido Trotter
359 d4fcd298 Guido Trotter
If you find that you need more memory on a node any instance can be
360 d4fcd298 Guido Trotter
manually resized without downtime, with the command::
361 d4fcd298 Guido Trotter
362 d4fcd298 Guido Trotter
  gnt-instance modify -m SIZE INSTANCE_NAME
363 d4fcd298 Guido Trotter
364 d4fcd298 Guido Trotter
The same command can also be used to increase the memory available on an
365 d4fcd298 Guido Trotter
instance, provided that enough free memory is available on its node, and
366 d4fcd298 Guido Trotter
the specified size is not larger than the maximum memory size the
367 d4fcd298 Guido Trotter
instance had when it was first booted (an instance will be unable to see
368 d4fcd298 Guido Trotter
new memory above the maximum that was specified to the hypervisor at its
369 d4fcd298 Guido Trotter
boot time, if it needs to grow further a reboot becomes necessary).
370 ffa6869f Iustin Pop
371 c71a1a3d Iustin Pop
Export/Import
372 c71a1a3d Iustin Pop
+++++++++++++
373 c71a1a3d Iustin Pop
374 c71a1a3d Iustin Pop
You can create a snapshot of an instance disk and its Ganeti
375 ffa6869f Iustin Pop
configuration, which then you can backup, or import into another
376 ffa6869f Iustin Pop
cluster. The way to export an instance is::
377 ffa6869f Iustin Pop
378 ffa6869f Iustin Pop
  gnt-backup export -n TARGET_NODE INSTANCE_NAME
379 ffa6869f Iustin Pop
380 c71a1a3d Iustin Pop
381 ffa6869f Iustin Pop
The target node can be any node in the cluster with enough space under
382 c71a1a3d Iustin Pop
``/srv/ganeti`` to hold the instance image. Use the ``--noshutdown``
383 c71a1a3d Iustin Pop
option to snapshot an instance without rebooting it. Note that Ganeti
384 c71a1a3d Iustin Pop
only keeps one snapshot for an instance - any previous snapshot of the
385 c71a1a3d Iustin Pop
same instance existing cluster-wide under ``/srv/ganeti`` will be
386 c71a1a3d Iustin Pop
removed by this operation: if you want to keep them, you need to move
387 c71a1a3d Iustin Pop
them out of the Ganeti exports directory.
388 ffa6869f Iustin Pop
389 c71a1a3d Iustin Pop
Importing an instance is similar to creating a new one, but additionally
390 c71a1a3d Iustin Pop
one must specify the location of the snapshot. The command is::
391 ffa6869f Iustin Pop
392 33ea43b6 Iustin Pop
  gnt-backup import -n TARGET_NODE \
393 ffa6869f Iustin Pop
    --src-node=NODE --src-dir=DIR INSTANCE_NAME
394 ffa6869f Iustin Pop
395 33ea43b6 Iustin Pop
By default, parameters will be read from the export information, but you
396 33ea43b6 Iustin Pop
can of course pass them in via the command line - most of the options
397 33ea43b6 Iustin Pop
available for the command :command:`gnt-instance add` are supported here
398 33ea43b6 Iustin Pop
too.
399 ffa6869f Iustin Pop
400 17227cd1 Iustin Pop
Import of foreign instances
401 17227cd1 Iustin Pop
+++++++++++++++++++++++++++
402 17227cd1 Iustin Pop
403 17227cd1 Iustin Pop
There is a possibility to import a foreign instance whose disk data is
404 17227cd1 Iustin Pop
already stored as LVM volumes without going through copying it: the disk
405 17227cd1 Iustin Pop
adoption mode.
406 17227cd1 Iustin Pop
407 17227cd1 Iustin Pop
For this, ensure that the original, non-managed instance is stopped,
408 17227cd1 Iustin Pop
then create a Ganeti instance in the usual way, except that instead of
409 17227cd1 Iustin Pop
passing the disk information you specify the current volumes::
410 17227cd1 Iustin Pop
411 17227cd1 Iustin Pop
  gnt-instance add -t plain -n HOME_NODE ... \
412 7af3534e Dmitry Chernyak
    --disk 0:adopt=lv_name[,vg=vg_name] INSTANCE_NAME
413 17227cd1 Iustin Pop
414 17227cd1 Iustin Pop
This will take over the given logical volumes, rename them to the Ganeti
415 17227cd1 Iustin Pop
standard (UUID-based), and without installing the OS on them start
416 17227cd1 Iustin Pop
directly the instance. If you configure the hypervisor similar to the
417 17227cd1 Iustin Pop
non-managed configuration that the instance had, the transition should
418 17227cd1 Iustin Pop
be seamless for the instance. For more than one disk, just pass another
419 17227cd1 Iustin Pop
disk parameter (e.g. ``--disk 1:adopt=...``).
420 17227cd1 Iustin Pop
421 fc3914e6 Iustin Pop
Instance kernel selection
422 fc3914e6 Iustin Pop
+++++++++++++++++++++++++
423 fc3914e6 Iustin Pop
424 fc3914e6 Iustin Pop
The kernel that instances uses to bootup can come either from the node,
425 fc3914e6 Iustin Pop
or from instances themselves, depending on the setup.
426 fc3914e6 Iustin Pop
427 fc3914e6 Iustin Pop
Xen-PVM
428 fc3914e6 Iustin Pop
~~~~~~~
429 fc3914e6 Iustin Pop
430 fc3914e6 Iustin Pop
With Xen PVM, there are three options.
431 fc3914e6 Iustin Pop
432 fc3914e6 Iustin Pop
First, you can use a kernel from the node, by setting the hypervisor
433 fc3914e6 Iustin Pop
parameters as such:
434 fc3914e6 Iustin Pop
435 fc3914e6 Iustin Pop
- ``kernel_path`` to a valid file on the node (and appropriately
436 fc3914e6 Iustin Pop
  ``initrd_path``)
437 fc3914e6 Iustin Pop
- ``kernel_args`` optionally set to a valid Linux setting (e.g. ``ro``)
438 fc3914e6 Iustin Pop
- ``root_path`` to a valid setting (e.g. ``/dev/xvda1``)
439 fc3914e6 Iustin Pop
- ``bootloader_path`` and ``bootloader_args`` to empty
440 fc3914e6 Iustin Pop
441 96514751 Michael Hanselmann
Alternatively, you can delegate the kernel management to instances, and
442 fc3914e6 Iustin Pop
use either ``pvgrub`` or the deprecated ``pygrub``. For this, you must
443 96514751 Michael Hanselmann
install the kernels and initrds in the instance and create a valid GRUB
444 fc3914e6 Iustin Pop
v1 configuration file.
445 fc3914e6 Iustin Pop
446 fc3914e6 Iustin Pop
For ``pvgrub`` (new in version 2.4.2), you need to set:
447 fc3914e6 Iustin Pop
448 fc3914e6 Iustin Pop
- ``kernel_path`` to point to the ``pvgrub`` loader present on the node
449 fc3914e6 Iustin Pop
  (e.g. ``/usr/lib/xen/boot/pv-grub-x86_32.gz``)
450 96514751 Michael Hanselmann
- ``kernel_args`` to the path to the GRUB config file, relative to the
451 fc3914e6 Iustin Pop
  instance (e.g. ``(hd0,0)/grub/menu.lst``)
452 fc3914e6 Iustin Pop
- ``root_path`` **must** be empty
453 fc3914e6 Iustin Pop
- ``bootloader_path`` and ``bootloader_args`` to empty
454 fc3914e6 Iustin Pop
455 fc3914e6 Iustin Pop
While ``pygrub`` is deprecated, here is how you can configure it:
456 fc3914e6 Iustin Pop
457 fc3914e6 Iustin Pop
- ``bootloader_path`` to the pygrub binary (e.g. ``/usr/bin/pygrub``)
458 fc3914e6 Iustin Pop
- the other settings are not important
459 fc3914e6 Iustin Pop
460 fc3914e6 Iustin Pop
More information can be found in the Xen wiki pages for `pvgrub
461 fc3914e6 Iustin Pop
<http://wiki.xensource.com/xenwiki/PvGrub>`_ and `pygrub
462 fc3914e6 Iustin Pop
<http://wiki.xensource.com/xenwiki/PyGrub>`_.
463 fc3914e6 Iustin Pop
464 fc3914e6 Iustin Pop
KVM
465 fc3914e6 Iustin Pop
~~~
466 fc3914e6 Iustin Pop
467 fc3914e6 Iustin Pop
For KVM also the kernel can be loaded either way.
468 fc3914e6 Iustin Pop
469 fc3914e6 Iustin Pop
For loading the kernels from the node, you need to set:
470 fc3914e6 Iustin Pop
471 fc3914e6 Iustin Pop
- ``kernel_path`` to a valid value
472 fc3914e6 Iustin Pop
- ``initrd_path`` optionally set if you use an initrd
473 fc3914e6 Iustin Pop
- ``kernel_args`` optionally set to a valid value (e.g. ``ro``)
474 fc3914e6 Iustin Pop
475 fc3914e6 Iustin Pop
If you want instead to have the instance boot from its disk (and execute
476 fc3914e6 Iustin Pop
its bootloader), simply set the ``kernel_path`` parameter to an empty
477 fc3914e6 Iustin Pop
string, and all the others will be ignored.
478 fc3914e6 Iustin Pop
479 c71a1a3d Iustin Pop
Instance HA features
480 c71a1a3d Iustin Pop
--------------------
481 ffa6869f Iustin Pop
482 ffa6869f Iustin Pop
.. note:: This section only applies to multi-node clusters
483 ffa6869f Iustin Pop
484 c71a1a3d Iustin Pop
.. _instance-change-primary-label:
485 c71a1a3d Iustin Pop
486 c71a1a3d Iustin Pop
Changing the primary node
487 c71a1a3d Iustin Pop
+++++++++++++++++++++++++
488 c71a1a3d Iustin Pop
489 c71a1a3d Iustin Pop
There are three ways to exchange an instance's primary and secondary
490 c71a1a3d Iustin Pop
nodes; the right one to choose depends on how the instance has been
491 c71a1a3d Iustin Pop
created and the status of its current primary node. See
492 c71a1a3d Iustin Pop
:ref:`rest-redundancy-label` for information on changing the secondary
493 c71a1a3d Iustin Pop
node. Note that it's only possible to change the primary node to the
494 c71a1a3d Iustin Pop
secondary and vice-versa; a direct change of the primary node with a
495 c71a1a3d Iustin Pop
third node, while keeping the current secondary is not possible in a
496 c71a1a3d Iustin Pop
single step, only via multiple operations as detailed in
497 c71a1a3d Iustin Pop
:ref:`instance-relocation-label`.
498 c71a1a3d Iustin Pop
499 ffa6869f Iustin Pop
Failing over an instance
500 ffa6869f Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~
501 ffa6869f Iustin Pop
502 ffa6869f Iustin Pop
If an instance is built in highly available mode you can at any time
503 ffa6869f Iustin Pop
fail it over to its secondary node, even if the primary has somehow
504 ffa6869f Iustin Pop
failed and it's not up anymore. Doing it is really easy, on the master
505 ffa6869f Iustin Pop
node you can just run::
506 ffa6869f Iustin Pop
507 ffa6869f Iustin Pop
  gnt-instance failover INSTANCE_NAME
508 ffa6869f Iustin Pop
509 ffa6869f Iustin Pop
That's it. After the command completes the secondary node is now the
510 c71a1a3d Iustin Pop
primary, and vice-versa.
511 ffa6869f Iustin Pop
512 d4fcd298 Guido Trotter
The instance will be started with an amount of memory between its
513 d4fcd298 Guido Trotter
``maxmem`` and its ``minmem`` value, depending on the free memory on its
514 d4fcd298 Guido Trotter
target node, or the operation will fail if that's not possible. See
515 d4fcd298 Guido Trotter
:ref:`instance-startup-label` for details.
516 d4fcd298 Guido Trotter
517 7ed400f0 Stratos Psomadakis
If the instance's disk template is of type rbd, then you can specify
518 7ed400f0 Stratos Psomadakis
the target node (which can be any node) explicitly, or specify an
519 7ed400f0 Stratos Psomadakis
iallocator plugin. If you omit both, the default iallocator will be
520 7ed400f0 Stratos Psomadakis
used to determine the target node::
521 7ed400f0 Stratos Psomadakis
522 7ed400f0 Stratos Psomadakis
  gnt-instance failover -n TARGET_NODE INSTANCE_NAME
523 7ed400f0 Stratos Psomadakis
524 ffa6869f Iustin Pop
Live migrating an instance
525 ffa6869f Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~
526 ffa6869f Iustin Pop
527 c71a1a3d Iustin Pop
If an instance is built in highly available mode, it currently runs and
528 c71a1a3d Iustin Pop
both its nodes are running fine, you can at migrate it over to its
529 c71a1a3d Iustin Pop
secondary node, without downtime. On the master node you need to run::
530 ffa6869f Iustin Pop
531 ffa6869f Iustin Pop
  gnt-instance migrate INSTANCE_NAME
532 ffa6869f Iustin Pop
533 c71a1a3d Iustin Pop
The current load on the instance and its memory size will influence how
534 c71a1a3d Iustin Pop
long the migration will take. In any case, for both KVM and Xen
535 c71a1a3d Iustin Pop
hypervisors, the migration will be transparent to the instance.
536 ffa6869f Iustin Pop
537 d4fcd298 Guido Trotter
If the destination node has less memory than the instance's current
538 d4fcd298 Guido Trotter
runtime memory, but at least the instance's minimum memory available
539 d4fcd298 Guido Trotter
Ganeti will automatically reduce the instance runtime memory before
540 d4fcd298 Guido Trotter
migrating it, unless the ``--no-runtime-changes`` option is passed, in
541 d4fcd298 Guido Trotter
which case the target node should have at least the instance's current
542 d4fcd298 Guido Trotter
runtime memory free.
543 d4fcd298 Guido Trotter
544 7ed400f0 Stratos Psomadakis
If the instance's disk template is of type rbd, then you can specify
545 7ed400f0 Stratos Psomadakis
the target node (which can be any node) explicitly, or specify an
546 7ed400f0 Stratos Psomadakis
iallocator plugin. If you omit both, the default iallocator will be
547 7ed400f0 Stratos Psomadakis
used to determine the target node::
548 7ed400f0 Stratos Psomadakis
549 7ed400f0 Stratos Psomadakis
   gnt-instance migrate -n TARGET_NODE INSTANCE_NAME
550 7ed400f0 Stratos Psomadakis
551 c71a1a3d Iustin Pop
Moving an instance (offline)
552 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
553 ffa6869f Iustin Pop
554 c71a1a3d Iustin Pop
If an instance has not been create as mirrored, then the only way to
555 c71a1a3d Iustin Pop
change its primary node is to execute the move command::
556 ffa6869f Iustin Pop
557 c71a1a3d Iustin Pop
  gnt-instance move -n NEW_NODE INSTANCE
558 ffa6869f Iustin Pop
559 c71a1a3d Iustin Pop
This has a few prerequisites:
560 ffa6869f Iustin Pop
561 c71a1a3d Iustin Pop
- the instance must be stopped
562 c71a1a3d Iustin Pop
- its current primary node must be on-line and healthy
563 c71a1a3d Iustin Pop
- the disks of the instance must not have any errors
564 ffa6869f Iustin Pop
565 c71a1a3d Iustin Pop
Since this operation actually copies the data from the old node to the
566 c71a1a3d Iustin Pop
new node, expect it to take proportional to the size of the instance's
567 c71a1a3d Iustin Pop
disks and the speed of both the nodes' I/O system and their networking.
568 ffa6869f Iustin Pop
569 c71a1a3d Iustin Pop
Disk operations
570 c71a1a3d Iustin Pop
+++++++++++++++
571 ffa6869f Iustin Pop
572 c71a1a3d Iustin Pop
Disk failures are a common cause of errors in any server
573 c71a1a3d Iustin Pop
deployment. Ganeti offers protection from single-node failure if your
574 c71a1a3d Iustin Pop
instances were created in HA mode, and it also offers ways to restore
575 c71a1a3d Iustin Pop
redundancy after a failure.
576 ffa6869f Iustin Pop
577 c71a1a3d Iustin Pop
Preparing for disk operations
578 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
579 ffa6869f Iustin Pop
580 c71a1a3d Iustin Pop
It is important to note that for Ganeti to be able to do any disk
581 c71a1a3d Iustin Pop
operation, the Linux machines on top of which Ganeti must be consistent;
582 c71a1a3d Iustin Pop
for LVM, this means that the LVM commands must not return failures; it
583 c71a1a3d Iustin Pop
is common that after a complete disk failure, any LVM command aborts
584 c71a1a3d Iustin Pop
with an error similar to::
585 ffa6869f Iustin Pop
586 c71a1a3d Iustin Pop
  # vgs
587 c71a1a3d Iustin Pop
  /dev/sdb1: read failed after 0 of 4096 at 0: Input/output error
588 c71a1a3d Iustin Pop
  /dev/sdb1: read failed after 0 of 4096 at 750153695232: Input/output
589 c71a1a3d Iustin Pop
  error
590 c71a1a3d Iustin Pop
  /dev/sdb1: read failed after 0 of 4096 at 0: Input/output error
591 c71a1a3d Iustin Pop
  Couldn't find device with uuid
592 c71a1a3d Iustin Pop
  't30jmN-4Rcf-Fr5e-CURS-pawt-z0jU-m1TgeJ'.
593 c71a1a3d Iustin Pop
  Couldn't find all physical volumes for volume group xenvg.
594 ffa6869f Iustin Pop
595 c71a1a3d Iustin Pop
Before restoring an instance's disks to healthy status, it's needed to
596 c71a1a3d Iustin Pop
fix the volume group used by Ganeti so that we can actually create and
597 c71a1a3d Iustin Pop
manage the logical volumes. This is usually done in a multi-step
598 c71a1a3d Iustin Pop
process:
599 ffa6869f Iustin Pop
600 c71a1a3d Iustin Pop
#. first, if the disk is completely gone and LVM commands exit with
601 c71a1a3d Iustin Pop
   โ€œCouldn't find device with uuidโ€ฆโ€ then you need to run the command::
602 c71a1a3d Iustin Pop
603 c71a1a3d Iustin Pop
    vgreduce --removemissing VOLUME_GROUP
604 c71a1a3d Iustin Pop
605 c71a1a3d Iustin Pop
#. after the above command, the LVM commands should be executing
606 c71a1a3d Iustin Pop
   normally (warnings are normal, but the commands will not fail
607 c71a1a3d Iustin Pop
   completely).
608 c71a1a3d Iustin Pop
609 c71a1a3d Iustin Pop
#. if the failed disk is still visible in the output of the ``pvs``
610 c71a1a3d Iustin Pop
   command, you need to deactivate it from allocations by running::
611 c71a1a3d Iustin Pop
612 c71a1a3d Iustin Pop
    pvs -x n /dev/DISK
613 ffa6869f Iustin Pop
614 c71a1a3d Iustin Pop
At this point, the volume group should be consistent and any bad
615 c71a1a3d Iustin Pop
physical volumes should not longer be available for allocation.
616 c71a1a3d Iustin Pop
617 c71a1a3d Iustin Pop
Note that since version 2.1 Ganeti provides some commands to automate
618 c71a1a3d Iustin Pop
these two operations, see :ref:`storage-units-label`.
619 c71a1a3d Iustin Pop
620 c71a1a3d Iustin Pop
.. _rest-redundancy-label:
621 c71a1a3d Iustin Pop
622 c71a1a3d Iustin Pop
Restoring redundancy for DRBD-based instances
623 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
624 c71a1a3d Iustin Pop
625 c71a1a3d Iustin Pop
A DRBD instance has two nodes, and the storage on one of them has
626 c71a1a3d Iustin Pop
failed. Depending on which node (primary or secondary) has failed, you
627 c71a1a3d Iustin Pop
have three options at hand:
628 c71a1a3d Iustin Pop
629 c71a1a3d Iustin Pop
- if the storage on the primary node has failed, you need to re-create
630 c71a1a3d Iustin Pop
  the disks on it
631 c71a1a3d Iustin Pop
- if the storage on the secondary node has failed, you can either
632 c71a1a3d Iustin Pop
  re-create the disks on it or change the secondary and recreate
633 c71a1a3d Iustin Pop
  redundancy on the new secondary node
634 c71a1a3d Iustin Pop
635 c71a1a3d Iustin Pop
Of course, at any point it's possible to force re-creation of disks even
636 c71a1a3d Iustin Pop
though everything is already fine.
637 c71a1a3d Iustin Pop
638 c71a1a3d Iustin Pop
For all three cases, the ``replace-disks`` operation can be used::
639 c71a1a3d Iustin Pop
640 c71a1a3d Iustin Pop
  # re-create disks on the primary node
641 c71a1a3d Iustin Pop
  gnt-instance replace-disks -p INSTANCE_NAME
642 c71a1a3d Iustin Pop
  # re-create disks on the current secondary
643 c71a1a3d Iustin Pop
  gnt-instance replace-disks -s INSTANCE_NAME
644 c71a1a3d Iustin Pop
  # change the secondary node, via manual specification
645 c71a1a3d Iustin Pop
  gnt-instance replace-disks -n NODE INSTANCE_NAME
646 c71a1a3d Iustin Pop
  # change the secondary node, via an iallocator script
647 c71a1a3d Iustin Pop
  gnt-instance replace-disks -I SCRIPT INSTANCE_NAME
648 c71a1a3d Iustin Pop
  # since Ganeti 2.1: automatically fix the primary or secondary node
649 c71a1a3d Iustin Pop
  gnt-instance replace-disks -a INSTANCE_NAME
650 c71a1a3d Iustin Pop
651 c71a1a3d Iustin Pop
Since the process involves copying all data from the working node to the
652 c71a1a3d Iustin Pop
target node, it will take a while, depending on the instance's disk
653 1cdc9dbb Bernardo Dal Seno
size, node I/O system and network speed. But it is (barring any network
654 c71a1a3d Iustin Pop
interruption) completely transparent for the instance.
655 c71a1a3d Iustin Pop
656 c71a1a3d Iustin Pop
Re-creating disks for non-redundant instances
657 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
658 c71a1a3d Iustin Pop
659 c71a1a3d Iustin Pop
.. versionadded:: 2.1
660 c71a1a3d Iustin Pop
661 c71a1a3d Iustin Pop
For non-redundant instances, there isn't a copy (except backups) to
662 c71a1a3d Iustin Pop
re-create the disks. But it's possible to at-least re-create empty
663 c71a1a3d Iustin Pop
disks, after which a reinstall can be run, via the ``recreate-disks``
664 c71a1a3d Iustin Pop
command::
665 c71a1a3d Iustin Pop
666 c71a1a3d Iustin Pop
  gnt-instance recreate-disks INSTANCE
667 c71a1a3d Iustin Pop
668 c71a1a3d Iustin Pop
Note that this will fail if the disks already exists.
669 c71a1a3d Iustin Pop
670 bbf74a76 Iustin Pop
Conversion of an instance's disk type
671 bbf74a76 Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
672 bbf74a76 Iustin Pop
673 bbf74a76 Iustin Pop
It is possible to convert between a non-redundant instance of type
674 bbf74a76 Iustin Pop
``plain`` (LVM storage) and redundant ``drbd`` via the ``gnt-instance
675 bbf74a76 Iustin Pop
modify`` command::
676 bbf74a76 Iustin Pop
677 bbf74a76 Iustin Pop
  # start with a non-redundant instance
678 bbf74a76 Iustin Pop
  gnt-instance add -t plain ... INSTANCE
679 bbf74a76 Iustin Pop
680 bbf74a76 Iustin Pop
  # later convert it to redundant
681 bbf74a76 Iustin Pop
  gnt-instance stop INSTANCE
682 3e039592 Iustin Pop
  gnt-instance modify -t drbd -n NEW_SECONDARY INSTANCE
683 bbf74a76 Iustin Pop
  gnt-instance start INSTANCE
684 bbf74a76 Iustin Pop
685 bbf74a76 Iustin Pop
  # and convert it back
686 bbf74a76 Iustin Pop
  gnt-instance stop INSTANCE
687 bbf74a76 Iustin Pop
  gnt-instance modify -t plain INSTANCE
688 bbf74a76 Iustin Pop
  gnt-instance start INSTANCE
689 bbf74a76 Iustin Pop
690 bbf74a76 Iustin Pop
The conversion must be done while the instance is stopped, and
691 bbf74a76 Iustin Pop
converting from plain to drbd template presents a small risk, especially
692 bbf74a76 Iustin Pop
if the instance has multiple disks and/or if one node fails during the
693 bbf74a76 Iustin Pop
conversion procedure). As such, it's recommended (as always) to make
694 bbf74a76 Iustin Pop
sure that downtime for manual recovery is acceptable and that the
695 bbf74a76 Iustin Pop
instance has up-to-date backups.
696 bbf74a76 Iustin Pop
697 c71a1a3d Iustin Pop
Debugging instances
698 c71a1a3d Iustin Pop
+++++++++++++++++++
699 ffa6869f Iustin Pop
700 ffa6869f Iustin Pop
Accessing an instance's disks
701 ffa6869f Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
702 ffa6869f Iustin Pop
703 c71a1a3d Iustin Pop
From an instance's primary node you can have access to its disks. Never
704 ffa6869f Iustin Pop
ever mount the underlying logical volume manually on a fault tolerant
705 c71a1a3d Iustin Pop
instance, or will break replication and your data will be
706 c71a1a3d Iustin Pop
inconsistent. The correct way to access an instance's disks is to run
707 c71a1a3d Iustin Pop
(on the master node, as usual) the command::
708 c71a1a3d Iustin Pop
709 c71a1a3d Iustin Pop
  gnt-instance activate-disks INSTANCE
710 c71a1a3d Iustin Pop
711 c71a1a3d Iustin Pop
And then, *on the primary node of the instance*, access the device that
712 c71a1a3d Iustin Pop
gets created. For example, you could mount the given disks, then edit
713 c71a1a3d Iustin Pop
files on the filesystem, etc.
714 c71a1a3d Iustin Pop
715 c71a1a3d Iustin Pop
Note that with partitioned disks (as opposed to whole-disk filesystems),
716 c71a1a3d Iustin Pop
you will need to use a tool like :manpage:`kpartx(8)`::
717 ffa6869f Iustin Pop
718 c71a1a3d Iustin Pop
  node1# gnt-instance activate-disks instance1
719 c71a1a3d Iustin Pop
  โ€ฆ
720 c71a1a3d Iustin Pop
  node1# ssh node3
721 c71a1a3d Iustin Pop
  node3# kpartx -l /dev/โ€ฆ
722 c71a1a3d Iustin Pop
  node3# kpartx -a /dev/โ€ฆ
723 c71a1a3d Iustin Pop
  node3# mount /dev/mapper/โ€ฆ /mnt/
724 c71a1a3d Iustin Pop
  # edit files under mnt as desired
725 c71a1a3d Iustin Pop
  node3# umount /mnt/
726 c71a1a3d Iustin Pop
  node3# kpartx -d /dev/โ€ฆ
727 c71a1a3d Iustin Pop
  node3# exit
728 c71a1a3d Iustin Pop
  node1#
729 ffa6869f Iustin Pop
730 c71a1a3d Iustin Pop
After you've finished you can deactivate them with the deactivate-disks
731 c71a1a3d Iustin Pop
command, which works in the same way::
732 c71a1a3d Iustin Pop
733 c71a1a3d Iustin Pop
  gnt-instance deactivate-disks INSTANCE
734 c71a1a3d Iustin Pop
735 c71a1a3d Iustin Pop
Note that if any process started by you is still using the disks, the
736 c71a1a3d Iustin Pop
above command will error out, and you **must** cleanup and ensure that
737 c71a1a3d Iustin Pop
the above command runs successfully before you start the instance,
738 c71a1a3d Iustin Pop
otherwise the instance will suffer corruption.
739 ffa6869f Iustin Pop
740 ffa6869f Iustin Pop
Accessing an instance's console
741 fd07c6b3 Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
742 ffa6869f Iustin Pop
743 ffa6869f Iustin Pop
The command to access a running instance's console is::
744 ffa6869f Iustin Pop
745 ffa6869f Iustin Pop
  gnt-instance console INSTANCE_NAME
746 ffa6869f Iustin Pop
747 c71a1a3d Iustin Pop
Use the console normally and then type ``^]`` when done, to exit.
748 c71a1a3d Iustin Pop
749 c71a1a3d Iustin Pop
Other instance operations
750 c71a1a3d Iustin Pop
+++++++++++++++++++++++++
751 c71a1a3d Iustin Pop
752 c71a1a3d Iustin Pop
Reboot
753 c71a1a3d Iustin Pop
~~~~~~
754 ffa6869f Iustin Pop
755 c71a1a3d Iustin Pop
There is a wrapper command for rebooting instances::
756 ffa6869f Iustin Pop
757 c71a1a3d Iustin Pop
  gnt-instance reboot instance2
758 c71a1a3d Iustin Pop
759 c71a1a3d Iustin Pop
By default, this does the equivalent of shutting down and then starting
760 c71a1a3d Iustin Pop
the instance, but it accepts parameters to perform a soft-reboot (via
761 c71a1a3d Iustin Pop
the hypervisor), a hard reboot (hypervisor shutdown and then startup) or
762 c71a1a3d Iustin Pop
a full one (the default, which also de-configures and then configures
763 c71a1a3d Iustin Pop
again the disks of the instance).
764 c71a1a3d Iustin Pop
765 c71a1a3d Iustin Pop
Instance OS definitions debugging
766 c71a1a3d Iustin Pop
+++++++++++++++++++++++++++++++++
767 c71a1a3d Iustin Pop
768 c71a1a3d Iustin Pop
Should you have any problems with instance operating systems the command
769 c71a1a3d Iustin Pop
to see a complete status for all your nodes is::
770 ffa6869f Iustin Pop
771 ffa6869f Iustin Pop
   gnt-os diagnose
772 ffa6869f Iustin Pop
773 c71a1a3d Iustin Pop
.. _instance-relocation-label:
774 ffa6869f Iustin Pop
775 c71a1a3d Iustin Pop
Instance relocation
776 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~
777 ffa6869f Iustin Pop
778 c71a1a3d Iustin Pop
While it is not possible to move an instance from nodes ``(A, B)`` to
779 c71a1a3d Iustin Pop
nodes ``(C, D)`` in a single move, it is possible to do so in a few
780 c71a1a3d Iustin Pop
steps::
781 ffa6869f Iustin Pop
782 c71a1a3d Iustin Pop
  # instance is located on A, B
783 c71a1a3d Iustin Pop
  node1# gnt-instance replace -n nodeC instance1
784 c71a1a3d Iustin Pop
  # instance has moved from (A, B) to (A, C)
785 c71a1a3d Iustin Pop
  # we now flip the primary/secondary nodes
786 c71a1a3d Iustin Pop
  node1# gnt-instance migrate instance1
787 c71a1a3d Iustin Pop
  # instance lives on (C, A)
788 c71a1a3d Iustin Pop
  # we can then change A to D via:
789 c71a1a3d Iustin Pop
  node1# gnt-instance replace -n nodeD instance1
790 56c9a709 Iustin Pop
791 c71a1a3d Iustin Pop
Which brings it into the final configuration of ``(C, D)``. Note that we
792 c71a1a3d Iustin Pop
needed to do two replace-disks operation (two copies of the instance
793 c71a1a3d Iustin Pop
disks), because we needed to get rid of both the original nodes (A and
794 c71a1a3d Iustin Pop
B).
795 c71a1a3d Iustin Pop
796 c71a1a3d Iustin Pop
Node operations
797 c71a1a3d Iustin Pop
---------------
798 c71a1a3d Iustin Pop
799 c71a1a3d Iustin Pop
There are much fewer node operations available than for instances, but
800 c71a1a3d Iustin Pop
they are equivalently important for maintaining a healthy cluster.
801 c71a1a3d Iustin Pop
802 c71a1a3d Iustin Pop
Add/readd
803 c71a1a3d Iustin Pop
+++++++++
804 c71a1a3d Iustin Pop
805 c71a1a3d Iustin Pop
It is at any time possible to extend the cluster with one more node, by
806 c71a1a3d Iustin Pop
using the node add operation::
807 c71a1a3d Iustin Pop
808 c71a1a3d Iustin Pop
  gnt-node add NEW_NODE
809 c71a1a3d Iustin Pop
810 c71a1a3d Iustin Pop
If the cluster has a replication network defined, then you need to pass
811 c71a1a3d Iustin Pop
the ``-s REPLICATION_IP`` parameter to this option.
812 c71a1a3d Iustin Pop
813 c71a1a3d Iustin Pop
A variation of this command can be used to re-configure a node if its
814 c71a1a3d Iustin Pop
Ganeti configuration is broken, for example if it has been reinstalled
815 c71a1a3d Iustin Pop
by mistake::
816 c71a1a3d Iustin Pop
817 c71a1a3d Iustin Pop
  gnt-node add --readd EXISTING_NODE
818 c71a1a3d Iustin Pop
819 c71a1a3d Iustin Pop
This will reinitialise the node as if it's been newly added, but while
820 c71a1a3d Iustin Pop
keeping its existing configuration in the cluster (primary/secondary IP,
821 c71a1a3d Iustin Pop
etc.), in other words you won't need to use ``-s`` here.
822 c71a1a3d Iustin Pop
823 c71a1a3d Iustin Pop
Changing the node role
824 c71a1a3d Iustin Pop
++++++++++++++++++++++
825 c71a1a3d Iustin Pop
826 c71a1a3d Iustin Pop
A node can be in different roles, as explained in the
827 c71a1a3d Iustin Pop
:ref:`terminology-label` section. Promoting a node to the master role is
828 c71a1a3d Iustin Pop
special, while the other roles are handled all via a single command.
829 c71a1a3d Iustin Pop
830 c71a1a3d Iustin Pop
Failing over the master node
831 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
832 c71a1a3d Iustin Pop
833 c71a1a3d Iustin Pop
If you want to promote a different node to the master role (for whatever
834 c71a1a3d Iustin Pop
reason), run on any other master-candidate node the command::
835 c71a1a3d Iustin Pop
836 c28502b1 Iustin Pop
  gnt-cluster master-failover
837 c71a1a3d Iustin Pop
838 c71a1a3d Iustin Pop
and the node you ran it on is now the new master. In case you try to run
839 c71a1a3d Iustin Pop
this on a non master-candidate node, you will get an error telling you
840 c71a1a3d Iustin Pop
which nodes are valid.
841 c71a1a3d Iustin Pop
842 c71a1a3d Iustin Pop
Changing between the other roles
843 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
844 c71a1a3d Iustin Pop
845 c71a1a3d Iustin Pop
The ``gnt-node modify`` command can be used to select a new role::
846 c71a1a3d Iustin Pop
847 c71a1a3d Iustin Pop
  # change to master candidate
848 c71a1a3d Iustin Pop
  gnt-node modify -C yes NODE
849 c71a1a3d Iustin Pop
  # change to drained status
850 c71a1a3d Iustin Pop
  gnt-node modify -D yes NODE
851 c71a1a3d Iustin Pop
  # change to offline status
852 c71a1a3d Iustin Pop
  gnt-node modify -O yes NODE
853 c71a1a3d Iustin Pop
  # change to regular mode (reset all flags)
854 c71a1a3d Iustin Pop
  gnt-node modify -O no -D no -C no NODE
855 c71a1a3d Iustin Pop
856 c71a1a3d Iustin Pop
Note that the cluster requires that at any point in time, a certain
857 c71a1a3d Iustin Pop
number of nodes are master candidates, so changing from master candidate
858 c71a1a3d Iustin Pop
to other roles might fail. It is recommended to either force the
859 c71a1a3d Iustin Pop
operation (via the ``--force`` option) or first change the number of
860 c71a1a3d Iustin Pop
master candidates in the cluster - see :ref:`cluster-config-label`.
861 c71a1a3d Iustin Pop
862 c71a1a3d Iustin Pop
Evacuating nodes
863 c71a1a3d Iustin Pop
++++++++++++++++
864 c71a1a3d Iustin Pop
865 c71a1a3d Iustin Pop
There are two steps of moving instances off a node:
866 c71a1a3d Iustin Pop
867 c71a1a3d Iustin Pop
- moving the primary instances (actually converting them into secondary
868 c71a1a3d Iustin Pop
  instances)
869 c71a1a3d Iustin Pop
- moving the secondary instances (including any instances converted in
870 c71a1a3d Iustin Pop
  the step above)
871 c71a1a3d Iustin Pop
872 c71a1a3d Iustin Pop
Primary instance conversion
873 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~
874 c71a1a3d Iustin Pop
875 c71a1a3d Iustin Pop
For this step, you can use either individual instance move
876 c71a1a3d Iustin Pop
commands (as seen in :ref:`instance-change-primary-label`) or the bulk
877 c71a1a3d Iustin Pop
per-node versions; these are::
878 c71a1a3d Iustin Pop
879 c71a1a3d Iustin Pop
  gnt-node migrate NODE
880 c71a1a3d Iustin Pop
  gnt-node evacuate NODE
881 c71a1a3d Iustin Pop
882 c71a1a3d Iustin Pop
Note that the instance โ€œmoveโ€ command doesn't currently have a node
883 c71a1a3d Iustin Pop
equivalent.
884 c71a1a3d Iustin Pop
885 c71a1a3d Iustin Pop
Both these commands, or the equivalent per-instance command, will make
886 c71a1a3d Iustin Pop
this node the secondary node for the respective instances, whereas their
887 c71a1a3d Iustin Pop
current secondary node will become primary. Note that it is not possible
888 c71a1a3d Iustin Pop
to change in one step the primary node to another node as primary, while
889 c71a1a3d Iustin Pop
keeping the same secondary node.
890 c71a1a3d Iustin Pop
891 c71a1a3d Iustin Pop
Secondary instance evacuation
892 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
893 c71a1a3d Iustin Pop
894 c71a1a3d Iustin Pop
For the evacuation of secondary instances, a command called
895 c71a1a3d Iustin Pop
:command:`gnt-node evacuate` is provided and its syntax is::
896 c71a1a3d Iustin Pop
897 c71a1a3d Iustin Pop
  gnt-node evacuate -I IALLOCATOR_SCRIPT NODE
898 c71a1a3d Iustin Pop
  gnt-node evacuate -n DESTINATION_NODE NODE
899 c71a1a3d Iustin Pop
900 c71a1a3d Iustin Pop
The first version will compute the new secondary for each instance in
901 c71a1a3d Iustin Pop
turn using the given iallocator script, whereas the second one will
902 c71a1a3d Iustin Pop
simply move all instances to DESTINATION_NODE.
903 c71a1a3d Iustin Pop
904 c71a1a3d Iustin Pop
Removal
905 c71a1a3d Iustin Pop
+++++++
906 c71a1a3d Iustin Pop
907 c71a1a3d Iustin Pop
Once a node no longer has any instances (neither primary nor secondary),
908 c71a1a3d Iustin Pop
it's easy to remove it from the cluster::
909 c71a1a3d Iustin Pop
910 c71a1a3d Iustin Pop
  gnt-node remove NODE_NAME
911 c71a1a3d Iustin Pop
912 c71a1a3d Iustin Pop
This will deconfigure the node, stop the ganeti daemons on it and leave
913 c71a1a3d Iustin Pop
it hopefully like before it joined to the cluster.
914 c71a1a3d Iustin Pop
915 c71a1a3d Iustin Pop
Storage handling
916 c71a1a3d Iustin Pop
++++++++++++++++
917 c71a1a3d Iustin Pop
918 c71a1a3d Iustin Pop
When using LVM (either standalone or with DRBD), it can become tedious
919 c71a1a3d Iustin Pop
to debug and fix it in case of errors. Furthermore, even file-based
920 c71a1a3d Iustin Pop
storage can become complicated to handle manually on many hosts. Ganeti
921 c71a1a3d Iustin Pop
provides a couple of commands to help with automation.
922 c71a1a3d Iustin Pop
923 c71a1a3d Iustin Pop
Logical volumes
924 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~
925 c71a1a3d Iustin Pop
926 c71a1a3d Iustin Pop
This is a command specific to LVM handling. It allows listing the
927 c71a1a3d Iustin Pop
logical volumes on a given node or on all nodes and their association to
928 c71a1a3d Iustin Pop
instances via the ``volumes`` command::
929 c71a1a3d Iustin Pop
930 c71a1a3d Iustin Pop
  node1# gnt-node volumes
931 c71a1a3d Iustin Pop
  Node  PhysDev   VG    Name             Size Instance
932 c71a1a3d Iustin Pop
  node1 /dev/sdb1 xenvg e61fbc97-โ€ฆ.disk0 512M instance17
933 c71a1a3d Iustin Pop
  node1 /dev/sdb1 xenvg ebd1a7d1-โ€ฆ.disk0 512M instance19
934 c71a1a3d Iustin Pop
  node2 /dev/sdb1 xenvg 0af08a3d-โ€ฆ.disk0 512M instance20
935 c71a1a3d Iustin Pop
  node2 /dev/sdb1 xenvg cc012285-โ€ฆ.disk0 512M instance16
936 c71a1a3d Iustin Pop
  node2 /dev/sdb1 xenvg f0fac192-โ€ฆ.disk0 512M instance18
937 c71a1a3d Iustin Pop
938 c71a1a3d Iustin Pop
The above command maps each logical volume to a volume group and
939 c71a1a3d Iustin Pop
underlying physical volume and (possibly) to an instance.
940 c71a1a3d Iustin Pop
941 c71a1a3d Iustin Pop
.. _storage-units-label:
942 c71a1a3d Iustin Pop
943 c71a1a3d Iustin Pop
Generalized storage handling
944 c71a1a3d Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
945 c71a1a3d Iustin Pop
946 c71a1a3d Iustin Pop
.. versionadded:: 2.1
947 c71a1a3d Iustin Pop
948 c71a1a3d Iustin Pop
Starting with Ganeti 2.1, a new storage framework has been implemented
949 c71a1a3d Iustin Pop
that tries to abstract the handling of the storage type the cluster
950 c71a1a3d Iustin Pop
uses.
951 c71a1a3d Iustin Pop
952 c71a1a3d Iustin Pop
First is listing the backend storage and their space situation::
953 c71a1a3d Iustin Pop
954 c71a1a3d Iustin Pop
  node1# gnt-node list-storage
955 c71a1a3d Iustin Pop
  Node  Name        Size Used   Free
956 c71a1a3d Iustin Pop
  node1 /dev/sda7 673.8G   0M 673.8G
957 c71a1a3d Iustin Pop
  node1 /dev/sdb1 698.6G 1.5G 697.1G
958 c71a1a3d Iustin Pop
  node2 /dev/sda7 673.8G   0M 673.8G
959 c71a1a3d Iustin Pop
  node2 /dev/sdb1 698.6G 1.0G 697.6G
960 c71a1a3d Iustin Pop
961 c71a1a3d Iustin Pop
The default is to list LVM physical volumes. It's also possible to list
962 c71a1a3d Iustin Pop
the LVM volume groups::
963 c71a1a3d Iustin Pop
964 c71a1a3d Iustin Pop
  node1# gnt-node list-storage -t lvm-vg
965 c71a1a3d Iustin Pop
  Node  Name  Size
966 c71a1a3d Iustin Pop
  node1 xenvg 1.3T
967 c71a1a3d Iustin Pop
  node2 xenvg 1.3T
968 c71a1a3d Iustin Pop
969 c71a1a3d Iustin Pop
Next is repairing storage units, which is currently only implemented for
970 c71a1a3d Iustin Pop
volume groups and does the equivalent of ``vgreduce --removemissing``::
971 c71a1a3d Iustin Pop
972 c71a1a3d Iustin Pop
  node1# gnt-node repair-storage node2 lvm-vg xenvg
973 c71a1a3d Iustin Pop
  Sun Oct 25 22:21:45 2009 Repairing storage unit 'xenvg' on node2 ...
974 c71a1a3d Iustin Pop
975 c71a1a3d Iustin Pop
Last is the modification of volume properties, which is (again) only
976 c71a1a3d Iustin Pop
implemented for LVM physical volumes and allows toggling the
977 c71a1a3d Iustin Pop
``allocatable`` value::
978 c71a1a3d Iustin Pop
979 c71a1a3d Iustin Pop
  node1# gnt-node modify-storage --allocatable=no node2 lvm-pv /dev/sdb1
980 c71a1a3d Iustin Pop
981 c71a1a3d Iustin Pop
Use of the storage commands
982 56c9a709 Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~
983 56c9a709 Iustin Pop
984 c71a1a3d Iustin Pop
All these commands are needed when recovering a node from a disk
985 c71a1a3d Iustin Pop
failure:
986 c71a1a3d Iustin Pop
987 c71a1a3d Iustin Pop
- first, we need to recover from complete LVM failure (due to missing
988 c71a1a3d Iustin Pop
  disk), by running the ``repair-storage`` command
989 c71a1a3d Iustin Pop
- second, we need to change allocation on any partially-broken disk
990 c71a1a3d Iustin Pop
  (i.e. LVM still sees it, but it has bad blocks) by running
991 c71a1a3d Iustin Pop
  ``modify-storage``
992 c71a1a3d Iustin Pop
- then we can evacuate the instances as needed
993 56c9a709 Iustin Pop
994 56c9a709 Iustin Pop
995 c71a1a3d Iustin Pop
Cluster operations
996 c71a1a3d Iustin Pop
------------------
997 c71a1a3d Iustin Pop
998 c71a1a3d Iustin Pop
Beside the cluster initialisation command (which is detailed in the
999 c71a1a3d Iustin Pop
:doc:`install` document) and the master failover command which is
1000 c71a1a3d Iustin Pop
explained under node handling, there are a couple of other cluster
1001 c71a1a3d Iustin Pop
operations available.
1002 c71a1a3d Iustin Pop
1003 c71a1a3d Iustin Pop
.. _cluster-config-label:
1004 c71a1a3d Iustin Pop
1005 c71a1a3d Iustin Pop
Standard operations
1006 c71a1a3d Iustin Pop
+++++++++++++++++++
1007 c71a1a3d Iustin Pop
1008 c71a1a3d Iustin Pop
One of the few commands that can be run on any node (not only the
1009 c71a1a3d Iustin Pop
master) is the ``getmaster`` command::
1010 c71a1a3d Iustin Pop
1011 c71a1a3d Iustin Pop
  node2# gnt-cluster getmaster
1012 c71a1a3d Iustin Pop
  node1.example.com
1013 c71a1a3d Iustin Pop
  node2#
1014 c71a1a3d Iustin Pop
1015 c71a1a3d Iustin Pop
It is possible to query and change global cluster parameters via the
1016 c71a1a3d Iustin Pop
``info`` and ``modify`` commands::
1017 c71a1a3d Iustin Pop
1018 c71a1a3d Iustin Pop
  node1# gnt-cluster info
1019 c71a1a3d Iustin Pop
  Cluster name: cluster.example.com
1020 c71a1a3d Iustin Pop
  Cluster UUID: 07805e6f-f0af-4310-95f1-572862ee939c
1021 c71a1a3d Iustin Pop
  Creation time: 2009-09-25 05:04:15
1022 c71a1a3d Iustin Pop
  Modification time: 2009-10-18 22:11:47
1023 c71a1a3d Iustin Pop
  Master node: node1.example.com
1024 c71a1a3d Iustin Pop
  Architecture (this node): 64bit (x86_64)
1025 c71a1a3d Iustin Pop
  โ€ฆ
1026 c71a1a3d Iustin Pop
  Tags: foo
1027 c71a1a3d Iustin Pop
  Default hypervisor: xen-pvm
1028 c71a1a3d Iustin Pop
  Enabled hypervisors: xen-pvm
1029 c71a1a3d Iustin Pop
  Hypervisor parameters:
1030 c71a1a3d Iustin Pop
    - xen-pvm:
1031 c71a1a3d Iustin Pop
        root_path: /dev/sda1
1032 c71a1a3d Iustin Pop
        โ€ฆ
1033 c71a1a3d Iustin Pop
  Cluster parameters:
1034 c71a1a3d Iustin Pop
    - candidate pool size: 10
1035 c71a1a3d Iustin Pop
      โ€ฆ
1036 c71a1a3d Iustin Pop
  Default instance parameters:
1037 c71a1a3d Iustin Pop
    - default:
1038 c71a1a3d Iustin Pop
        memory: 128
1039 c71a1a3d Iustin Pop
        โ€ฆ
1040 c71a1a3d Iustin Pop
  Default nic parameters:
1041 c71a1a3d Iustin Pop
    - default:
1042 c71a1a3d Iustin Pop
        link: xen-br0
1043 c71a1a3d Iustin Pop
        โ€ฆ
1044 c71a1a3d Iustin Pop
1045 c71a1a3d Iustin Pop
There various parameters above can be changed via the ``modify``
1046 c71a1a3d Iustin Pop
commands as follows:
1047 c71a1a3d Iustin Pop
1048 c71a1a3d Iustin Pop
- the hypervisor parameters can be changed via ``modify -H
1049 c71a1a3d Iustin Pop
  xen-pvm:root_path=โ€ฆ``, and so on for other hypervisors/key/values
1050 c71a1a3d Iustin Pop
- the "default instance parameters" are changeable via ``modify -B
1051 c71a1a3d Iustin Pop
  parameter=valueโ€ฆ`` syntax
1052 c71a1a3d Iustin Pop
- the cluster parameters are changeable via separate options to the
1053 c71a1a3d Iustin Pop
  modify command (e.g. ``--candidate-pool-size``, etc.)
1054 c71a1a3d Iustin Pop
1055 c71a1a3d Iustin Pop
For detailed option list see the :manpage:`gnt-cluster(8)` man page.
1056 c71a1a3d Iustin Pop
1057 c71a1a3d Iustin Pop
The cluster version can be obtained via the ``version`` command::
1058 c71a1a3d Iustin Pop
  node1# gnt-cluster version
1059 c71a1a3d Iustin Pop
  Software version: 2.1.0
1060 c71a1a3d Iustin Pop
  Internode protocol: 20
1061 c71a1a3d Iustin Pop
  Configuration format: 2010000
1062 c71a1a3d Iustin Pop
  OS api version: 15
1063 c71a1a3d Iustin Pop
  Export interface: 0
1064 c71a1a3d Iustin Pop
1065 c71a1a3d Iustin Pop
This is not very useful except when debugging Ganeti.
1066 c71a1a3d Iustin Pop
1067 c71a1a3d Iustin Pop
Global node commands
1068 c71a1a3d Iustin Pop
++++++++++++++++++++
1069 c71a1a3d Iustin Pop
1070 c71a1a3d Iustin Pop
There are two commands provided for replicating files to all nodes of a
1071 c71a1a3d Iustin Pop
cluster and for running commands on all the nodes::
1072 c71a1a3d Iustin Pop
1073 c71a1a3d Iustin Pop
  node1# gnt-cluster copyfile /path/to/file
1074 c71a1a3d Iustin Pop
  node1# gnt-cluster command ls -l /path/to/file
1075 c71a1a3d Iustin Pop
1076 c71a1a3d Iustin Pop
These are simple wrappers over scp/ssh and more advanced usage can be
1077 c71a1a3d Iustin Pop
obtained using :manpage:`dsh(1)` and similar commands. But they are
1078 c71a1a3d Iustin Pop
useful to update an OS script from the master node, for example.
1079 c71a1a3d Iustin Pop
1080 c71a1a3d Iustin Pop
Cluster verification
1081 c71a1a3d Iustin Pop
++++++++++++++++++++
1082 c71a1a3d Iustin Pop
1083 c71a1a3d Iustin Pop
There are three commands that relate to global cluster checks. The first
1084 c71a1a3d Iustin Pop
one is ``verify`` which gives an overview on the cluster state,
1085 c71a1a3d Iustin Pop
highlighting any issues. In normal operation, this command should return
1086 c71a1a3d Iustin Pop
no ``ERROR`` messages::
1087 c71a1a3d Iustin Pop
1088 c71a1a3d Iustin Pop
  node1# gnt-cluster verify
1089 c71a1a3d Iustin Pop
  Sun Oct 25 23:08:58 2009 * Verifying global settings
1090 c71a1a3d Iustin Pop
  Sun Oct 25 23:08:58 2009 * Gathering data (2 nodes)
1091 c71a1a3d Iustin Pop
  Sun Oct 25 23:09:00 2009 * Verifying node status
1092 c71a1a3d Iustin Pop
  Sun Oct 25 23:09:00 2009 * Verifying instance status
1093 c71a1a3d Iustin Pop
  Sun Oct 25 23:09:00 2009 * Verifying orphan volumes
1094 c71a1a3d Iustin Pop
  Sun Oct 25 23:09:00 2009 * Verifying remaining instances
1095 c71a1a3d Iustin Pop
  Sun Oct 25 23:09:00 2009 * Verifying N+1 Memory redundancy
1096 c71a1a3d Iustin Pop
  Sun Oct 25 23:09:00 2009 * Other Notes
1097 c71a1a3d Iustin Pop
  Sun Oct 25 23:09:00 2009   - NOTICE: 5 non-redundant instance(s) found.
1098 c71a1a3d Iustin Pop
  Sun Oct 25 23:09:00 2009 * Hooks Results
1099 c71a1a3d Iustin Pop
1100 c71a1a3d Iustin Pop
The second command is ``verify-disks``, which checks that the instance's
1101 c71a1a3d Iustin Pop
disks have the correct status based on the desired instance state
1102 c71a1a3d Iustin Pop
(up/down)::
1103 c71a1a3d Iustin Pop
1104 c71a1a3d Iustin Pop
  node1# gnt-cluster verify-disks
1105 c71a1a3d Iustin Pop
1106 c71a1a3d Iustin Pop
Note that this command will show no output when disks are healthy.
1107 c71a1a3d Iustin Pop
1108 c71a1a3d Iustin Pop
The last command is used to repair any discrepancies in Ganeti's
1109 c71a1a3d Iustin Pop
recorded disk size and the actual disk size (disk size information is
1110 c71a1a3d Iustin Pop
needed for proper activation and growth of DRBD-based disks)::
1111 c71a1a3d Iustin Pop
1112 c71a1a3d Iustin Pop
  node1# gnt-cluster repair-disk-sizes
1113 c71a1a3d Iustin Pop
  Sun Oct 25 23:13:16 2009  - INFO: Disk 0 of instance instance1 has mismatched size, correcting: recorded 512, actual 2048
1114 c71a1a3d Iustin Pop
  Sun Oct 25 23:13:17 2009  - WARNING: Invalid result from node node4, ignoring node results
1115 c71a1a3d Iustin Pop
1116 c71a1a3d Iustin Pop
The above shows one instance having wrong disk size, and a node which
1117 c71a1a3d Iustin Pop
returned invalid data, and thus we ignored all primary instances of that
1118 c71a1a3d Iustin Pop
node.
1119 c71a1a3d Iustin Pop
1120 c71a1a3d Iustin Pop
Configuration redistribution
1121 c71a1a3d Iustin Pop
++++++++++++++++++++++++++++
1122 c71a1a3d Iustin Pop
1123 c71a1a3d Iustin Pop
If the verify command complains about file mismatches between the master
1124 c71a1a3d Iustin Pop
and other nodes, due to some node problems or if you manually modified
1125 c71a1a3d Iustin Pop
configuration files, you can force an push of the master configuration
1126 c71a1a3d Iustin Pop
to all other nodes via the ``redist-conf`` command::
1127 c71a1a3d Iustin Pop
1128 c71a1a3d Iustin Pop
  node1# gnt-cluster redist-conf
1129 c71a1a3d Iustin Pop
  node1#
1130 c71a1a3d Iustin Pop
1131 c71a1a3d Iustin Pop
This command will be silent unless there are problems sending updates to
1132 c71a1a3d Iustin Pop
the other nodes.
1133 c71a1a3d Iustin Pop
1134 c71a1a3d Iustin Pop
1135 c71a1a3d Iustin Pop
Cluster renaming
1136 c71a1a3d Iustin Pop
++++++++++++++++
1137 c71a1a3d Iustin Pop
1138 c71a1a3d Iustin Pop
It is possible to rename a cluster, or to change its IP address, via the
1139 c71a1a3d Iustin Pop
``rename`` command. If only the IP has changed, you need to pass the
1140 c71a1a3d Iustin Pop
current name and Ganeti will realise its IP has changed::
1141 c71a1a3d Iustin Pop
1142 c71a1a3d Iustin Pop
  node1# gnt-cluster rename cluster.example.com
1143 c71a1a3d Iustin Pop
  This will rename the cluster to 'cluster.example.com'. If
1144 c71a1a3d Iustin Pop
  you are connected over the network to the cluster name, the operation
1145 c71a1a3d Iustin Pop
  is very dangerous as the IP address will be removed from the node and
1146 c71a1a3d Iustin Pop
  the change may not go through. Continue?
1147 c71a1a3d Iustin Pop
  y/[n]/?: y
1148 c71a1a3d Iustin Pop
  Failure: prerequisites not met for this operation:
1149 c71a1a3d Iustin Pop
  Neither the name nor the IP address of the cluster has changed
1150 c71a1a3d Iustin Pop
1151 c71a1a3d Iustin Pop
In the above output, neither value has changed since the cluster
1152 c71a1a3d Iustin Pop
initialisation so the operation is not completed.
1153 c71a1a3d Iustin Pop
1154 c71a1a3d Iustin Pop
Queue operations
1155 c71a1a3d Iustin Pop
++++++++++++++++
1156 c71a1a3d Iustin Pop
1157 c71a1a3d Iustin Pop
The job queue execution in Ganeti 2.0 and higher can be inspected,
1158 c71a1a3d Iustin Pop
suspended and resumed via the ``queue`` command::
1159 c71a1a3d Iustin Pop
1160 c71a1a3d Iustin Pop
  node1~# gnt-cluster queue info
1161 c71a1a3d Iustin Pop
  The drain flag is unset
1162 c71a1a3d Iustin Pop
  node1~# gnt-cluster queue drain
1163 c71a1a3d Iustin Pop
  node1~# gnt-instance stop instance1
1164 c71a1a3d Iustin Pop
  Failed to submit job for instance1: Job queue is drained, refusing job
1165 c71a1a3d Iustin Pop
  node1~# gnt-cluster queue info
1166 c71a1a3d Iustin Pop
  The drain flag is set
1167 c71a1a3d Iustin Pop
  node1~# gnt-cluster queue undrain
1168 c71a1a3d Iustin Pop
1169 c71a1a3d Iustin Pop
This is most useful if you have an active cluster and you need to
1170 c71a1a3d Iustin Pop
upgrade the Ganeti software, or simply restart the software on any node:
1171 c71a1a3d Iustin Pop
1172 c71a1a3d Iustin Pop
#. suspend the queue via ``queue drain``
1173 c71a1a3d Iustin Pop
#. wait until there are no more running jobs via ``gnt-job list``
1174 c71a1a3d Iustin Pop
#. restart the master or another node, or upgrade the software
1175 c71a1a3d Iustin Pop
#. resume the queue via ``queue undrain``
1176 c71a1a3d Iustin Pop
1177 c71a1a3d Iustin Pop
.. note:: this command only stores a local flag file, and if you
1178 c71a1a3d Iustin Pop
   failover the master, it will not have effect on the new master.
1179 c71a1a3d Iustin Pop
1180 c71a1a3d Iustin Pop
1181 c71a1a3d Iustin Pop
Watcher control
1182 c71a1a3d Iustin Pop
+++++++++++++++
1183 c71a1a3d Iustin Pop
1184 c71a1a3d Iustin Pop
The :manpage:`ganeti-watcher` is a program, usually scheduled via
1185 c71a1a3d Iustin Pop
``cron``, that takes care of cluster maintenance operations (restarting
1186 c71a1a3d Iustin Pop
downed instances, activating down DRBD disks, etc.). However, during
1187 c71a1a3d Iustin Pop
maintenance and troubleshooting, this can get in your way; disabling it
1188 c71a1a3d Iustin Pop
via commenting out the cron job is not so good as this can be
1189 c71a1a3d Iustin Pop
forgotten. Thus there are some commands for automated control of the
1190 c71a1a3d Iustin Pop
watcher: ``pause``, ``info`` and ``continue``::
1191 c71a1a3d Iustin Pop
1192 c71a1a3d Iustin Pop
  node1~# gnt-cluster watcher info
1193 c71a1a3d Iustin Pop
  The watcher is not paused.
1194 c71a1a3d Iustin Pop
  node1~# gnt-cluster watcher pause 1h
1195 c71a1a3d Iustin Pop
  The watcher is paused until Mon Oct 26 00:30:37 2009.
1196 c71a1a3d Iustin Pop
  node1~# gnt-cluster watcher info
1197 c71a1a3d Iustin Pop
  The watcher is paused until Mon Oct 26 00:30:37 2009.
1198 c71a1a3d Iustin Pop
  node1~# ganeti-watcher -d
1199 c71a1a3d Iustin Pop
  2009-10-25 23:30:47,984:  pid=28867 ganeti-watcher:486 DEBUG Pause has been set, exiting
1200 c71a1a3d Iustin Pop
  node1~# gnt-cluster watcher continue
1201 c71a1a3d Iustin Pop
  The watcher is no longer paused.
1202 c71a1a3d Iustin Pop
  node1~# ganeti-watcher -d
1203 c71a1a3d Iustin Pop
  2009-10-25 23:31:04,789:  pid=28976 ganeti-watcher:345 DEBUG Archived 0 jobs, left 0
1204 c71a1a3d Iustin Pop
  2009-10-25 23:31:05,884:  pid=28976 ganeti-watcher:280 DEBUG Got data from cluster, writing instance status file
1205 c71a1a3d Iustin Pop
  2009-10-25 23:31:06,061:  pid=28976 ganeti-watcher:150 DEBUG Data didn't change, just touching status file
1206 c71a1a3d Iustin Pop
  node1~# gnt-cluster watcher info
1207 c71a1a3d Iustin Pop
  The watcher is not paused.
1208 c71a1a3d Iustin Pop
  node1~#
1209 c71a1a3d Iustin Pop
1210 c71a1a3d Iustin Pop
The exact details of the argument to the ``pause`` command are available
1211 c71a1a3d Iustin Pop
in the manpage.
1212 c71a1a3d Iustin Pop
1213 c71a1a3d Iustin Pop
.. note:: this command only stores a local flag file, and if you
1214 c71a1a3d Iustin Pop
   failover the master, it will not have effect on the new master.
1215 c71a1a3d Iustin Pop
1216 6328fea3 Iustin Pop
Node auto-maintenance
1217 6328fea3 Iustin Pop
+++++++++++++++++++++
1218 6328fea3 Iustin Pop
1219 6328fea3 Iustin Pop
If the cluster parameter ``maintain_node_health`` is enabled (see the
1220 6328fea3 Iustin Pop
manpage for :command:`gnt-cluster`, the init and modify subcommands),
1221 6328fea3 Iustin Pop
then the following will happen automatically:
1222 6328fea3 Iustin Pop
1223 6328fea3 Iustin Pop
- the watcher will shutdown any instances running on offline nodes
1224 6328fea3 Iustin Pop
- the watcher will deactivate any DRBD devices on offline nodes
1225 6328fea3 Iustin Pop
1226 6328fea3 Iustin Pop
In the future, more actions are planned, so only enable this parameter
1227 6328fea3 Iustin Pop
if the nodes are completely dedicated to Ganeti; otherwise it might be
1228 6328fea3 Iustin Pop
possible to lose data due to auto-maintenance actions.
1229 6328fea3 Iustin Pop
1230 c71a1a3d Iustin Pop
Removing a cluster entirely
1231 c71a1a3d Iustin Pop
+++++++++++++++++++++++++++
1232 c71a1a3d Iustin Pop
1233 c71a1a3d Iustin Pop
The usual method to cleanup a cluster is to run ``gnt-cluster destroy``
1234 c71a1a3d Iustin Pop
however if the Ganeti installation is broken in any way then this will
1235 c71a1a3d Iustin Pop
not run.
1236 c71a1a3d Iustin Pop
1237 c71a1a3d Iustin Pop
It is possible in such a case to cleanup manually most if not all traces
1238 c71a1a3d Iustin Pop
of a cluster installation by following these steps on all of the nodes:
1239 c71a1a3d Iustin Pop
1240 c71a1a3d Iustin Pop
1. Shutdown all instances. This depends on the virtualisation method
1241 c71a1a3d Iustin Pop
   used (Xen, KVM, etc.):
1242 56c9a709 Iustin Pop
1243 56c9a709 Iustin Pop
  - Xen: run ``xm list`` and ``xm destroy`` on all the non-Domain-0
1244 56c9a709 Iustin Pop
    instances
1245 56c9a709 Iustin Pop
  - KVM: kill all the KVM processes
1246 56c9a709 Iustin Pop
  - chroot: kill all processes under the chroot mountpoints
1247 56c9a709 Iustin Pop
1248 c71a1a3d Iustin Pop
2. If using DRBD, shutdown all DRBD minors (which should by at this time
1249 c71a1a3d Iustin Pop
   no-longer in use by instances); on each node, run ``drbdsetup
1250 56c9a709 Iustin Pop
   /dev/drbdN down`` for each active DRBD minor.
1251 56c9a709 Iustin Pop
1252 c71a1a3d Iustin Pop
3. If using LVM, cleanup the Ganeti volume group; if only Ganeti created
1253 c71a1a3d Iustin Pop
   logical volumes (and you are not sharing the volume group with the
1254 c71a1a3d Iustin Pop
   OS, for example), then simply running ``lvremove -f xenvg`` (replace
1255 c71a1a3d Iustin Pop
   'xenvg' with your volume group name) should do the required cleanup.
1256 56c9a709 Iustin Pop
1257 56c9a709 Iustin Pop
4. If using file-based storage, remove recursively all files and
1258 56c9a709 Iustin Pop
   directories under your file-storage directory: ``rm -rf
1259 c71a1a3d Iustin Pop
   /srv/ganeti/file-storage/*`` replacing the path with the correct path
1260 c71a1a3d Iustin Pop
   for your cluster.
1261 56c9a709 Iustin Pop
1262 56c9a709 Iustin Pop
5. Stop the ganeti daemons (``/etc/init.d/ganeti stop``) and kill any
1263 56c9a709 Iustin Pop
   that remain alive (``pgrep ganeti`` and ``pkill ganeti``).
1264 56c9a709 Iustin Pop
1265 56c9a709 Iustin Pop
6. Remove the ganeti state directory (``rm -rf /var/lib/ganeti/*``),
1266 56c9a709 Iustin Pop
   replacing the path with the correct path for your installation.
1267 56c9a709 Iustin Pop
1268 7ed400f0 Stratos Psomadakis
7. If using RBD, run ``rbd unmap /dev/rbdN`` to unmap the RBD disks.
1269 7ed400f0 Stratos Psomadakis
   Then remove the RBD disk images used by Ganeti, identified by their
1270 7ed400f0 Stratos Psomadakis
   UUIDs (``rbd rm uuid.rbd.diskN``).
1271 7ed400f0 Stratos Psomadakis
1272 56c9a709 Iustin Pop
On the master node, remove the cluster from the master-netdev (usually
1273 c71a1a3d Iustin Pop
``xen-br0`` for bridged mode, otherwise ``eth0`` or similar), by running
1274 c71a1a3d Iustin Pop
``ip a del $clusterip/32 dev xen-br0`` (use the correct cluster ip and
1275 c71a1a3d Iustin Pop
network device name).
1276 56c9a709 Iustin Pop
1277 56c9a709 Iustin Pop
At this point, the machines are ready for a cluster creation; in case
1278 c71a1a3d Iustin Pop
you want to remove Ganeti completely, you need to also undo some of the
1279 c71a1a3d Iustin Pop
SSH changes and log directories:
1280 56c9a709 Iustin Pop
1281 7faf5110 Michael Hanselmann
- ``rm -rf /var/log/ganeti /srv/ganeti`` (replace with the correct
1282 7faf5110 Michael Hanselmann
  paths)
1283 c71a1a3d Iustin Pop
- remove from ``/root/.ssh`` the keys that Ganeti added (check the
1284 c71a1a3d Iustin Pop
  ``authorized_keys`` and ``id_dsa`` files)
1285 56c9a709 Iustin Pop
- regenerate the host's SSH keys (check the OpenSSH startup scripts)
1286 56c9a709 Iustin Pop
- uninstall Ganeti
1287 56c9a709 Iustin Pop
1288 56c9a709 Iustin Pop
Otherwise, if you plan to re-create the cluster, you can just go ahead
1289 56c9a709 Iustin Pop
and rerun ``gnt-cluster init``.
1290 558fd122 Michael Hanselmann
1291 c71a1a3d Iustin Pop
Tags handling
1292 c71a1a3d Iustin Pop
-------------
1293 c71a1a3d Iustin Pop
1294 c71a1a3d Iustin Pop
The tags handling (addition, removal, listing) is similar for all the
1295 c71a1a3d Iustin Pop
objects that support it (instances, nodes, and the cluster).
1296 c71a1a3d Iustin Pop
1297 c71a1a3d Iustin Pop
Limitations
1298 c71a1a3d Iustin Pop
+++++++++++
1299 c71a1a3d Iustin Pop
1300 c71a1a3d Iustin Pop
Note that the set of characters present in a tag and the maximum tag
1301 c71a1a3d Iustin Pop
length are restricted. Currently the maximum length is 128 characters,
1302 c71a1a3d Iustin Pop
there can be at most 4096 tags per object, and the set of characters is
1303 bde65914 Iustin Pop
comprised by alphanumeric characters and additionally ``.+*/:@-``.
1304 c71a1a3d Iustin Pop
1305 c71a1a3d Iustin Pop
Operations
1306 c71a1a3d Iustin Pop
++++++++++
1307 c71a1a3d Iustin Pop
1308 c71a1a3d Iustin Pop
Tags can be added via ``add-tags``::
1309 c71a1a3d Iustin Pop
1310 c71a1a3d Iustin Pop
  gnt-instance add-tags INSTANCE a b c
1311 c71a1a3d Iustin Pop
  gnt-node add-tags INSTANCE a b c
1312 c71a1a3d Iustin Pop
  gnt-cluster add-tags a b c
1313 c71a1a3d Iustin Pop
1314 c71a1a3d Iustin Pop
1315 c71a1a3d Iustin Pop
The above commands add three tags to an instance, to a node and to the
1316 c71a1a3d Iustin Pop
cluster. Note that the cluster command only takes tags as arguments,
1317 c71a1a3d Iustin Pop
whereas the node and instance commands first required the node and
1318 c71a1a3d Iustin Pop
instance name.
1319 c71a1a3d Iustin Pop
1320 c71a1a3d Iustin Pop
Tags can also be added from a file, via the ``--from=FILENAME``
1321 c71a1a3d Iustin Pop
argument. The file is expected to contain one tag per line.
1322 c71a1a3d Iustin Pop
1323 c71a1a3d Iustin Pop
Tags can also be remove via a syntax very similar to the add one::
1324 c71a1a3d Iustin Pop
1325 c71a1a3d Iustin Pop
  gnt-instance remove-tags INSTANCE a b c
1326 c71a1a3d Iustin Pop
1327 c71a1a3d Iustin Pop
And listed via::
1328 c71a1a3d Iustin Pop
1329 c71a1a3d Iustin Pop
  gnt-instance list-tags
1330 c71a1a3d Iustin Pop
  gnt-node list-tags
1331 c71a1a3d Iustin Pop
  gnt-cluster list-tags
1332 c71a1a3d Iustin Pop
1333 c71a1a3d Iustin Pop
Global tag search
1334 c71a1a3d Iustin Pop
+++++++++++++++++
1335 c71a1a3d Iustin Pop
1336 c71a1a3d Iustin Pop
It is also possible to execute a global search on the all tags defined
1337 c71a1a3d Iustin Pop
in the cluster configuration, via a cluster command::
1338 c71a1a3d Iustin Pop
1339 c71a1a3d Iustin Pop
  gnt-cluster search-tags REGEXP
1340 c71a1a3d Iustin Pop
1341 c71a1a3d Iustin Pop
The parameter expected is a regular expression (see
1342 c71a1a3d Iustin Pop
:manpage:`regex(7)`). This will return all tags that match the search,
1343 c71a1a3d Iustin Pop
together with the object they are defined in (the names being show in a
1344 c71a1a3d Iustin Pop
hierarchical kind of way)::
1345 c71a1a3d Iustin Pop
1346 c71a1a3d Iustin Pop
  node1# gnt-cluster search-tags o
1347 c71a1a3d Iustin Pop
  /cluster foo
1348 c71a1a3d Iustin Pop
  /instances/instance1 owner:bar
1349 c71a1a3d Iustin Pop
1350 c71a1a3d Iustin Pop
1351 c71a1a3d Iustin Pop
Job operations
1352 c71a1a3d Iustin Pop
--------------
1353 c71a1a3d Iustin Pop
1354 c71a1a3d Iustin Pop
The various jobs submitted by the instance/node/cluster commands can be
1355 c71a1a3d Iustin Pop
examined, canceled and archived by various invocations of the
1356 c71a1a3d Iustin Pop
``gnt-job`` command.
1357 c71a1a3d Iustin Pop
1358 c71a1a3d Iustin Pop
First is the job list command::
1359 c71a1a3d Iustin Pop
1360 c71a1a3d Iustin Pop
  node1# gnt-job list
1361 c71a1a3d Iustin Pop
  17771 success INSTANCE_QUERY_DATA
1362 c71a1a3d Iustin Pop
  17773 success CLUSTER_VERIFY_DISKS
1363 c71a1a3d Iustin Pop
  17775 success CLUSTER_REPAIR_DISK_SIZES
1364 c71a1a3d Iustin Pop
  17776 error   CLUSTER_RENAME(cluster.example.com)
1365 c71a1a3d Iustin Pop
  17780 success CLUSTER_REDIST_CONF
1366 c71a1a3d Iustin Pop
  17792 success INSTANCE_REBOOT(instance1.example.com)
1367 c71a1a3d Iustin Pop
1368 c71a1a3d Iustin Pop
More detailed information about a job can be found via the ``info``
1369 c71a1a3d Iustin Pop
command::
1370 c71a1a3d Iustin Pop
1371 c71a1a3d Iustin Pop
  node1# gnt-job info 17776
1372 c71a1a3d Iustin Pop
  Job ID: 17776
1373 c71a1a3d Iustin Pop
    Status: error
1374 c71a1a3d Iustin Pop
    Received:         2009-10-25 23:18:02.180569
1375 c71a1a3d Iustin Pop
    Processing start: 2009-10-25 23:18:02.200335 (delta 0.019766s)
1376 c71a1a3d Iustin Pop
    Processing end:   2009-10-25 23:18:02.279743 (delta 0.079408s)
1377 c71a1a3d Iustin Pop
    Total processing time: 0.099174 seconds
1378 c71a1a3d Iustin Pop
    Opcodes:
1379 c71a1a3d Iustin Pop
      OP_CLUSTER_RENAME
1380 c71a1a3d Iustin Pop
        Status: error
1381 c71a1a3d Iustin Pop
        Processing start: 2009-10-25 23:18:02.200335
1382 c71a1a3d Iustin Pop
        Processing end:   2009-10-25 23:18:02.252282
1383 c71a1a3d Iustin Pop
        Input fields:
1384 c71a1a3d Iustin Pop
          name: cluster.example.com
1385 c71a1a3d Iustin Pop
        Result:
1386 c71a1a3d Iustin Pop
          OpPrereqError
1387 c71a1a3d Iustin Pop
          [Neither the name nor the IP address of the cluster has changed]
1388 c71a1a3d Iustin Pop
        Execution log:
1389 c71a1a3d Iustin Pop
1390 c71a1a3d Iustin Pop
During the execution of a job, it's possible to follow the output of a
1391 c71a1a3d Iustin Pop
job, similar to the log that one get from the ``gnt-`` commands, via the
1392 c71a1a3d Iustin Pop
watch command::
1393 c71a1a3d Iustin Pop
1394 c71a1a3d Iustin Pop
  node1# gnt-instance add --submit โ€ฆ instance1
1395 c71a1a3d Iustin Pop
  JobID: 17818
1396 c71a1a3d Iustin Pop
  node1# gnt-job watch 17818
1397 c71a1a3d Iustin Pop
  Output from job 17818 follows
1398 c71a1a3d Iustin Pop
  -----------------------------
1399 c71a1a3d Iustin Pop
  Mon Oct 26 00:22:48 2009  - INFO: Selected nodes for instance instance1 via iallocator dumb: node1, node2
1400 c71a1a3d Iustin Pop
  Mon Oct 26 00:22:49 2009 * creating instance disks...
1401 c71a1a3d Iustin Pop
  Mon Oct 26 00:22:52 2009 adding instance instance1 to cluster config
1402 c71a1a3d Iustin Pop
  Mon Oct 26 00:22:52 2009  - INFO: Waiting for instance instance1 to sync disks.
1403 c71a1a3d Iustin Pop
  โ€ฆ
1404 e0897adf Michael Hanselmann
  Mon Oct 26 00:23:03 2009 creating os for instance instance1 on node node1
1405 c71a1a3d Iustin Pop
  Mon Oct 26 00:23:03 2009 * running the instance OS create scripts...
1406 c71a1a3d Iustin Pop
  Mon Oct 26 00:23:13 2009 * starting instance...
1407 c71a1a3d Iustin Pop
  node1#
1408 c71a1a3d Iustin Pop
1409 c71a1a3d Iustin Pop
This is useful if you need to follow a job's progress from multiple
1410 c71a1a3d Iustin Pop
terminals.
1411 c71a1a3d Iustin Pop
1412 c71a1a3d Iustin Pop
A job that has not yet started to run can be canceled::
1413 c71a1a3d Iustin Pop
1414 c71a1a3d Iustin Pop
  node1# gnt-job cancel 17810
1415 c71a1a3d Iustin Pop
1416 c71a1a3d Iustin Pop
But not one that has already started execution::
1417 c71a1a3d Iustin Pop
1418 c71a1a3d Iustin Pop
  node1# gnt-job cancel 17805
1419 c71a1a3d Iustin Pop
  Job 17805 is no longer waiting in the queue
1420 c71a1a3d Iustin Pop
1421 c71a1a3d Iustin Pop
There are two queues for jobs: the *current* and the *archive*
1422 c71a1a3d Iustin Pop
queue. Jobs are initially submitted to the current queue, and they stay
1423 c71a1a3d Iustin Pop
in that queue until they have finished execution (either successfully or
1424 89907375 Michael Hanselmann
not). At that point, they can be moved into the archive queue using e.g.
1425 89907375 Michael Hanselmann
``gnt-job autoarchive all``. The ``ganeti-watcher`` script will do this
1426 89907375 Michael Hanselmann
automatically 6 hours after a job is finished. The ``ganeti-cleaner``
1427 89907375 Michael Hanselmann
script will then remove archived the jobs from the archive directory
1428 c71a1a3d Iustin Pop
after three weeks.
1429 c71a1a3d Iustin Pop
1430 89907375 Michael Hanselmann
Note that ``gnt-job list`` only shows jobs in the current queue.
1431 89907375 Michael Hanselmann
Archived jobs can be viewed using ``gnt-job info <id>``.
1432 c71a1a3d Iustin Pop
1433 bde65914 Iustin Pop
Special Ganeti deployments
1434 bde65914 Iustin Pop
--------------------------
1435 bde65914 Iustin Pop
1436 bde65914 Iustin Pop
Since Ganeti 2.4, it is possible to extend the Ganeti deployment with
1437 bde65914 Iustin Pop
two custom scenarios: Ganeti inside Ganeti and multi-site model.
1438 bde65914 Iustin Pop
1439 bde65914 Iustin Pop
Running Ganeti under Ganeti
1440 bde65914 Iustin Pop
+++++++++++++++++++++++++++
1441 bde65914 Iustin Pop
1442 bde65914 Iustin Pop
It is sometimes useful to be able to use a Ganeti instance as a Ganeti
1443 bde65914 Iustin Pop
node (part of another cluster, usually). One example scenario is two
1444 bde65914 Iustin Pop
small clusters, where we want to have an additional master candidate
1445 bde65914 Iustin Pop
that holds the cluster configuration and can be used for helping with
1446 bde65914 Iustin Pop
the master voting process.
1447 bde65914 Iustin Pop
1448 bde65914 Iustin Pop
However, these Ganeti instance should not host instances themselves, and
1449 bde65914 Iustin Pop
should not be considered in the normal capacity planning, evacuation
1450 bde65914 Iustin Pop
strategies, etc. In order to accomplish this, mark these nodes as
1451 bde65914 Iustin Pop
non-``vm_capable``::
1452 bde65914 Iustin Pop
1453 bde65914 Iustin Pop
  node1# gnt-node modify --vm-capable=no node3
1454 bde65914 Iustin Pop
1455 bde65914 Iustin Pop
The vm_capable status can be listed as usual via ``gnt-node list``::
1456 bde65914 Iustin Pop
1457 bde65914 Iustin Pop
  node1# gnt-node list -oname,vm_capable
1458 bde65914 Iustin Pop
  Node  VMCapable
1459 bde65914 Iustin Pop
  node1 Y
1460 bde65914 Iustin Pop
  node2 Y
1461 bde65914 Iustin Pop
  node3 N
1462 bde65914 Iustin Pop
1463 bde65914 Iustin Pop
When this flag is set, the cluster will not do any operations that
1464 bde65914 Iustin Pop
relate to instances on such nodes, e.g. hypervisor operations,
1465 bde65914 Iustin Pop
disk-related operations, etc. Basically they will just keep the ssconf
1466 bde65914 Iustin Pop
files, and if master candidates the full configuration.
1467 bde65914 Iustin Pop
1468 bde65914 Iustin Pop
Multi-site model
1469 bde65914 Iustin Pop
++++++++++++++++
1470 bde65914 Iustin Pop
1471 bde65914 Iustin Pop
If Ganeti is deployed in multi-site model, with each site being a node
1472 bde65914 Iustin Pop
group (so that instances are not relocated across the WAN by mistake),
1473 bde65914 Iustin Pop
it is conceivable that either the WAN latency is high or that some sites
1474 bde65914 Iustin Pop
have a lower reliability than others. In this case, it doesn't make
1475 bde65914 Iustin Pop
sense to replicate the job information across all sites (or even outside
1476 bde65914 Iustin Pop
of a โ€œcentralโ€ node group), so it should be possible to restrict which
1477 bde65914 Iustin Pop
nodes can become master candidates via the auto-promotion algorithm.
1478 bde65914 Iustin Pop
1479 bde65914 Iustin Pop
Ganeti 2.4 introduces for this purpose a new ``master_capable`` flag,
1480 bde65914 Iustin Pop
which (when unset) prevents nodes from being marked as master
1481 bde65914 Iustin Pop
candidates, either manually or automatically.
1482 bde65914 Iustin Pop
1483 bde65914 Iustin Pop
As usual, the node modify operation can change this flag::
1484 bde65914 Iustin Pop
1485 bde65914 Iustin Pop
  node1# gnt-node modify --auto-promote --master-capable=no node3
1486 bde65914 Iustin Pop
  Fri Jan  7 06:23:07 2011  - INFO: Demoting from master candidate
1487 bde65914 Iustin Pop
  Fri Jan  7 06:23:08 2011  - INFO: Promoted nodes to master candidate role: node4
1488 bde65914 Iustin Pop
  Modified node node3
1489 bde65914 Iustin Pop
   - master_capable -> False
1490 bde65914 Iustin Pop
   - master_candidate -> False
1491 bde65914 Iustin Pop
1492 bde65914 Iustin Pop
And the node list operation will list this flag::
1493 bde65914 Iustin Pop
1494 bde65914 Iustin Pop
  node1# gnt-node list -oname,master_capable node1 node2 node3
1495 bde65914 Iustin Pop
  Node  MasterCapable
1496 bde65914 Iustin Pop
  node1 Y
1497 bde65914 Iustin Pop
  node2 Y
1498 bde65914 Iustin Pop
  node3 N
1499 bde65914 Iustin Pop
1500 bde65914 Iustin Pop
Note that marking a node both not ``vm_capable`` and not
1501 bde65914 Iustin Pop
``master_capable`` makes the node practically unusable from Ganeti's
1502 bde65914 Iustin Pop
point of view. Hence these two flags should be used probably in
1503 bde65914 Iustin Pop
contrast: some nodes will be only master candidates (master_capable but
1504 bde65914 Iustin Pop
not vm_capable), and other nodes will only hold instances (vm_capable
1505 bde65914 Iustin Pop
but not master_capable).
1506 bde65914 Iustin Pop
1507 bde65914 Iustin Pop
1508 c71a1a3d Iustin Pop
Ganeti tools
1509 c71a1a3d Iustin Pop
------------
1510 c71a1a3d Iustin Pop
1511 c71a1a3d Iustin Pop
Beside the usual ``gnt-`` and ``ganeti-`` commands which are provided
1512 c71a1a3d Iustin Pop
and installed in ``$prefix/sbin`` at install time, there are a couple of
1513 c71a1a3d Iustin Pop
other tools installed which are used seldom but can be helpful in some
1514 c71a1a3d Iustin Pop
cases.
1515 c71a1a3d Iustin Pop
1516 c71a1a3d Iustin Pop
lvmstrap
1517 c71a1a3d Iustin Pop
++++++++
1518 c71a1a3d Iustin Pop
1519 c71a1a3d Iustin Pop
The ``lvmstrap`` tool, introduced in :ref:`configure-lvm-label` section,
1520 c71a1a3d Iustin Pop
has two modes of operation:
1521 c71a1a3d Iustin Pop
1522 c71a1a3d Iustin Pop
- ``diskinfo`` shows the discovered disks on the system and their status
1523 c71a1a3d Iustin Pop
- ``create`` takes all not-in-use disks and creates a volume group out
1524 c71a1a3d Iustin Pop
  of them
1525 c71a1a3d Iustin Pop
1526 c71a1a3d Iustin Pop
.. warning:: The ``create`` argument to this command causes data-loss!
1527 c71a1a3d Iustin Pop
1528 c71a1a3d Iustin Pop
cfgupgrade
1529 c71a1a3d Iustin Pop
++++++++++
1530 c71a1a3d Iustin Pop
1531 c71a1a3d Iustin Pop
The ``cfgupgrade`` tools is used to upgrade between major (and minor)
1532 c71a1a3d Iustin Pop
Ganeti versions. Point-releases are usually transparent for the admin.
1533 c71a1a3d Iustin Pop
1534 c71a1a3d Iustin Pop
More information about the upgrade procedure is listed on the wiki at
1535 c71a1a3d Iustin Pop
http://code.google.com/p/ganeti/wiki/UpgradeNotes.
1536 c71a1a3d Iustin Pop
1537 b5672ea0 Iustin Pop
There is also a script designed to upgrade from Ganeti 1.2 to 2.0,
1538 b5672ea0 Iustin Pop
called ``cfgupgrade12``.
1539 b5672ea0 Iustin Pop
1540 c71a1a3d Iustin Pop
cfgshell
1541 c71a1a3d Iustin Pop
++++++++
1542 c71a1a3d Iustin Pop
1543 c71a1a3d Iustin Pop
.. note:: This command is not actively maintained; make sure you backup
1544 c71a1a3d Iustin Pop
   your configuration before using it
1545 c71a1a3d Iustin Pop
1546 c71a1a3d Iustin Pop
This can be used as an alternative to direct editing of the
1547 c71a1a3d Iustin Pop
main configuration file if Ganeti has a bug and prevents you, for
1548 c71a1a3d Iustin Pop
example, from removing an instance or a node from the configuration
1549 c71a1a3d Iustin Pop
file.
1550 c71a1a3d Iustin Pop
1551 c71a1a3d Iustin Pop
.. _burnin-label:
1552 c71a1a3d Iustin Pop
1553 c71a1a3d Iustin Pop
burnin
1554 c71a1a3d Iustin Pop
++++++
1555 c71a1a3d Iustin Pop
1556 c71a1a3d Iustin Pop
.. warning:: This command will erase existing instances if given as
1557 c71a1a3d Iustin Pop
   arguments!
1558 c71a1a3d Iustin Pop
1559 c71a1a3d Iustin Pop
This tool is used to exercise either the hardware of machines or
1560 c71a1a3d Iustin Pop
alternatively the Ganeti software. It is safe to run on an existing
1561 c71a1a3d Iustin Pop
cluster **as long as you don't pass it existing instance names**.
1562 c71a1a3d Iustin Pop
1563 c71a1a3d Iustin Pop
The command will, by default, execute a comprehensive set of operations
1564 c71a1a3d Iustin Pop
against a list of instances, these being:
1565 c71a1a3d Iustin Pop
1566 c71a1a3d Iustin Pop
- creation
1567 c71a1a3d Iustin Pop
- disk replacement (for redundant instances)
1568 c71a1a3d Iustin Pop
- failover and migration (for redundant instances)
1569 c71a1a3d Iustin Pop
- move (for non-redundant instances)
1570 c71a1a3d Iustin Pop
- disk growth
1571 c71a1a3d Iustin Pop
- add disks, remove disk
1572 c71a1a3d Iustin Pop
- add NICs, remove NICs
1573 c71a1a3d Iustin Pop
- export and then import
1574 c71a1a3d Iustin Pop
- rename
1575 c71a1a3d Iustin Pop
- reboot
1576 c71a1a3d Iustin Pop
- shutdown/startup
1577 c71a1a3d Iustin Pop
- and finally removal of the test instances
1578 c71a1a3d Iustin Pop
1579 c71a1a3d Iustin Pop
Executing all these operations will test that the hardware performs
1580 c71a1a3d Iustin Pop
well: the creation, disk replace, disk add and disk growth will exercise
1581 c71a1a3d Iustin Pop
the storage and network; the migrate command will test the memory of the
1582 c71a1a3d Iustin Pop
systems. Depending on the passed options, it can also test that the
1583 c71a1a3d Iustin Pop
instance OS definitions are executing properly the rename, import and
1584 c71a1a3d Iustin Pop
export operations.
1585 c71a1a3d Iustin Pop
1586 ea5fd476 Iustin Pop
sanitize-config
1587 ea5fd476 Iustin Pop
+++++++++++++++
1588 ea5fd476 Iustin Pop
1589 ea5fd476 Iustin Pop
This tool takes the Ganeti configuration and outputs a "sanitized"
1590 ea5fd476 Iustin Pop
version, by randomizing or clearing:
1591 ea5fd476 Iustin Pop
1592 ea5fd476 Iustin Pop
- DRBD secrets and cluster public key (always)
1593 ea5fd476 Iustin Pop
- host names (optional)
1594 ea5fd476 Iustin Pop
- IPs (optional)
1595 ea5fd476 Iustin Pop
- OS names (optional)
1596 ea5fd476 Iustin Pop
- LV names (optional, only useful for very old clusters which still have
1597 ea5fd476 Iustin Pop
  instances whose LVs are based on the instance name)
1598 ea5fd476 Iustin Pop
1599 ea5fd476 Iustin Pop
By default, all optional items are activated except the LV name
1600 ea5fd476 Iustin Pop
randomization. When passing ``--no-randomization``, which disables the
1601 ea5fd476 Iustin Pop
optional items (i.e. just the DRBD secrets and cluster public keys are
1602 ea5fd476 Iustin Pop
randomized), the resulting file can be used as a safety copy of the
1603 ea5fd476 Iustin Pop
cluster config - while not trivial, the layout of the cluster can be
1604 ea5fd476 Iustin Pop
recreated from it and if the instance disks have not been lost it
1605 ea5fd476 Iustin Pop
permits recovery from the loss of all master candidates.
1606 ea5fd476 Iustin Pop
1607 e0897adf Michael Hanselmann
move-instance
1608 e0897adf Michael Hanselmann
+++++++++++++
1609 e0897adf Michael Hanselmann
1610 e0897adf Michael Hanselmann
See :doc:`separate documentation for move-instance <move-instance>`.
1611 e0897adf Michael Hanselmann
1612 e0897adf Michael Hanselmann
.. TODO: document cluster-merge tool
1613 e0897adf Michael Hanselmann
1614 ea5fd476 Iustin Pop
1615 c71a1a3d Iustin Pop
Other Ganeti projects
1616 c71a1a3d Iustin Pop
---------------------
1617 c71a1a3d Iustin Pop
1618 1ebe6dbd Iustin Pop
Below is a list (which might not be up-to-date) of additional projects
1619 1ebe6dbd Iustin Pop
that can be useful in a Ganeti deployment. They can be downloaded from
1620 1ebe6dbd Iustin Pop
the project site (http://code.google.com/p/ganeti/) and the repositories
1621 1ebe6dbd Iustin Pop
are also on the project git site (http://git.ganeti.org).
1622 c71a1a3d Iustin Pop
1623 c71a1a3d Iustin Pop
NBMA tools
1624 c71a1a3d Iustin Pop
++++++++++
1625 c71a1a3d Iustin Pop
1626 c71a1a3d Iustin Pop
The ``ganeti-nbma`` software is designed to allow instances to live on a
1627 c71a1a3d Iustin Pop
separate, virtual network from the nodes, and in an environment where
1628 c71a1a3d Iustin Pop
nodes are not guaranteed to be able to reach each other via multicasting
1629 c71a1a3d Iustin Pop
or broadcasting. For more information see the README in the source
1630 c71a1a3d Iustin Pop
archive.
1631 c71a1a3d Iustin Pop
1632 c71a1a3d Iustin Pop
ganeti-htools
1633 c71a1a3d Iustin Pop
+++++++++++++
1634 c71a1a3d Iustin Pop
1635 1ebe6dbd Iustin Pop
Before Ganeti version 2.5, this was a standalone project; since that
1636 1ebe6dbd Iustin Pop
version it is integrated into the Ganeti codebase (see
1637 1ebe6dbd Iustin Pop
:doc:`install-quick` for instructions on how to enable it). If you run
1638 1ebe6dbd Iustin Pop
an older Ganeti version, you will have to download and build it
1639 1ebe6dbd Iustin Pop
separately.
1640 c71a1a3d Iustin Pop
1641 c71a1a3d Iustin Pop
For more information and installation instructions, see the README file
1642 c71a1a3d Iustin Pop
in the source archive.
1643 c71a1a3d Iustin Pop
1644 558fd122 Michael Hanselmann
.. vim: set textwidth=72 :
1645 c71a1a3d Iustin Pop
.. Local Variables:
1646 c71a1a3d Iustin Pop
.. mode: rst
1647 c71a1a3d Iustin Pop
.. fill-column: 72
1648 c71a1a3d Iustin Pop
.. End: