Centreon是开源的IT监控软件,由法国人于2003年开发,最初名为Oreon,并于2005年正式更名为centreon。

centreon作为nagios的分布式监控管理平台,其功能之强大,打造了centreon在IT监控方面强势地位,它的底层使用nagios监控软件,nagios通过ndoutil模块将监控数据写入数据库,centreon读取该数据并即时的展现监控信息,通过centreon可以简单地管理和配置所有nagios,因此,完全可以使用centreon轻易的搭建企业级分布式IT基础运维监控系统。

注:以上内容摘自百度百科

一、准备工作:

1)配置yum源

   最好保证此主机能上Internet,因为光盘内的安装包有些版本比较旧,还有一部分安装包没有,所以如果把光盘作为yum源,会在后面的安装过程中碰到一些麻烦。

[root@Domain01 ~]# cat /etc/yum.repos.d/rhel-internet.repo[rhel-internet]name=rhel-internetbaseurl=http://centos.ustc.edu.cn/centos/6/os/x86_64/#中科大yum源enabled=1gpgcheck=0

2)安装包下载

以上连接中包括Nagios,Nagios-Plugins,Centreon,RRDtool,ndoutils源码安装包

二、LAMP环境搭建

   如果网络环境好,且硬盘足够大建议最大化安装,因为这样可以最大化的避免源码安装过程中找不到库文件,centreon配置时找不到对应文件的尴尬。

安装之前先安装开发包组:

yum -y groupinstall "Development tools"yum -y install gd gd-devel

最大化安装LAMP:

yum -y install httpd*yum -y install mysql*yum -y install php*

   由于安装文件比较多,这几步视网络情况可能要花几分钟时间,期间可以上个厕所,沏杯茶,或者刷耍微博之类的。

   如果在安装过程中出现以下错误:

Error Downloading Packages:  bcel-5.2-7.2.el6.x86_64: failure: Packages/bcel-5.2-7.2.el6.x86_64.rpm from rhel-internet: [Errno 256] No more mirrors to try.

请下载对应的安装包后安装,bcel的rpm包: 右键另存为即可。

安装过程中如存在依赖关系请使用yum安装:

yum -y install bcel-5.2-7.2.el6.x86_64.rpm

安装完成后记得将httpd,mysqld,加入开机启动中:

[root@Domain01 ~]# chkconfig httpd on[root@Domain01 ~]# chkconfig mysqld on

开启httpd服务并测试:

service httpd startservice mysqld startmysqladmin -uroot password 123456

看到如下界面说明安装成功

三、Nagios及相关插件安装

Nagios安装:    

useradd -s /sbin/nologin -G apache nagios #增加Nagios用户,并将其加入apache组中tar xf nagios-3.4.4.tar.gztar xf nagios-3.4.4.tar.gz./configure --with-nagios-user=nagios --with-nagios-group=nagiosmake allmake installmake install-init && make install-commandmode &&  make install-config && make install-webconf

Nagios-plugins安装

tar xf nagios-plugins-1.5.tar.gzcd nagios-plugins-1.5./configure --prefix=/usr/local/nagios/ --with-nagios-user=nagios --with-nagios-group=nagiosmakemake install

相关配置:

创建Nagios web登录用户并设置密码

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

防火墙和Selinux设置:

iptables -F  #清除防火墙规则,生产环境慎用iptables -A INPUT -p tcp --dport 80 -j ACCEPT #开启80端口setenforce 0 #关闭selinuxsed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/sysconfig/selinux #在配置文件中永久关闭selinux

ndoutils安装

