如何在Ubuntu 16.04上安装icinga2
ICinga2IS一个开源监控系统,该系统检查网络资源,服务的可用性,通知用户的中断并生成用于报告的性能数据。
它是一种高级的Nagios形式,与它相比它具有更好的Web界面。
它是用具有更多选项的用户友好的Web界面开发,它更响应和可自定义。
最重要的是,监控服务器和客户端节点之间的通信在此版本中变得更加安全。
在本文中,我将解释如何在Ubuntu 16.04服务器上使用Web 2接口设置ICingA2服务器。
让我们通过关于如何构建我们的监控系统的步骤步骤步骤。
添加存储库
所有的冷杉,我们需要将我们的ICinga2存储库添加到我们的服务器。
我们需要启用Add-Repository功能,然后将其存储库添加到我们的存储库包并更新软件包。
root@ubuntu:~# apt install software-properties-common
root@ubuntu:~# add-apt-repository ppa:formorer/icinga
root@ubuntu:~#apt-get update
安装ICinga2.
现在我们可以从添加的存储库中安装。
root@ubuntu:~# apt-get install icinga2
安装完成后。
确保服务已启动并运行正常。
root@ubuntu:~# systemctl enable icinga2.service Synchronizing state of icinga2.service with SysV init with /lib/systemd/systemd-sysv-install... Executing /lib/systemd/systemd-sysv-install enable icinga2 root@ubuntu:~# systemctl start icinga2.service ● icinga2.service - Icinga host/service/network monitoring system Loaded: loaded (/lib/systemd/system/icinga2.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2015-06-26 07:18:44 UTC; 4h 2min ago Process: 29178 ExecStartPre=/usr/lib/icinga2/prepare-dirs /usr/lib/icinga2/icinga2 (code=exited, status=0/SUCCESS) Main PID: 29262 (icinga2) Tasks: 16 (limit: 512) CGroup: /system.slice/icinga2.service └─29262 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon -e
启用功能列表
默认情况下,ICinga2启用以下功能。
但我们可以通过运行此命令确认已启用的设置,如下所示:
root@ubuntu:~# icinga2 feature list Disabled features: api command compatlog debuglog gelf graphite icingastatus livestatus opentsdb perfdata statusdata syslog Enabled features: checker mainlog notification The following features are enabled by default: Checker : This feature enables the execution of checks. Mainlog: This feature enables the logging. Notification : This feature enables notification mechanism.
安装ICinga2插件
Icinga2将根据监视插件收集服务信息。
其中我们正在为此功能安装Nagios插件。
root@ubuntu:~# apt-get install nagios-plugins
安装数据输出(IDO)模块
我正在使用MySQL作为外部数据库。
因此,我们需要安装用于ICinga2 Web界面的MySQL IDO模块。
它用于将所有配置和状态信息导出到其数据库中。
我们需要在我们的服务器上安装mysql,如果之前未安装。
root@ubuntu:~# apt-get install mysql-server-5.7 root@ubuntu:~# apt-get install icinga2-ido-mysql Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: mysql-server The following NEW packages will be installed: icinga2-ido-mysql 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/113 kB of archives. After this operation, 686 kB of additional disk space will be used. Preconfiguring packages ... Determining localhost credentials from /etc/mysql/debian.cnf: succeeded. Selecting previously unselected package icinga2-ido-mysql. (Reading database ... 27776 files and directories currently installed.) Preparing to unpack .../icinga2-ido-mysql_2.4.1-2ubuntu1_amd64.deb ... Unpacking icinga2-ido-mysql (2.4.1-2ubuntu1) ... Setting up icinga2-ido-mysql (2.4.1-2ubuntu1) ... Determining localhost credentials from /etc/mysql/debian.cnf: succeeded. dbconfig-common: writing config to /etc/dbconfig-common/icinga2-ido-mysql.conf dbconfig-common: flushing administrative password
安装IDO模块后。
我们需要设置MySQL数据库以接受使用此模块的值。
我创建了一个名为"icinga2"的数据库,其中包含用户名"icinga2"和password"icinga123"
root@ubuntu:~# mysql -u root -p mysql> Create database icinga2; mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga2.*TO 'icinga2'@'localhost' IDENTIFIED BY 'icinga123'; mysql> flush privileges; root@ubuntu:~# icinga2 feature enable ido-mysql warning/cli: Feature 'ido-mysql' already enabled.
启用此模块并创建我们的数据库后,我们需要重新启动ICinga2服务。
请确保使用正确的DB凭据正确设置IDO MySQL配置文件。
root@ubuntu:~# cat /etc/icinga2/features-enabled/ido-mysql.conf /** * The db_ido_mysql library implements IDO functionality * for MySQL. */ library "db_ido_mysql" object IdoMysqlConnection "ido-mysql" { user = "icinga2", password = "icinga123", host = "localhost", database = "icinga2" }
安装ICinga Web2插件
在Ubuntu 16.05中,PHP 7.0是默认版本,为icinga2带有更多的压缩性问题,具有PHP 7.0。
因此,在此安装之前,我们需要安装PHP 5.6版本。
在我的服务器上安装PHP 5.6.
我需要启用"ondrej/php"存储库。
请参阅以下步骤:
root@ubuntu:/usr#add-apt-repository ppa:ondrej/php root@ubuntu:/usr#apt-get install php5.6 root@ubuntu:/usr# php -v PHP 5.6.22-4+deb.sury.org~xenial+1 (cli) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
我将使用MySQL数据库来保存我的ICinga2 Web界面的所有本能。
为此,创建一个数据库,并在DB上授予用户的所有权限,如下所示:
root@ubuntu:/usr/share/icingaweb2# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 18 Server version: 5.7.11-0ubuntu6 (Ubuntu) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names Jan be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> mysql> create database icingawebdb; mysql> GRANT SUPER ON *.* TO 'icingaweb'@'localhost' IDENTIFIED BY 'icinga123'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icingawebdb.*TO 'icingaweb'@'localhost' IDENTIFIED BY 'icinga123';
创建数据库后,我们可以安装Web接口插件并逐个配置它。
Apache2和其他Web包以及PHP模块与此插件一起安装。
root@ubuntu:~# apt-get install icingaweb2 Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu fonts-dejavu-core fonts-dejavu-extra icingaweb2-module-doc icingaweb2-module-monitoring libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libfontconfig1 libfreetype6 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 liblua5.1-0 libtiff5 libvpx3 libxpm4 libzend-framework-php php php-common php-dompdf php-font-lib php-gd
安装后,我们可以在浏览器中调用此URL到"http://ip //icingaweb2/setup"。
配置ICINGA WEB2插件
我们的下一步是配置Web界面。
请浏览屏幕截图以获得更多的清晰度。
第1步:创建令牌。
初始设置页面提出了一条消息来验证我们的icingaWeb用户并创建令牌以继续配置。
To run this wizard a user needs to authenticate using a token which is usually provided to him by an administrator who'd followed the instructions below. In any case, make sure that all of the following applies to your environment: A system group called "icingaweb2" exists The user "www-data" is a member of the system group "icingaweb2" addgroup --system icingaweb2; usermod -a -G icingaweb2 www-data; If you've got the IcingaCLI installed you can do the following: icingacli setup config directory --group icingaweb2; icingacli setup token create; In case the IcingaCLI is missing you can create the token manually: su www-data -c "mkdir -m 2770 /etc/icingaweb2; chgrp icingaweb2 /etc/icingaweb2; head -c 12 /dev/urandom | base64 | tee /etc/icingaweb2/setup.token; chmod 0660 /etc/icingaweb2/setup.token;"; Please see the Icinga Web 2 documentation for an extensive description on how to access and use this wizard.
我们只需遵循这些说明并提供生成的令牌键,为"setup令牌"列。这就是我的确。
root@ubuntu:/usr/local/src# addgroup --system icingaweb2 addgroup: The group `icingaweb2' already exists as a system group. Exiting. root@ubuntu:/usr/local/src# usermod -a -G icingaweb2 www-data root@ubuntu:/usr/local/src# icingacli setup config directory --group icingaweb2; Successfully created configuration directory /etc/icingaweb2 root@ubuntu:/usr/local/src# icingacli setup token create; The newly generated setup token is: 1951e1eb11110e65
通过提供令牌,它将进入下一步。
步骤2:选择Modules.After提供令牌,它将移动到下一节以选择模块。我们可以选择首选模块进行下一步。
步骤3:验证PHP设置。要进一步进行,我们需要安装缺少的PHP模块并设置适当的时区。我们可以使用以下命令安装所需的模块:#APT-Get安装PHP5.6-GD PHP5.6-JSON PHP5.6-DBA PHP5.6-INTL PHP5.6-LDAP PHP5.6-PDO-MYSQL PHP5. 6-imagick php5.6-dom
此外,我们可以在PHP配置文件中设置一个适当的时区。
在满足所需的设置后,我们可以继续下一阶段。
第5步:验证方法
我们需要选择首选的身份验证方法以继续安装。
正如我之前讨论的那样,我更愿意选择数据库类型。
步骤6:填写用于身份验证的数据库详细信息。
我们需要输入我们在此处为Web界面创建的数据库详细信息。
我们可以在设置之前或者在此步骤从CLI创建此。
我们需要确保提供此用户,在此数据库中提供足够的权限。
步骤7:创建ICinga Web管理用户以管理界面。
在成功验证我们的数据库资源后,我们需要创建管理ICinga2 Web界面的管理帐户。
请提供管理界面的首选用户名和密码。
步骤8:选择应用程序配置选项。
接下来是根据我们的需求设置应用程序配置。
并进入下一阶段。
第9步:查看所有所选设置。
这些阶段将简要介绍一下你直到现在的所有设置。
我们可以确认设置并进一步进行。
步骤10:配置监控模块。
现在,我们已经完成了身份验证部分,并遵循监控模块的配置。
正如我们之前讨论的那样,ICinga IDO模块将所有状态信息和配置部分导出到ICinga主数据库。
因此,我们需要选择此模块并正确配置它以更新数据库,并使用信息更新数据库。
其中我们需要提供主数据库信息来继续。
此处填写数据库详细信息。
确保为数据库用户设置任何修改的适当权限。
这为监控实例选择传输介质。
我们不需要在此步骤进行任何修改。
只需单击"下一步"。
步骤11:查看监视模块配置选项
此阶段将简要介绍我们选择的所有监控模块配置部分。
我们可以确认设置并继续进一步完成设置。
最后一步:登录Web界面。
现在,我们可以继续使用在设置期间创建的登录凭据登录ICinga Web 2接口。
默认情况下,我们的主节点将添加到此系统。
我们可以在此处查看我们的主icinga服务器的服务通知。
或者我们可以浏览此URL http://ip/icingaweb2 /以访问Web界面。