Icinga安装配置手册.docx
《Icinga安装配置手册.docx》由会员分享,可在线阅读,更多相关《Icinga安装配置手册.docx(17页珍藏版)》请在冰豆网上搜索。
![Icinga安装配置手册.docx](https://file1.bdocx.com/fileroot1/2022-12/7/ea584669-92fd-46b7-b3ea-4bcc33215241/ea584669-92fd-46b7-b3ea-4bcc332152411.gif)
Icinga安装配置手册
Icinga安装配置手册
giser062——2014-11-06
1Icinga说明
1.1中文版地址
中文版项目地址
http:
//icinga-
下载地址
1.2官方安装指南
IcingawithIDOUtilsQuickstart
http:
//docs.icinga.org/1.4/en/quickstart-idoutils.html
NRPE
http:
//docs.icinga.org/1.4/en/nrpe.html
1.3插件下载地址
http:
//exchange.nagios.org/directory/Plugins/System-Metrics
1.4实验环境
操作系统
CentOS6.5
数据库
MySQL
2监控主机服务器安装配置
2.1上传安装包和依赖包
上传路径:
/usr/local/softwares
2.2安装依赖包
分为在线安装方式及离线安装
2.2.1在线安装
执行命令,安装依赖:
yuminstallhttpdgccglibcglibc-commongdgd-devel opensslopenssl-devellibjpeglibjpeg-devellibpnglibpng-devel
安装MySql:
yuminstallmysqlmysql-serverlibdbilibdbi-devellibdbi-driverslibdbi-dbd-mysql
2.2.2离线安装
进入到依赖包路径,执行命令:
安装依赖:
rpm-ivhapr-1.3.9-5.el6_2.x86_64.rpmapr-util-1.3.9-3.el6_0.1.x86_64.rpmapr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpmcloog-ppl-0.15.7-1.2.el6.x86_64.rpmcpp-4.4.7-4.el6.x86_64.rpme2fsprogs-1.41.12-18.el6_5.1.x86_64.rpme2fsprogs-libs-1.41.12-18.el6_5.1.x86_64.rpmfontconfig-devel-2.8.0-3.el6.x86_64.rpmfreetype-devel-2.3.11-14.el6_3.1.x86_64.rpmgcc-4.4.7-4.el6.x86_64.rpmgd-devel-2.0.35-11.el6.x86_64.rpmglibc-2.12-1.132.el6_5.4.x86_64.rpmglibc-common-2.12-1.132.el6_5.4.x86_64.rpmglibc-devel-2.12-1.132.el6_5.4.x86_64.rpmglibc-headers-2.12-1.132.el6_5.4.x86_64.rpmhttpd-2.2.15-31.el6.centos.x86_64.rpmhttpd-tools-2.2.15-31.el6.centos.x86_64.rpmkeyutils-libs-devel-1.4-4.el6.x86_64.rpmkrb5-devel-1.10.3-15.el6_5.1.x86_64.rpmkrb5-libs-1.10.3-15.el6_5.1.x86_64.rpmkrb5-workstation-1.10.3-15.el6_5.1.x86_64.rpmlibX11-devel-1.5.0-4.el6.x86_64.rpmlibXau-devel-1.0.6-4.el6.x86_64.rpmlibXpm-devel-3.5.10-2.el6.x86_64.rpmlibcom_err-1.41.12-18.el6_5.1.x86_64.rpmlibcom_err-devel-1.41.12-18.el6_5.1.x86_64.rpmlibjpeg-turbo-1.2.1-3.el6_5.x86_64.rpmlibjpeg-turbo-devel-1.2.1-3.el6_5.x86_64.rpmlibpng-devel-1.2.49-1.el6_2.x86_64.rpmlibselinux-devel-2.0.94-5.3.el6_4.1.x86_64.rpmlibsepol-devel-2.0.41-4.el6.x86_64.rpmlibss-1.41.12-18.el6_5.1.x86_64.rpmlibxcb-devel-1.8.1-1.el6.x86_64.rpmmailcap-2.1.31-2.el6.noarch.rpmmpfr-2.4.1-6.el6.x86_64.rpmopenssl-1.0.1e-16.el6_5.15.x86_64.rpmopenssl-devel-1.0.1e-16.el6_5.15.x86_64.rpmppl-0.10.2-11.el6.x86_64.rpmxorg-x11-proto-devel-7.6-25.el6.noarch.rpmzlib-devel-1.2.3-29.el6.x86_64.rpm–force
安装MySQL:
rpm-ivhlibdbi-0.8.3-4.el6.x86_64.rpmlibdbi-dbd-mysql-0.8.3-5.1.el6.x86_64.rpmlibdbi-devel-0.8.3-4.el6.x86_64.rpmlibdbi-drivers-0.8.3-5.1.el6.x86_64.rpmmysql-5.1.73-3.el6_5.x86_64.rpmmysql-libs-5.1.73-3.el6_5.x86_64.rpmmysql-server-5.1.73-3.el6_5.x86_64.rpmperl-DBD-MySQL-4.013-3.el6.x86_64.rpmperl-DBI-1.609-4.el6.x86_64.rpm--force
2.3添加icinga用户及用户组
useradd-micinga
passwdicinga
添加新用户组icinga-cmd,用于从icingaweb界面中给icinga发送命令
groupaddicinga-cmd
usermod-a-Gicinga-cmdicinga
2.4编译安装Icinga和IDOUtils
cd/usr/local/softwares
tar-xvficinga-cn-1.4.0.tar.bz2
cdicinga-cn-1.4.0
2.4.1运行配置脚本
启用idoutils和ssl
./configure--with-command-group=icinga-cmd--enable-idoutils--enable-ssl
2.4.2编译
makeall
2.4.3安装
分别执行下面的安装语句:
makeinstall
makeinstall-init
makeinstall-config
makeinstall-commandmode
makeinstall-idoutils
或者直接全部安装:
makefullinstall
2.5自定义配置
一些简单的配置文件已经被被“makeisntall-config”命令安装到目录“/usr/local/icinga/etc/”中。
2.5.1修改联系邮件地址
vim/usr/local/icinga/etc/objects/contacts.cfg
definecontact{
contact_name icingaadmin;Shortnameofuser
usegeneric-contact;Inheritdefaultvaluesfromgeneric-contacttemplate(definedabove)
alias IcingaAdmin;Fullnameofuser
email liujianliang@;<<*****CHANGETHISTOYOUREMAILADDRESS******
}
2.5.2启用SSL连接及连接配置
vim/usr/local/icinga/etc/idomod.cfg
修改如下内容:
use_ssl=1
output_type=tcpsocket
output=127.0.0.1
其中output为本机服务器ip地址,或者直接127.0.0.1,如果该地址配置为数据库服务器IP地址,则启动后,会报如下错误:
icinga:
idomod:
Stillunabletoconnecttodatasink.0itemslost,434queueditemstoflush.
vim /usr/local/icinga/etc/ido2db.cfg
修改如下内容:
use_ssl=1
socket_type=tcp
2.5.3启用idomod事件代理(Eventbroker)模块
编辑主配置文件,找到broker_module并且取消其前面的注释
vim/usr/local/icinga/etc/icinga.cfg
broker_module=/usr/local/icinga/bin/idomod.oconfig_file=/usr/local/icinga/etc/idomod.cfg
2.6创建数据库和IDOUtils
2.6.1启动MySQL数据库
servicemysqldstart
2.6.2设置mysqlroot的密码
mysqladmin-uroot-ppassword"root"
2.6.3修改MySQL默认编码为utf8
vim/etc/f
添加:
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
2.6.4创建Icinga数据库
#>mysql-uroot-p
mysql>CREATEDATABASEicingaCHARACTERSETutf8COLLATEutf8_general_ci;
GRANTUSAGEON*.*TO'icinga'@'localhost'
IDENTIFIEDBY'icinga'
WITHMAX_QUERIES_PER_HOUR0
MAX_CONNECTIONS_PER_HOUR0
MAX_UPDATES_PER_HOUR0;
GRANTSELECT,INSERT,UPDATE,DELETE
ONicinga.*TO'icinga'@'localhost';
FLUSHPRIVILEGES;
quit
2.6.5导入表结构
进入icinga安装目录下的module/idoutils/db/mysql目录
cd/usr/local/softwares/icinga-cn-1.4.0/module/idoutils/db/mysql
注意:
修改mysql.sql脚本中的字符集为utf8,否则icinga_servicechecks表中的性能数据会乱码
打开mysql.sql文件,全部替换latin1_general_cs为utf8_general_ci,全部替换latin1为utf8
然后导入表结构
mysql-uroot-picinga2.6.6自定义IDOUtils的数据库配置文件
vim/usr/local/icinga/etc/ido2db.cfg
修改信息如下:
db_servertype=mysql
db_host=localhost
db_port=3306
db_user=icinga
db_pass=icinga
注意:
其中db_host为数据库服务器IP地址,如果数据库不在本机上,要记得修改。
2.7配置经典Web界面
2.7.1编译安装
#>makecgis
#>makeinstall-cgis
#>makeinstall-html
2.7.2安装配置文件
把icinga经典web界面配置文件安装到apache的conf.d目录中
#>makeinstall-webconf
2.7.3创建Icinga账号
创建icinga经典web界面登录用户帐号:
icingaadmin
#>htpasswd-c/usr/local/icinga/etc/htpasswd.usersicingaadmin
2.7.4修改密码或者添加用户
#>htpasswd/usr/local/icinga/etc/htpasswd.users
2.7.5重启Apache,使生效
servicehttpdrestart
2.8编译安装Nagios插件
2.8.1解压
cd /usr/local/softwares
tarxvficinga-nagios-cn-plugins-1.4.15.tar.bz2
cdicinga-cn-plugins-1.4.15/
2.8.2编译安装
#>./configure--prefix=/usr/local/icinga\
--with-cgiurl=/icinga/cgi-bin--with-htmurl=/icinga\
--with-nagios-user=icinga--with-nagios-group=icinga
#>make
#>makeinstall
2.9调整SELinux设置
enforcing模式下,icinga运行会有问题,需要修改为permissive模式
2.9.1检查是否运行在enforcing模式
#>getenforce
2.9.2设置为permissive模式
#>setenforce0
2.9.3修改系统默认设置
修改/etc/selinux/config,并重启系统,就不用每次设置了
vim/etc/selinux/config
修改为:
SELINUX=permissive
2.10启动IDOUtils和Icinga
注意:
IDOUtils必须要在Icinga之前启动
2.10.1启动IDOUtils
#>serviceido2dbstart
2.10.2停止IDOUtils
#>serviceido2dbstop
2.10.3验证Icinga配置文件
#>/usr/local/icinga/bin/icinga-v/usr/local/icinga/etc/icinga.cfg
如果没有错误,则可以启动Icinga
2.10.4启动Icinga
#>serviceicingastart
2.10.5添加Icinga到系统服务,随系统启动而启动
#>chkconfig--addicinga
#>chkconfigicingaon
2.11登录经典web界面
http:
//ip/icinga/
如果不能访问,请关闭防火墙再试
serviceiptablesstop
2.12总结
需要启动服务一览:
serviceiptablesstop
servicehttpdstart
servicemysqldstart
serviceido2dbstart
serviceicingastart
2.13监控主机安装NRPE
NRPE=NagiosRemotePluginExecutor,用于在远程服务器上监控并返回数据。
2.13.1安装依赖
第2.2节已经安装过了
2.13.2解压
tarzxvficinga-nrpe-2.14.tar.gz
cdicinga-nrpe-2.14
2.13.3编译安装
./configure--enable-ssl
makeall
makeinstall-plugin
2.13.4第一次测试验证
/usr/local/softwares/icinga-nrpe-2.14/src/nrpe-n -c /usr/local/softwares/icinga-nrpe-2.14/sample-config/nrpe.cfg-d
/usr/local/icinga/libexec/check_nrpe-H127.0.0.1-n
会输出NRPE的版本号,如:
NRPEv2.14
停止这个进程:
kill`ps-ef|grep"sample-config/nrpe.cfg"|grep-vgrep|awk'{print$2}'`
3远程受控服务器安装配置
3.1安装依赖
两种方式:
在线安装、本地安装
3.1.1在线安装
yuminstallhttpdgccglibcglibc-commongdgd-devellibjpeglibjpeg-devellibpnglibpng-developensslopenssl-devel
3.1.2本地安装
rpm-ivhapr-1.3.9-5.el6_2.x86_64.rpmapr-util-1.3.9-3.el6_0.1.x86_64.rpmapr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpmcloog-ppl-0.15.7-1.2.el6.x86_64.rpmcpp-4.4.7-4.el6.x86_64.rpme2fsprogs-1.41.12-18.el6_5.1.x86_64.rpme2fsprogs-libs-1.41.12-18.el6_5.1.x86_64.rpmfontconfig-devel-2.8.0-3.el6.x86_64.rpmfreetype-devel-2.3.11-14.el6_3.1.x86_64.rpmgcc-4.4.7-4.el6.x86_64.rpmgd-devel-2.0.35-11.el6.x86_64.rpmglibc-2.12-1.132.el6_5.4.x86_64.rpmglibc-common-2.12-1.132.el6_5.4.x86_64.rpmglibc-devel-2.12-1.132.el6_5.4.x86_64.rpmglibc-headers-2.12-1.132.el6_5.4.x86_64.rpmhttpd-2.2.15-31.el6.centos.x86_64.rpmhttpd-tools-2.2.15-31.el6.centos.x86_64.rpmkeyutils-libs-devel-1.4-4.el6.x86_64.rpmkrb5-devel-1.10.3-15.el6_5.1.x86_64.rpmkrb5-libs-1.10.3-15.el6_5.1.x86_64.rpmkrb5-workstation-1.10.3-15.el6_5.1.x86_64.rpmlibX11-devel-1.5.0-4.el6.x86_64.rpmlibXau-devel-1.0.6-4.el6.x86_64.rpmlibXpm-devel-3.5.10-2.el6.x86_64.rpmlibcom_err-1.41.12-18.el6_5.1.x86_64.rpmlibcom_err-devel-1.41.12-18.el6_5.1.x86_64.rpmlibjpeg-turbo-1.2.1-3.el6_5.x86_64.rpmlibjpeg-turbo-devel-1.2.1-3.el6_5.x86_64.rpmlibpng-devel-1.2.49-1.el6_2.x86_64.rpmlibselinux-devel-2.0.94-5.3.el6_4.1.x86_64.rpmlibsepol-devel-2.0.41-4.el6.x86_64.rpmlibss-1.41.12-18.el6_5.1.x86_64.rpmlibxcb-devel-1.8.1-1.el6.x86_64.rpmmailcap-2.1.31-2.el6.noarch.rpmmpfr-2.4.1-6.el6.x86_64.rpmopenssl-1.0.1e-16.el6_5.15.x86_64.rpmopenssl-devel-1.0.1e-16.el6_5.15.x86_64.rpmppl-0.10.2-11.el6.x86_64.rpmxorg-x11-proto-devel-7.6-25.el6.noarch.rpmzlib-devel-1.2.3-29.el6.x86_64.rpmksh-20120801-21.el6.1.x86_64.rpm--force
3.2添加icinga用户及用户组
useradd-micinga
passwdicinga
3.3编译安装Nagios插件
3.3.1解压
cd/usr/local/softwares
tarxvficinga-nagios-cn-plugins-1.4.15.tar.bz2
cdicinga-cn-plugins-1.4.15/
3.3.2编译安装
#>./configure--prefix=/usr/local/icinga\
--with-cgiurl=/icinga/cgi-bin--with-htmurl=/icinga\
--with-nagios-user=icinga--with-nagios-group=icinga
#>make
#>makeinstall
3.4编译安装NRPE
3.4.1解压
tarzxvficinga-nrpe-2.14.tar.gz
cdicinga-nrpe-2.14
3.4.2配置
./configure--enable-ssl
makeall
修改sample-config/nrpe.cfg,修改设置allowed_hosts=172.19.17.142,ip为Icinga服务器地址,多个地址用逗号隔开
3.4.3第二次测试
在受控服务器上启动:
/usr/loc