]> granicus.if.org Git - icinga2/blob - INSTALL.md
Updates the install dependencies for Debian 9 'stretch'
[icinga2] / INSTALL.md
1 # Installing Icinga 2
2
3 The recommended way of installing Icinga 2 is to use packages. The Icinga
4 project provides both release and development packages for a number
5 of operating systems.
6
7 Please check the documentation in the [doc/](doc/) directory for a current list
8 of available packages and detailed installation instructions.
9
10 The online documentation is available at [docs.icinga.com](https://docs.icinga.com)
11 and will guide you step by step.
12
13 There are a number of known caveats when installing from source such as
14 incorrect directory and file permissions. So even if you're planning to
15 not use the official packages it is advisable to build your own Debian
16 or RPM packages.
17
18 # Builds
19
20 This information is intended for developers and packagers.
21
22 ## Build Requirements
23
24 The following requirements need to be fulfilled in order to build the
25 application using a dist tarball (package names for RHEL and Debian in
26 parentheses):
27
28 * cmake >= 2.6
29 * GNU make (make)
30 * C++ compiler which supports C++11 (gcc-c++ >= 4.7 on RHEL/SUSE, build-essential on Debian, alternatively clang++, build-base on Alpine)
31  * RedHat Developer Tools on RHEL5/6 (details on building below)
32 * pkg-config
33 * OpenSSL library and header files >= 0.9.8 (openssl-devel on RHEL, libopenssl1-devel on SLES11,
34 libopenssl-devel on SLES12, libssl-dev on Debian, libressl-dev on Alpine)
35 * Boost library and header files >= 1.48.0 (boost148-devel on EPEL for RHEL / CentOS, libboost-all-dev on Debian, boost-dev on Alpine)
36 * GNU bison (bison)
37 * GNU flex (flex) >= 2.5.35
38 * recommended: libexecinfo on FreeBSD (automatically used when Icinga 2 is
39                installed via port or package)
40 * optional: MySQL (mysql-devel on RHEL, libmysqlclient-devel on SUSE, libmysqlclient-dev until Debian 8 jessie / default-libmysqlclient-dev from Debian 9 stretch, mariadb-dev on Alpine);
41             set CMake variable `ICINGA2_WITH_MYSQL` to `OFF` to disable this module
42 * optional: PostgreSQL (postgresql-devel on RHEL, libpq-dev on Debian, postgresql-dev on Alpine); set CMake
43             variable `ICINGA2_WITH_PGSQL` to `OFF` to disable this module
44 * optional: YAJL (yajl-devel on RHEL, libyajl-dev on Debian, yajl-dev on Alpine)
45 * optional: libedit (libedit-devel on CentOS (RHEL requires rhel-7-server-optional-rpms
46             repository for el7 e.g.), libedit-dev on Debian and Alpine)
47 * optional: Termcap (libtermcap-devel on RHEL, not necessary on Debian) - only
48             required if libedit doesn't already link against termcap/ncurses
49 * optional: libwxgtk2.8-dev or newer (wxGTK-devel and wxBase) - only required when building the Icinga 2 Studio
50
51 Note: RHEL5 ships an ancient flex version. Updated packages are available for
52 example from the repoforge buildtools repository.
53
54 * x86: https://mirror.hs-esslingen.de/repoforge/redhat/el5/en/i386/buildtools/
55 * x86\_64: https://mirror.hs-esslingen.de/repoforge/redhat/el5/en/x86\_64/buildtools/
56
57 ### User Requirements
58
59 By default Icinga will run as user 'icinga' and group 'icinga'. Additionally the
60 external command pipe and livestatus features require a dedicated command group
61 'icingacmd'. You can choose your own user/group names and pass them to CMake
62 using the `ICINGA2_USER`, `ICINGA2_GROUP` and `ICINGA2_COMMAND_GROUP` variables.
63
64     # groupadd icinga
65     # groupadd icingacmd
66     # useradd -c "icinga" -s /sbin/nologin -G icingacmd -g icinga icinga
67
68 On Alpine (which uses ash busybox) you can run:
69
70     # addgroup -S icinga
71     # addgroup -S icingacmd
72     # adduser -S -D -H -h /var/spool/icinga2 -s /sbin/nologin -G icinga -g icinga icinga
73     # adduser icinga icingacmd
74
75 Add the web server user to the icingacmd group in order to grant it write
76 permissions to the external command pipe and livestatus socket:
77
78     # usermod -a -G icingacmd www-data
79
80 Make sure to replace "www-data" with the name of the user your web server
81 is running as.
82
83 ## Building Icinga 2
84
85 Once you have installed all the necessary build requirements you can build
86 Icinga 2 using the following commands:
87
88     $ mkdir build && cd build
89     $ cmake ..
90     $ make
91     $ make install
92
93 You can specify an alternative installation prefix using `-DCMAKE_INSTALL_PREFIX`:
94
95     $ cmake .. -DCMAKE_INSTALL_PREFIX=/tmp/icinga2
96
97 In addition to `CMAKE_INSTALL_PREFIX` the following Icinga-specific cmake
98 variables are supported:
99
100 - `ICINGA2_USER`: The user Icinga 2 should run as; defaults to `icinga`
101 - `ICINGA2_GROUP`: The group Icinga 2 should run as; defaults to `icinga`
102 - `ICINGA2_GIT_VERSION_INFO`: Whether to use Git to determine the version number; defaults to `ON`
103 - `ICINGA2_COMMAND_GROUP`: The command group Icinga 2 should use; defaults to `icingacmd`
104 - `ICINGA2_UNITY_BUILD`: Whether to perform a unity build; defaults to `ON`
105 - `ICINGA2_LTO_BUILD`: Whether to use link time optimization (LTO); defaults to `OFF`
106 - `ICINGA2_PLUGINDIR`: The path for the Monitoring Plugins project binaries; defaults to `/usr/lib/nagios/plugins`
107 - `ICINGA2_RUNDIR`: The location of the "run" directory; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/run`
108 - `CMAKE_INSTALL_SYSCONFDIR`: The configuration directory; defaults to `CMAKE_INSTALL_PREFIX/etc`
109 - `ICINGA2_SYSCONFIGFILE`: Where to put the config file the initscript/systemd pulls it's dirs from;
110 defaults to `CMAKE_INSTALL_PREFIX/etc/sysconfig/icinga2`
111 - `CMAKE_INSTALL_LOCALSTATEDIR`: The state directory; defaults to `CMAKE_INSTALL_PREFIX/var`
112 - `USE_SYSTEMD=ON|OFF`: Use systemd or a classic SysV initscript; defaults to `OFF`
113 - `INSTALL_SYSTEMD_SERVICE_AND_INITSCRIPT=ON|OFF` Force install both the systemd service definition file
114 and the SysV initscript in parallel, regardless of how `USE_SYSTEMD` is set.
115 Only use this for special packaging purposes and if you know what you are doing.
116 Defaults to `OFF`.
117 - `ICINGA2_WITH_MYSQL`: Determines whether the MySQL IDO module is built; defaults to `ON`
118 - `ICINGA2_WITH_PGSQL`: Determines whether the PostgreSQL IDO module is built; defaults to `ON`
119 - `ICINGA2_WITH_CHECKER`: Determines whether the checker module is built; defaults to `ON`
120 - `ICINGA2_WITH_COMPAT`: Determines whether the compat module is built; defaults to `ON`
121 - `ICINGA2_WITH_DEMO`: Determines whether the demo module is built; defaults to `OFF`
122 - `ICINGA2_WITH_HELLO`: Determines whether the hello module is built; defaults to `OFF`
123 - `ICINGA2_WITH_LIVESTATUS`: Determines whether the Livestatus module is built; defaults to `ON`
124 - `ICINGA2_WITH_NOTIFICATION`: Determines whether the notification module is built; defaults to `ON`
125 - `ICINGA2_WITH_PERFDATA`: Determines whether the perfdata module is built; defaults to `ON`
126 - `ICINGA2_WITH_STUDIO`: Determines whether the Icinga Studio application is built; defaults to `OFF`
127 - `ICINGA2_WITH_TESTS`: Determines whether the unit tests are built; defaults to `ON`
128
129 CMake determines the Icinga 2 version number using `git describe` if the
130 source directory is contained in a Git repository. Otherwise the version number
131 is extracted from the [icinga2.spec](icinga2.spec) file. This behavior can be
132 overridden by creating a file called `icinga-version.h.force` in the source
133 directory. Alternatively the `-DICINGA2_GIT_VERSION_INFO=OFF` option for CMake
134 can be used to disable the usage of `git describe`.
135
136 ## Build Icinga 2 RPMs
137
138 ### Build Environment on RHEL, CentOS, Fedora, Amazon Linux
139
140 Setup your build environment:
141
142     yum -y install rpmdevtools
143
144 ### Build Environment on SuSE/SLES
145
146 SLES:
147
148     zypper addrepo http://download.opensuse.org/repositories/devel:tools/SLE_12_SP2/devel:tools.repo
149     zypper refresh
150     zypper install rpmdevtools spectool
151
152 OpenSuSE:
153
154     zypper addrepo http://download.opensuse.org/repositories/devel:tools/openSUSE_Leap_42.3/devel:tools.repo
155     zypper refresh
156     zypper install rpmdevtools spectool
157
158 ### Package Builds
159
160 Prepare the rpmbuild directory tree:
161
162     cd $HOME
163     rpmdev-setuptree
164
165 Copy the icinga2.spec file to `rpmbuild/SPEC` or fetch the latest version:
166
167     curl https://raw.githubusercontent.com/Icinga/icinga2/master/icinga2.spec -o $HOME/rpmbuild/SPECS/icinga2.spec
168
169 Copy the tarball to `rpmbuild/SOURCES` e.g. by using the `spectool` binary
170 provided with `rpmdevtools`:
171
172     cd $HOME/rpmbuild/SOURCES
173     spectool -g ../SPECS/icinga2.spec
174
175     cd $HOME/rpmbuild
176
177 Install the build dependencies. Example for CentOS 7:
178
179     yum -y install libedit-devel ncurses-devel gcc-c++ libstdc++-devel openssl-devel \
180     cmake flex bison boost-devel systemd mysql-devel postgresql-devel httpd \
181     selinux-policy-devel checkpolicy selinux-policy selinux-policy-doc
182
183 Note: If you are using Amazon Linux, systemd is not required.
184
185 A shorter way is available using the `yum-builddep` command on RHEL based systems:
186
187     yum-builddep SPECS/icinga2.spec
188
189 Build the RPM:
190
191     rpmbuild -ba SPECS/icinga2.spec
192
193 ### Additional Hints
194
195 #### SELinux policy module
196
197 The following packages are required to build the SELinux policy module:
198
199 * checkpolicy
200 * selinux-policy (selinux-policy on CentOS 6, selinux-policy-devel on CentOS 7)
201 * selinux-policy-doc
202
203 #### RHEL/CentOS 5 and 6
204
205 The RedHat Developer Toolset is required for building Icinga 2 beforehand.
206 This contains a modern version of flex and a C++ compiler which supports
207 C++11 features.
208
209     cat >/etc/yum.repos.d/devtools-2.repo <<REPO
210     [testing-devtools-2-centos-\$releasever]
211     name=testing 2 devtools for CentOS $releasever
212     baseurl=https://people.centos.org/tru/devtools-2/\$releasever/\$basearch/RPMS
213     gpgcheck=0
214     REPO
215
216 Dependencies to devtools-2 are used in the RPM SPEC, so the correct tools
217 should be used for building.
218
219 As an alternative, you can use newer Boost packages provided on
220 [packages.icinga.com](https://packages.icinga.com/epel).
221
222     cat >$HOME/.rpmmacros <<MACROS
223     %build_icinga_org 1
224     MACROS
225
226 #### Amazon Linux
227
228 If you prefer to build packages offline, a suitable Vagrant box is located
229 [here](https://atlas.hashicorp.com/mvbcoding/boxes/awslinux/).
230
231 #### SLES 11
232
233 The Icinga repository provides the required boost package version and must be
234 added before building.
235
236 ## Build Icinga 2 Debian/Ubuntu packages
237
238 Setup your build environment on Debian/Ubuntu, copy the 'debian' directory from
239 the Debian packaging Git repository (https://github.com/Icinga/pkg-icinga2-debian)
240 into your source tree and run the following command:
241
242     $ dpkg-buildpackage -uc -us
243
244
245 ## Build Alpine Linux packages
246
247 A simple way to setup a build environment is installing Alpine in a chroot.
248 In this way, you can set up an Alpine build environment in a chroot under a
249 different Linux distro.
250 There is a script that simplifies these steps with just two commands, and
251 can be found [here](https://github.com/alpinelinux/alpine-chroot-install).
252
253 Once the build environment is installed, you can setup the system to build
254 the packages by following [this document](https://wiki.alpinelinux.org/wiki/Creating_an_Alpine_package).
255
256 ## Build Post Install Tasks
257
258 After building Icinga 2 yourself, your package build system should at least run the following post
259 install requirements:
260
261 * enable the `checker`, `notification` and `mainlog` feature by default
262 * run 'icinga2 api setup' in order to enable the `api` feature and generate SSL certificates for the node
263
264 ## Run Icinga 2
265
266 Icinga 2 comes with a binary that takes care of loading all the relevant
267 components (e.g. for check execution, notifications, etc.):
268
269     # icinga2 daemon
270     [2016-12-08 16:44:24 +0100] information/cli: Icinga application loader (version: v2.5.4-231-gb10a6b7; debug)
271     [2016-12-08 16:44:24 +0100] information/cli: Loading configuration file(s).
272     [2016-12-08 16:44:25 +0100] information/ConfigItem: Committing config item(s).
273     ...
274
275 Icinga 2 can be started as a daemon using the provided init script:
276
277     # /etc/init.d/icinga2
278     Usage: /etc/init.d/icinga2 {start|stop|restart|reload|checkconfig|status}
279
280 If your distribution uses systemd:
281
282     # systemctl {start|stop|reload|status|enable|disable} icinga2
283
284 Or if your distribution uses openrc (like Alpine):
285
286     # rc-service icinga2
287         Usage: /etc/init.d/icinga2 {start|stop|restart|reload|checkconfig|status}
288
289 Note: the openrc's init.d is not shipped by default.
290 A working init.d with openrc can be found here: (https://git.alpinelinux.org/cgit/aports/plain/community/icinga2/icinga2.initd). If you have customized some path, edit the file and adjust it according with your setup. 
291 Those few steps can be followed:
292
293     # wget https://git.alpinelinux.org/cgit/aports/plain/community/icinga2/icinga2.initd
294     # mv icinga2.initd /etc/init.d/icinga2
295         # chmod +x /etc/init.d/icinga2
296
297 Icinga 2 reads a single configuration file which is used to specify all
298 configuration settings (global settings, hosts, services, etc.). The
299 configuration format is explained in detail in the [doc/](doc/) directory.
300
301 By default `make install` installs example configuration files in
302 `/usr/local/etc/icinga2` unless you have specified a different prefix or
303 sysconfdir.