Ganeti quick installation guide
===============================

Please note that a more detailed installation procedure is described in
the :doc:`install`. Refer to it if you are setting up Ganeti the first time.
This quick installation guide is mainly meant as reference for experienced
users. A glossary of terms can be found in the :doc:`glossary`.


Software Requirements
---------------------

.. highlight:: shell-example

Before installing, please verify that you have the following programs:

- `Xen Hypervisor <http://www.xen.org/>`_, version 3.0 or above, if
  running on Xen
- `KVM Hypervisor <http://www.linux-kvm.org>`_, version 72 or above, if
  running on KVM. In order to use advanced features, such as live
  migration, virtio, etc, an even newer version is recommended (qemu-kvm
  versions 0.11.X and above have shown good behavior).
- `DRBD <http://www.drbd.org/>`_, kernel module and userspace utils,
  version 8.0.7 or above, up to 8.4.x.
- `RBD <http://ceph.newdream.net/>`_, kernel modules
  (``rbd.ko``/``libceph.ko``) and userspace utils (``ceph-common``)
- `LVM2 <http://sourceware.org/lvm2/>`_
- `OpenSSH <http://www.openssh.com/portable.html>`_
- `iproute2 <http://www.linuxfoundation.org/en/Net:Iproute2>`_
- `arping <http://www.skbuff.net/iputils/>`_ (part of iputils)
- `ndisc6 <http://www.remlab.net/ndisc6/>`_ (if using IPv6)
- `Python <http://www.python.org/>`_, version 3.6 or above
- `Python OpenSSL bindings <https://www.pyopenssl.org/>`_
- `simplejson Python module <https://simplejson.readthedocs.io/>`_
- `pyparsing Python module <https://pyparsing-docs.readthedocs.io/>`_, version
  1.5.7 or above
- `pyinotify Python module <https://github.com/seb-m/pyinotify>`_
- `PycURL Python module <http://pycurl.io/>`_
- `socat <http://www.dest-unreach.org/socat/>`_, see :ref:`note
  <socat-note>` below
- `Paramiko <http://www.paramiko.org/>`_, if you want to use
  ``ganeti-listrunner``
- `psutil Python module <https://psutil.readthedocs.io/>`_,
  optional python package for supporting CPU pinning under KVM, versions
  2.x.x only; beware that versions from 2.0.0 to before 2.2.0 had a
  number of file handle leaks, so running at least 2.2.0 is advised
- `qemu-img <http://qemu.org/>`_, if you want to use ``ovfconverter``
- `fping <http://fping.org/>`_
- `Bitarray Python library <https://github.com/ilanschnell/bitarray>`_
- `GNU Make <http://www.gnu.org/software/make/>`_
- `GNU M4 <http://www.gnu.org/software/m4/>`_

These programs are supplied as part of most Linux distributions, so
usually they can be installed via the standard package manager. Also
many of them will already be installed on a standard machine. On
Debian/Ubuntu, you can use this command line to install all required
packages, except for RBD, DRBD and Xen::

  $ apt-get install lvm2 ssh iproute iputils-arping make m4 \
                    ndisc6 python3 python3-openssl openssl \
                    python3-pyparsing python3-simplejson python3-bitarray \
                    python3-pyinotify python3-pycurl socat fping

Note that the previous instructions don't install optional packages.
To install the optional package, run the following line.::

  $ apt-get install python3-paramiko python3-psutil qemu-utils

If you want to run the QA suite, you also need the follwing packages::

  $ apt-get install python3-yaml python3-mock

If some of the python packages are not available in your system,
you can try installing them using ``easy_install`` command.
For example::

  $ apt-get install python-setuptools python-dev
  $ cd / && easy_install \
            psutil \
            bitarray \

On Fedora to install all required packages except RBD, DRBD and Xen::

  $ yum install openssh openssh-clients iproute ndisc6 make \
                pyOpenSSL pyparsing python-simplejson python-inotify \
                python-lxm socat fping python-bitarray python-ipaddr

