2017-11-09 21:17:09 +01:00
|
|
|
.. _installation:
|
|
|
|
|
2017-11-09 20:33:09 +01:00
|
|
|
Installation
|
|
|
|
============
|
|
|
|
|
|
|
|
.. TIP::
|
|
|
|
|
2017-11-10 14:30:51 +01:00
|
|
|
Note: check out the :ref:`tutorial` if you want a first impression of zrepl.
|
2017-11-09 20:33:09 +01:00
|
|
|
|
|
|
|
User Privileges
|
|
|
|
---------------
|
|
|
|
|
|
|
|
It is possible to run zrepl as an unprivileged user in combination with
|
2017-11-09 21:23:45 +01:00
|
|
|
`ZFS delegation <https://www.freebsd.org/doc/handbook/zfs-zfs-allow.html>`_.
|
2017-11-09 20:33:09 +01:00
|
|
|
Also, there is the possibility to run it in a jail on FreeBSD by delegating a dataset to the jail.
|
|
|
|
However, until we get around documenting those setups, you will have to run zrepl as root or experiment yourself :)
|
|
|
|
|
2017-11-10 14:30:51 +01:00
|
|
|
Packages
|
|
|
|
--------
|
|
|
|
|
|
|
|
zrepl releases are signed & tagged by the author in the git repository.
|
|
|
|
Your OS vendor may provide binary packages of zrepl through the package manager.
|
|
|
|
The following list may be incomplete, feel free to submit a PR with an update:
|
|
|
|
|
|
|
|
.. list-table::
|
|
|
|
:header-rows: 1
|
2017-11-09 20:33:09 +01:00
|
|
|
|
2017-11-10 14:30:51 +01:00
|
|
|
* - OS / Distro
|
|
|
|
- Install Command
|
|
|
|
- Link
|
|
|
|
* - FreeBSD
|
|
|
|
- ``pkg install zrepl``
|
|
|
|
- `<https://www.freshports.org/sysutils/zrepl/>`_
|
|
|
|
* - Others
|
|
|
|
-
|
|
|
|
- Install from source, see below
|
2017-11-09 20:33:09 +01:00
|
|
|
|
2017-11-10 14:30:51 +01:00
|
|
|
Compile From Source
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2017-11-12 16:15:12 +01:00
|
|
|
Go 1.9 or newer and a configured ``$GOPATH`` environment variable and a few build dependencies are required to build zrepl.
|
|
|
|
A tutorial is available over at `golang.org <https://golang.org/doc/install>`_.
|
|
|
|
If Go 1.9 is not available on your distro consider build in Docker (see below).
|
|
|
|
|
|
|
|
The following shell script checks out the zrepl project into your ``$GOPATH``,
|
|
|
|
installs the build dependencies, installs dependencies using ``dep ensure`` and does a ``make release``.
|
|
|
|
Build artifacts are placed into ``$GOPATH/github.com/zrepl/zrepl/artifacts/``.
|
|
|
|
|
|
|
|
When doing builds afterwards, it should be sufficient to checkout the new revision, run ``dep ensure`` and ``make release``.
|
|
|
|
You may want to switch to a tagged commit (we use `semver <http://semver.org>`_) but master should generally be considered stable.
|
|
|
|
|
|
|
|
**Note**: it is your job to install the apropriate binary in the zrepl users's ``$PATH``, e.g. ``/usr/local/bin/zrepl``.
|
|
|
|
Otherwise, the examples in the :ref:`tutorial` may need to be adjusted.
|
|
|
|
|
|
|
|
**You are encouraged to understand what happens by auditing the script.**
|
|
|
|
|
|
|
|
::
|
|
|
|
|
2017-11-18 17:02:11 +01:00
|
|
|
curl 'https://raw.githubusercontent.com/zrepl/zrepl/master/lazy.sh' | sh
|
2017-11-12 16:15:12 +01:00
|
|
|
|
|
|
|
You can also build in a Docker container if you want an isolated build environment or don't have a compatible Go version.
|
2017-11-09 20:33:09 +01:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
git clone https://github.com/zrepl/zrepl.git
|
|
|
|
cd zrepl
|
2017-11-12 16:15:12 +01:00
|
|
|
sudo docker run -it --rm \
|
|
|
|
-v "${PWD}:/zrepl" \
|
|
|
|
--user "$(id -u):$(id -g)" \
|
2017-11-18 17:02:11 +01:00
|
|
|
golang:latest bash -c 'export CLONEPATH=/go/src/github.com/zrepl; mkdir -p "$CLONEPATH" && ln -s /zrepl $CLONEPATH/zrepl && ${CLONEPATH}/zrepl/lazy.sh'
|
2017-11-12 16:15:12 +01:00
|
|
|
|
2017-11-18 17:02:11 +01:00
|
|
|
.. literalinclude:: ../lazy.sh
|
2017-11-12 16:15:12 +01:00
|
|
|
:language: sh
|
|
|
|
|
2017-11-09 20:33:09 +01:00
|
|
|
|
2017-11-09 21:17:09 +01:00
|
|
|
.. _mainconfigfile:
|
|
|
|
|
2017-11-09 20:33:09 +01:00
|
|
|
Configuration Files
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
zrepl searches for its main configuration file in the following locations (in that order):
|
|
|
|
|
2017-11-10 14:30:51 +01:00
|
|
|
* ``/etc/zrepl/zrepl.yml``
|
|
|
|
* ``/usr/local/etc/zrepl/zrepl.yml``
|
2017-11-09 20:33:09 +01:00
|
|
|
|
|
|
|
Alternatively, use CLI flags to specify a config location.
|
2017-11-10 14:30:51 +01:00
|
|
|
Copy a config from the :ref:`tutorial` or the ``cmd/sampleconf`` directory to one of these locations and customize it to your setup.
|
2017-11-09 20:33:09 +01:00
|
|
|
|
2017-11-10 14:30:51 +01:00
|
|
|
Runtime Directories
|
|
|
|
-------------------
|
2017-11-09 20:33:09 +01:00
|
|
|
|
2017-11-10 14:30:51 +01:00
|
|
|
zrepl requires ephemeral runtime directories where control sockets, etc are placed.
|
|
|
|
Refer to the :ref:`configuration documentation <conf-runtime-directories>` for more information.
|
2017-11-09 20:33:09 +01:00
|
|
|
|
2017-11-10 14:30:51 +01:00
|
|
|
When installing from a package, the package maintainer should have taken care of setting them up through the init system.
|
|
|
|
Alternatively, for default settings, the following should to the trick.
|
2017-11-09 20:33:09 +01:00
|
|
|
|
2017-11-09 21:23:45 +01:00
|
|
|
::
|
|
|
|
|
|
|
|
mkdir -p /var/run/zrepl/stdinserver
|
|
|
|
chmod -R 0700 /var/run/zrepl
|
2017-11-09 20:33:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
Running the Daemon
|
|
|
|
------------------
|
|
|
|
|
|
|
|
All actual work zrepl does is performed by a daemon process.
|
2017-11-10 13:41:17 +01:00
|
|
|
Logging is configurable via the config file. Please refer to the :ref:`logging documention <logging>`.
|
2017-11-09 20:33:09 +01:00
|
|
|
|
2017-11-10 14:30:51 +01:00
|
|
|
When installating from a package, the package maintainer should have provided an init script / systemd.service file.
|
|
|
|
You should thus be able to start zrepl daemon using your init system.
|
2017-11-09 20:33:09 +01:00
|
|
|
|
2017-11-10 14:30:51 +01:00
|
|
|
Alternatively, or for running zrepl in the foreground, simply execute ``zrepl daemon``.
|
|
|
|
Note that you won't see any output unless you configure :ref:`stdout logging outlet <logging-outlet-stdout>`.
|
2017-11-09 20:33:09 +01:00
|
|
|
|
|
|
|
.. ATTENTION::
|
|
|
|
|
2017-11-10 14:30:51 +01:00
|
|
|
Make sure to actually monitor the error level output of zrepl: some configuration errors will not make the daemon exit.
|
|
|
|
|
|
|
|
Example: if the daemon cannot create the :ref:`transport-ssh+stdinserver` sockets in the runtime directory,
|
|
|
|
it will emit an error message but not exit because other tasks such as periodic snapshots & pruning are of equal importance.
|
2017-11-09 20:33:09 +01:00
|
|
|
|
2017-11-09 21:17:09 +01:00
|
|
|
.. _install-restarting:
|
|
|
|
|
2017-11-09 20:33:09 +01:00
|
|
|
Restarting
|
|
|
|
~~~~~~~~~~
|
|
|
|
|
|
|
|
The daemon handles SIGINT and SIGTERM for graceful shutdown.
|
|
|
|
Graceful shutdown means at worst that a job will not be rescheduled for the next interval.
|
|
|
|
The daemon exits as soon as all jobs have reported shut down.
|