tar xf ndoutils-1.5.2.tar.gzcd ndoutils-1.5.2./configure --prefix=/usr/local/nagios --with-mysql-lib=/usr/lib/mysql --with-mysql-inc=/usr/include/mysqlmakecp src/ndo2db-3x src/file2sock src/log2ndo src/ndomod-3x.o /usr/local/nagios/bin/cp config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfgcp config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfgchown nagios.nagios /usr/local/nagios/bin/* /usr/local/nagios/etc/ndo*vim /usr/local/nagios/etc/ndo2db.cfg--------------------------------------------------------------------------------------------------     120 db_user=nagios     121 db_pass=123456mysql -uroot     mysql> create database nagios;     mysql> grant all on nagios.* to nagios@localhost identified by '123456';     mysql> flush privileges;     mysql> qmysql -unagios -p123456 nagios < db/mysql.sqlvim /usr/local/nagios/etc/nagios.cfg--------------------------------------------------------------------------------------------------    219 event_broker_options=-1    220broker_module=/usr/local/nagios/bin/ndomod3x.o    config_file=/usr/local/nagios/etc/ndomod.cfg  #增加本行代码/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg

RRDTool安装:

tar xf rrdtool-1.4.7.tar.gzcd rrdtool-1.4.7./configure --prefix=/usr/local/rrdtool && make && make install

四、Centreon安装

chmod o=rwx /usr/local/centreon/logtar -zxvf centreon-2.4.0.tar.gzcd centreon-2.4.0./install.sh -iDo you accept GPL license ?[y/n], default to [n]:> y------------------------------------------------------------------------        Please choose what you want to install------------------------------------------------------------------------Do you want to install : Centreon Web Front[y/n], default to [n]:> yDo you want to install : Centreon CentCore[y/n], default to [n]:> yDo you want to install : Centreon Nagios Plugins[y/n], default to [n]:> yDo you want to install : Centreon Snmp Traps process[y/n], default to [n]:> y------------------------------------------------------------------------        Start CentWeb Installation------------------------------------------------------------------------Where is your Centreon directory?default to [/usr/local/centreon]>Path /usr/local/centreon                                   OKWhere is your Centreon log directorydefault to [/usr/local/centreon/log]>Path /usr/local/centreon/log                               OKWhere is your Centreon etc directorydefault to [/etc/centreon]>Path /etc/centreon                                         OKWhere is your Centreon binaries directorydefault to [/usr/local/centreon/bin]>Path /usr/local/centreon/bin                               OKWhere is your Centreon data informations directorydefault to [/usr/local/centreon/data]>Path /usr/local/centreon/data                              OKWhere is your Centreon generation_files directory?default to [/usr/local/centreon]>Path /usr/local/centreon                                   OKWhere is your Centreon variable library directory?default to [/var/lib/centreon]>Path /var/lib/centreon                                     OKWhere is your CentPlugins Traps binarydefault to [/usr/local/centreon/bin]>Path /usr/local/centreon/bin                               OKWhere is the RRD perl module installed [RRDs.pm]default to [/usr/lib/perl5/RRDs.pm]> /usr/local/rrdtool/lib/perl/5.10.1/i386-linux-thread-multi/RRDs.pmPath /usr/local/rrdtool/lib/perl/5.10.1/i386-linux-thread-mOKti/usr/bin/rrdtool                                           OK/bin/mail                                                  OK/usr/bin/php                                               OK/usr/bin/perl                                              OKFinding Apache user :                                      apacheFinding Apache group :                                     apacheWhat is the Centreon group ? [centreon]default to [centreon]>What is the Centreon user ? [centreon]default to [centreon]>What is the Monitoring engine user ?> centreon                                                    #安装centreon的用户What is the Broker user ? (optional)>What is the Monitoring engine log directory ?> /usr/local/centreon/log                                    #日志存放目录             Where is your monitoring plugins (libexec) directory ?default to [/usr/lib/nagios/plugins]> /usr/local/nagios/libexec/                                  #libexec路径Path /usr/local/nagios/libexec/                            OKAdd group centreon to user apache                          OKAdd group centreon to user centreon                        OKAdd group centreon to user apache                          OKAdd group centreon to user centreon                        OK------------------------------------------------------------------------        Configure Sudo------------------------------------------------------------------------Where is sudo configuration filedefault to [/etc/sudoers]>/etc/sudoers                                               OKWhat is the Monitoring engine init.d script ?> /etc/init.d/nagios                                           #nagios初始路径在哪What is the Monitoring engine binary ?                     > /usr/local/nagios/bin/nagios                                 #nagios命令的路径What is the Monitoring engine configuration directory ?> /usr/local/nagios/etc/                                       #nagios的etc目录Where is the configuration directory for broker module ?> /usr/local/nagios/etc/                                       #ndoutils的路径Where is the init script for broker module daemon ?> /usr/local/nagios/bin/ndo2db-3xYour sudo is not configuredDo you want me to configure your sudo ? (WARNING)[y/n], default to [n]:> yConfiguring Sudo                                           OK------------------------------------------------------------------------        Configure Apache server------------------------------------------------------------------------Do you want to add Centreon Apache sub configuration file ?[y/n], default to [n]:> yCreate '/etc/httpd/conf.d/centreon.conf'                   OKConfiguring Apache                                         OKDo you want to reload your Apache ?[y/n], default to [n]:> yConfiguring Sudo                                           OK------------------------------------------------------------------------ Configure Apache server------------------------------------------------------------------------Do you want to add Centreon Apache sub configuration file ?[y/n], default to [n]:> yCreate '/etc/httpd/conf.d/centreon.conf'                   OKConfiguring Apache                                         OKDo you want to reload your Apache ?[y/n], default to [n]:> yReloading Apache service                                   OKPreparing Centreon temporary filesChange right on /usr/local/centreon/log                    OKChange right on /etc/centreon                              OKChange macros for insertBaseConf.sql                       OKChange macros for sql update files                         OKChange macros for php files                                OKChange right on /usr/local/nagios/etc                      OKCopy CentWeb in system directoryInstall CentWeb (web front of centreon)                    OKChange right for install directoryChange right for install directory                         OKInstall libraries                                          OKWrite right to Smarty Cache                                OKCopying libinstall                                         OKChange macros for centreon.cron                            OKInstall Centreon cron.d file                               OKChange macros for centAcl.php                              OKChange macros for downtimeManager.php                      OKChange macros for eventReportBuilder.pl                    OKChange macros for dashboardBuilder.pl                      OKInstall cron directory                                     OKChange right for eventReportBuilder.pl                     OKChange right for dashboardBuilder.pl                       OKChange macros for centreon.logrotate                       OKInstall Centreon logrotate.d file                          OKPrepare export-mysql-indexes                               OKInstall export-mysql-indexes                               OKPrepare import-mysql-indexes                               OKInstall import-mysql-indexes                               OKPrepare indexes schema                                     OKInstall indexes schema                                     OK------------------------------------------------------------------------Pear Modules------------------------------------------------------------------------Check PEAR modulesPEAR                            1.4.9       1.9.4          OKDB                              1.7.6                      NOKDB_DataObject                   1.8.4                      NOKDB_DataObject_FormBuilder       1.0.0RC4                   NOKMDB2                            2.0.0                      NOKDate                            1.4.6                      NOKHTML_Common                     1.2.2                      NOKHTML_QuickForm                  3.2.5                      NOKHTML_QuickForm_advmultiselect   1.1.0                      NOKHTML_Table                      1.6.1                      NOKArchive_Tar                     1.1         1.3.7          OKAuth_SASL                       1.0.1                      NOKConsole_Getopt                  1.2         1.2.3          OKNet_SMTP                        1.2.8                      NOKNet_Socket                      1.0.1                      NOKNet_Traceroute                  0.21                       NOKNet_Ping                        2.4.1                      NOKValidate                        0.6.2                      NOKXML_RPC                         1.4.5       1.5.4          OKSOAP                            0.10.1                     NOKLog                             1.9.11                     NOKArchive_Zip                     0.1.2                      NOKDo you want me to install/upgrade your PEAR modules[y/n], default to [y]:> yUpgrading PEAR modulesInstalling PEAR modulesDB                              1.7.6       1.7.14         OKDB_DataObject                   1.8.4       1.11.2         OKDB_DataObject_FormBuilder       1.0.0RC4    1.0.2          OKMDB2                            2.0.0       2.4.1          OKHTML_QuickForm_advmultiselect   1.1.0       1.5.1          OKHTML_Table                      1.6.1       1.8.3          OKAuth_SASL                       1.0.1       1.0.6          OKNet_SMTP                        1.2.8       1.6.2          OKNet_Traceroute                  0.21        0.21.3         OKNet_Ping                        2.4.1       2.4.5          OKValidate                        0.6.2       0.8.5          OKSOAP                            0.10.1      0.13.0         OKLog                             1.9.11      1.12.7         OKArchive_Zip                     0.1.2       0.1.2          OKCheck PEAR modulesPEAR                            1.4.9       1.9.4          OKDB                              1.7.6       1.7.14         OKDB_DataObject                   1.8.4       1.11.2         OKDB_DataObject_FormBuilder       1.0.0RC4    1.0.2          OKMDB2                            2.0.0       2.4.1          OKDate                            1.4.6       1.4.7          OKHTML_Common                     1.2.2       1.2.5          OKHTML_QuickForm                  3.2.5       3.2.13         OKHTML_QuickForm_advmultiselect   1.1.0       1.5.1          OKHTML_Table                      1.6.1       1.8.3          OKArchive_Tar                     1.1         1.3.7          OKAuth_SASL                       1.0.1       1.0.6          OKConsole_Getopt                  1.2         1.2.3          OKNet_SMTP                        1.2.8       1.6.2          OKNet_Socket                      1.0.1       1.0.14         OKNet_Traceroute                  0.21        0.21.3         OKNet_Ping                        2.4.1       2.4.5          OKValidate                        0.6.2       0.8.5          OKXML_RPC                         1.4.5       1.5.4          OKSOAP                            0.10.1      0.13.0         OKLog                             1.9.11      1.12.7         OKArchive_Zip                     0.1.2       0.1.2          OKAll PEAR modules                                           OK------------------------------------------------------------------------                Centreon Post Install------------------------------------------------------------------------Create /usr/local/centreon/www/install/install.conf.php    OKCreate /etc/centreon/instCentWeb.conf                      OK------------------------------------------------------------------------        Start CentStorage Installation------------------------------------------------------------------------Where is your Centreon Run Dir directory?default to [/var/run/centreon]>Do you want me to create this directory ? [/var/run/centreon][y/n], default to [n]:> yPath /var/run/centreon                                     OKWhere is your CentStorage binary directorydefault to [/usr/local/centreon/bin]> yYou select slash...Where is your CentStorage binary directorydefault to [/usr/local/centreon/bin]>Path /usr/local/centreon/bin                               OKWhere is your CentStorage RRD directorydefault to [/var/lib/centreon]>Path /var/lib/centreon                                     OKPreparing Centreon temporary files/tmp/centreon-setup exists, it will be moved...install www/install/createTablesCentstorage.sql            OKCreating Centreon Directory '/var/lib/centreon/status'     OKCreating Centreon Directory '/var/lib/centreon/metrics'    OKChange macros for centstorage binary                       OKInstall CentStorage binary                                 OKInstall library for centstorage                            OKChange right : /var/run/centreon                           OKChange macros for centstorage init script                  OKDo you want me to install CentStorage init script ?[y/n], default to [n]:> yCentStorage init script installed                          OKDo you want me to install CentStorage run level ?[y/n], default to [n]:> yChange macros for logAnalyser                              OKInstall logAnalyser                                        OKChange macros for logAnalyser-cbroker                      OKInstall logAnalyser-cbroker                                OKChange macros for nagiosPerfTrace                          OKInstall nagiosPerfTrace                                    OKChange macros for purgeLogs                                OKInstall purgeLogs                                          OKChange macros for purgeCentstorage                         OKInstall purgeCentstorage                                   OKChange macros for centreonPurge.sh                         OKInstall centreonPurge.sh                                   OKChange macros for centstorage.cron                         OKInstall CentStorage cron                                   OKChange macros for centstorage.logrotate                    OKInstall Centreon Storage logrotate.d file                  OKCreate /etc/centreon/instCentStorage.conf                  OK------------------------------------------------------------------------        Start CentCore Installation------------------------------------------------------------------------Where is your CentCore binary directorydefault to [/usr/local/centreon/bin]>Path /usr/local/centreon/bin                               OK/usr/bin/ssh                                               OK/usr/bin/scp                                               OKPreparing Centreon temporary files/tmp/centreon-setup exists, it will be moved...Change CentCore Macro                                      OKCopy CentCore in binary directory                          OKChange right : /var/run/centreon                           OKChange right : /var/lib/centreon                           OKChange macros for centcore.logrotate                       OKInstall Centreon Core logrotate.d file                     OKReplace CentCore init script Macro                         OKDo you want me to install CentCore init script ?[y/n], default to [n]:> yCentCore init script installed                             OKDo you want me to install CentCore run level ?[y/n], default to [n]:> yCreate /etc/centreon/instCentCore.conf                     OK------------------------------------------------------------------------        Start CentPlugins Installation------------------------------------------------------------------------Where is your CentPlugins lib directorydefault to [/var/lib/centreon/centplugins]> yYou select slash...Where is your CentPlugins lib directorydefault to [/var/lib/centreon/centplugins]>Do you want me to create this directory ? [/var/lib/centreon/centplugins][y/n], default to [n]:> yPath /var/lib/centreon/centplugins                         OKPreparing Centreon temporary files/tmp/centreon-setup exists, it will be moved...Change macros for CentPlugins                              OKInstalling the plugins                                     OKChange right on centreon.conf                              OKCentPlugins is installed------------------------------------------------------------------------        Start CentPlugins Traps Installation------------------------------------------------------------------------Where is your SNMP configuration directorydefault to [/etc/snmp]>/etc/snmp                                                  OKWhere is your SNMPTT binaries directorydefault to [/usr/local/centreon/bin/]>/usr/local/centreon/bin/                                   OKFinding Apache user :                                      apachePreparing Centreon temporary files/tmp/centreon-setup exists, it will be moved...Change macros for CentPluginsTraps                         OKChange macros for init scripts                             OKInstalling the plugins Trap binaries                       OKChange macros for snmptrapd.conf                           OKChange macros for snmptt.ini                               OKSNMPTT init script installed                               OKInstall : snmptrapd.conf                                   OKInstall : snmp.conf                                        OKInstall : snmptt.ini                                       OKInstall : snmptt                                           OKInstall : snmptthandler                                    OKInstall : snmpttconvertmib                                 OKCreate /etc/centreon/instCentPlugins.conf                  OKhostname: Unknown host################################################################################                                                                             ##                 Go to the URL : http:///centreon/                    ##                            to finish the setup                              ##                                                                             ##                  Report bugs at http://forge.centreon.com                   ##                                                                             ##                         Thanks for using Centreon.                          ##                          -----------------------                            ##                        Contact : infos@centreon.com                         ##                          http://www.centreon.com                            ##                                                                             ################################################################################

至此,Centreon安装完成。最后登录http://IP/centreon做初始化。