For optional packages use the command::

  $ yum install python-paramiko python-psutil qemu-img

If you want to build from source, please see doc/devnotes.rst for more
dependencies.

.. _socat-note:
.. note::
  Ganeti's import/export functionality uses ``socat`` with OpenSSL for
  transferring data between nodes. By default, OpenSSL 0.9.8 and above
  employ transparent compression of all data using zlib if supported by
  both sides of a connection. In cases where a lot of data is
  transferred, this can lead to an increased CPU usage. Additionally,
  Ganeti already compresses all data using ``gzip`` where it makes sense
  (for inter-cluster instance moves).

  To remedey this situation, patches implementing a new ``socat`` option
  for disabling OpenSSL compression have been contributed and will
  likely be included in the next feature release. Until then, users or
  distributions need to apply the patches on their own.

  Ganeti will use the option if it's detected by the ``configure``
  script; auto-detection can be disabled by explicitly passing
  ``--enable-socat-compress`` (use the option to disable compression) or
  ``--disable-socat-compress`` (don't use the option).

  The patches and more information can be found on
  http://www.dest-unreach.org/socat/contrib/socat-opensslcompress.html.

Haskell requirements
~~~~~~~~~~~~~~~~~~~~

Starting with Ganeti 2.7, the Haskell GHC compiler and a few base
libraries are required in order to build Ganeti (but not to run and
deploy Ganeti on production machines). More specifically:

- `GHC <http://www.haskell.org/ghc/>`_ version 8.0 or higher
- or even better, `The Haskell Platform
  <http://hackage.haskell.org/platform/>`_ which gives you a simple way
  to bootstrap Haskell
- `cabal-install <http://hackage.haskell.org/package/json>`_ and
  `Cabal <http://hackage.haskell.org/package/json>`_, the Common Architecture
  for Building Haskell Applications and Libraries (executable and library)
- `json <http://hackage.haskell.org/package/json>`_, a JSON library
- `network <http://hackage.haskell.org/package/network>`_, a basic
  network library
- `parallel <http://hackage.haskell.org/package/parallel>`_, a parallel
  programming library (note: tested with up to version 3.x)
- `bytestring <http://hackage.haskell.org/package/bytestring>`_ and
  `utf8-string <http://hackage.haskell.org/package/utf8-string>`_
  libraries; these usually come with the GHC compiler
- `text <http://hackage.haskell.org/package/text>`_
- `deepseq <http://hackage.haskell.org/package/deepseq>`_,
  usually comes with the GHC compiler
- `curl <http://hackage.haskell.org/package/curl>`_, tested with
  versions 1.3.4 and above
- `hslogger <http://software.complete.org/hslogger>`_, version 1.1 and
  above.
- `hinotify <http://hackage.haskell.org/package/hinotify>`_, tested with
  version 0.3.2
- `Crypto <http://hackage.haskell.org/package/Crypto>`_, tested with
  version 4.2.4
- `regex-pcre <http://hackage.haskell.org/package/regex-pcre>`_,
  bindings for the ``pcre`` library
- `attoparsec <http://hackage.haskell.org/package/attoparsec>`_,
  version 0.10 and above
- `vector <http://hackage.haskell.org/package/vector>`_
- `process <http://hackage.haskell.org/package/process>`_, version 1.0.1.1 and
  above; usually comes with the GHC compiler
- `base64-bytestring
  <http://hackage.haskell.org/package/base64-bytestring>`_,
  version 1.0.0.0 and above
- `lifted-base <http://hackage.haskell.org/package/lifted-base>`_,
  version 0.1.1 and above.
- `lens <http://hackage.haskell.org/package/lens>`_,
  version 3.10 and above.

Some of these are also available as package in Debian/Ubuntu::

  $ apt-get install ghc ghc-ghci cabal-install \
                    libghc-case-insensitive-dev  libghc-curl-dev \
                    libghc-json-dev libghc-lens-dev \
                    libghc-network-dev libghc-parallel-dev \
                    libghc-utf8-string-dev libghc-deepseq-dev \
                    libghc-hslogger-dev libghc-cryptonite-dev \
                    libghc-text-dev libghc-hinotify-dev \
                    libghc-base64-bytestring-dev libghc-zlib-dev \
                    libghc-regex-pcre-dev libghc-attoparsec-dev
                    libghc-vector-dev libghc-lifted-base-dev \
                    libghc-test-framework-quickcheck2-dev \
                    libghc-test-framework-hunit-dev libghc-temporary-dev \
                    libghc-old-time-dev libghc-old-time-dev \
                    libghc-lifted-base-dev libghc-temporary-dev \
                    libpcre3-dev

In Fedora, some of them are available via packages as well::

  $ yum install ghc ghc-json-devel ghc-network-devel \
                    ghc-parallel-devel ghc-deepseq-devel \
                    ghc-hslogger-devel ghc-text-devel \
                    ghc-regex-pcre-devel

The most recent Fedora doesn't provide ``inotify``. So these
need to be installed using ``cabal``.

If using a distribution which does not provide these libraries, first
install the Haskell platform. Then run::

  $ cabal update

Then install the additional native libraries::

  $ apt-get install libpcre3-dev libcurl4-openssl-dev

And finally the libraries required for building the packages via ``cabal``
(it will automatically pick only those that are not already installed via your
distribution packages)::

  $ cabal install --only-dependencies cabal/ganeti.template.cabal

Haskell optional features
~~~~~~~~~~~~~~~~~~~~~~~~~

Optionally, more functionality can be enabled if your build machine has
a few more Haskell libraries enabled: the ``ganeti-confd`` daemon
(``--enable-confd``), the monitoring daemon (``--enable-monitoring``) and
the meta-data daemon (``--enable-metadata``).
The extra dependencies for these are:

- `snap-server` <http://hackage.haskell.org/package/snap-server>`_, version
  0.8.1 and above.
- `case-insensitive`
  <http://hackage.haskell.org/package/case-insensitive>`_, version
  0.4.0.1 and above (it's also a dependency of ``snap-server``).
- `PSQueue <http://hackage.haskell.org/package/PSQueue>`_,
  version 1.0 and above.

These libraries are available in Debian Wheezy or later, so you can use
either apt::

  $ apt-get install libghc-snap-server-dev libghc-psqueue-dev

or ``cabal``::

  $ cabal install --only-dependencies cabal/ganeti.template.cabal \
                  --flags="confd mond metad"

to install them.

.. _cabal-note:
.. note::
  Make sure that your ``~/.cabal/bin`` directory (or whatever else
  is defined as ``bindir``) is in your ``PATH``.

Installation of the software
----------------------------

To install, simply run the following command::

  $ ./configure --localstatedir=/var --sysconfdir=/etc && \
    make && \
    make install

This will install the software under ``/usr/local``. Depending on
your init system you then need to copy ``doc/examples/ganeti.initd``
to ``/etc/init.d/ganeti`` or install the respective systemd unit
files provided in ``doc/examples/systemd/``.
Also, Ganeti uses symbolic links in the sysconfdir to determine,
which of potentially many installed versions currently is used. If these
symbolic links should be added by the install as well, add the
option ``--enable-symlinks`` to the ``configure`` call.


Cluster initialisation
----------------------

Before initialising the cluster, on each node you need to create the
following directories:

- ``/etc/ganeti``
- ``/var/lib/ganeti``
- ``/var/log/ganeti``
- ``/srv/ganeti``
- ``/srv/ganeti/os``
- ``/srv/ganeti/export``

After this, use ``gnt-cluster init``.

.. vim: set textwidth=72 syntax=rst :
.. Local Variables:
.. mode: rst
.. fill-column: 72
.. End:
