您的位置:首页 > 运维架构 > Linux

在CentOS 7 上安装 icinga2

2015-11-02 16:08 681 查看
1. 通过 yum 安装icinga2 核心包

a) Package Repositories

# rpm --import http://packages.icinga.org/icinga.key
# curl -o/etc/yum.repos.d/ICINGA-release.repohttp://packages.icinga.org/fedora/ICINGA-release.repo

# yum makecache

b) Installing Icinga 2

# yum install icinga2

# systemctl enable icinga2

# systemctl start icinga2

c) Enabled Features during Installation

# icinga2 feature list

显示内容分为Disabled和Eabled 2个部分

Disabledfeatures: api command compatlog debuglog graphite icingastatus ido-mysqlido-pgsql livestatus notification perfdata statusdata syslog

Enabled features: checker mainlognotification

2. 安装nagios-plugins-all

a) 安装EPEL

EPEL,即Extra Packages for Enterprise Linux的简称,是为企业级Linux提供的一组高质量的额外软件包,包括但不限于Red Hat EnterpriseLinux (RHEL),

# yum -y install epel-release

# yum clean all && yum makecache

# yum install nagios-plugins-all –y

检查
/usr/lib/nagios/plugins or/usr/lib64/nagios/plugins 目录下,是否有相应的 plugin文件

3. 运行icinga2

$ systemctl status icinga2

$ systemctl enable icinga2

$ systemctl restart icinga2

COMMAND

DESCRIPTION

start

The
start
action starts the Icinga 2 daemon.

stop

The
stop
action stops the Icinga 2 daemon.

restart

The
restart
action is a shortcut for running the
stop
action
followed by
start
.

reload

The
reload
action sends the
HUP
signal
to Icinga 2 which causes it to restart. Unlike the
restart
action
reload
does
not wait until Icinga 2 has restarted.

checkconfig

The
checkconfig
action checks if the
/etc/icinga2/icinga2.conf
configuration
file contains any errors.

status

The
status
action checks if Icinga 2 is running.

4. Setting up Icinga Web 2

a) Configuring DB IDO MySQL

The DB IDO(Database Icinga Data Output) modules for Icinga 2 take care of exporting allconfiguration and status information into a database. The IDO database is usedby a number of projects including Icinga
Web 2, Icinga Reporting or Icinga Web 1.x

i. InstallingMySQL database server

# yum install mariadb-server mariadb

# systemctl enable mariadb

# systemctl start mariadb

# mysql_secure_installation

ii. Installingthe IDO modules for MySQL

# yum install icinga2-ido-mysql

iii. Settingup the MySQL database

# mysql -u root -p

mysql> CREATE DATABASE icinga;

GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTEON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga';

Aftercreating the database you can import the Icinga 2 IDO schema using thefollowing command:

# mysql -u root -p icinga </usr/share/icinga2-ido-mysql/schema/mysql.sql

The package provides a new configuration filethat is installed in
/etc/icinga2/features-available/ido-mysql.conf
.
You will need to update the databasecredentials in this file.

iv. Enablingthe IDO MySQL module

# icinga2 feature enable ido-mysql

Module 'ido-mysql' was enabled.

Make sure to restart Icinga 2 for thesechanges to take effect.

# systemctl restart icinga2


b) 安装Webserver

# yum install httpd

# systemctl enable httpd

# systemctl start httpd

i. FirewallRules

# firewall-cmd --add-service=http

# firewall-cmd --permanent --add-service=http

ii. 配置额外的命令通道

Web接口和一些其它模块通过额外的命令通道来向Icinga2发送命令,你可以使用下面的命令启用它:

# icinga2 feature enable command

# systemctl restart icinga2

默认情况下,icingacmd用户组拥有读写命令通道文件的权限,因此需要使用下面的命令将Web服务的用户加入到该组:

$ usermod -a -G icingacmd apache

以使用以下命令来检测是否成功将用户加入到icingacmd用户组:

$ id apache

显示 uid=48(apache) gid=48(apache) 组=48(apache),989(icingacmd)

c) 安装icinga Web2

# yum installicingaweb2 icingacli

d) 配置icinga Web2

你可以通过IcingaWeb2配置向导,或者直接通过执行命令来完成配置,本文仅介绍通过配置向导来完成配置,如果需要使用命令行来完成,请查看 Icinga Web 2官方文档。

STEP1: 通过icingacli创建一个token,用来安装IcingaWeb2:

icingacli setup token create

icingacli setup token show

STEP 2: 使用浏览器访问 http://127.0.0.1/icingaweb2/setup (将IP替换为实际IP或域名),将上一步命令行得到的token输入到Steup
Token的输入框中,继续下一步。



Image
STEP 3: 根据需要选择需要安装的模块,我这边选择了除翻译外的所有模块。



Image
STEP 4: 根据系统检查结果,解决需要修改的项,全部完成后刷新确认。



Image
本例中,需要解决的有PHP时区,LDAP,PDO-MySQL,PDO-PostgreSQL问题。PDO-MySQL,PDO-PostgreSQL只需要重启Web服务器即可解决。
修改PHP时区:

使用
vi
打开
/etc/php.ini
;查找
date.timezone
,删除最前面的分号,在结尾增加时区标签,这里使用:
Asia/Shanghai

启用LDAP:
yum install php-ldap
重启Web服务器,CentOS7直接使用systemctl
restart httpd 重启。

如果出现 The directory /etc/icingaweb2 is not writable.就关闭SELINUX

现在界面上所有的状态应该都已经变成了绿色,继续下一步吧,后面没有特别讲到的步骤都是直接点击下一步的!
STEP 5: 配置Icinga Web2数据库



Image
此处直接填写我们创建的icingaweb2数据库的信息,默认情况下用户名和密码都是icingaweb2。由于我们并没有给予icingaweb2用户创建表的权限,因此你还需要给一个有创建数据库和表权限的用户。



Image
STEP 6: 创建一个Icinga Web2的管理员账号



Image

STEP 7: 配置IcingaIDO数据库信息



Image
此处直接填写我们创建的icinga数据库的信息,默认情况下用户名和密码都是icinga。(这些信息是和设置mysql
数据库的操作步骤的时候填写的信息所对应)

如果出现 /usr/share/icingaweb2/etc/schema/mysql.schema.sql文件没有发现的错误,就运行

# cp /usr/share/doc/icingaweb2/schema/mysql.schema.sql /usr/share/icingaweb2/etc/schema/

登录!



Image
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: