Nagios和Centreon的安裝部署

Centreon是開源的IT監控軟件,由法國人於2003年開發,最初名爲Oreon,並於2005年正式改名爲centreon。

centreon做爲nagios的分佈式監控管理平臺,其功能之強大,打造了centreon在IT監控方面強勢地位,它的底層使用nagios監控軟件,nagios經過ndoutil模塊將監控數據寫入數據庫,centreon讀取該數據並即時的展示監控信息,經過centreon能夠簡單地管理和配置全部nagios,所以,徹底可使用centreon輕易的搭建企業級分佈式IT基礎運維監控系統。php

注:以上內容摘自百度百科mysql


1、準備工做:linux

1)配置yum源
ios

   最好保證此主機能上Internet,由於光盤內的安裝包有些版本比較舊,還有一部分安裝包沒有,因此若是把光盤做爲yum源,會在後面的安裝過程當中碰到一些麻煩。 web

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

2)安裝包下載sql

http://pan.baidu.com/s/1qWLefKS數據庫

以上鍊接中包括Nagios,Nagios-Plugins,Centreon,RRDtool,ndoutils源碼安裝包apache

2、LAMP環境搭建vim

   若是網絡環境好,且硬盤足夠大建議最大化安裝,由於這樣能夠最大化的避免源碼安裝過程當中找不到庫文件,centreon配置時找不到對應文件的尷尬。centos

安裝以前先安裝開發包組:

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包:http://rpm.pbone.net/index.php3?stat=26&dist=74&size=1426424&name=bcel-5.2-7.2.el6.x86_64.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 start
service mysqld start
mysqladmin -uroot password 123456

看到以下界面說明安裝成功

wKiom1LU0OSj4dF0AAjYHoakx5c866.jpg


3、Nagios及相關插件安裝

Nagios安裝:    

useradd -s /sbin/nologin -G apache nagios #增長Nagios用戶,並將其加入apache組中
tar xf nagios-3.4.4.tar.gz
tar xf nagios-3.4.4.tar.gz
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make all
make install
make install-init && make install-commandmode &&  make install-config && make install-webconf

Nagios-plugins安裝

tar xf nagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5
./configure --prefix=/usr/local/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios
make
make 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 #關閉selinux
sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/sysconfig/selinux #在配置文件中永久關閉selinux

ndoutils安裝

tar xf ndoutils-1.5.2.tar.gz
cd ndoutils-1.5.2
./configure --prefix=/usr/local/nagios --with-mysql-lib=/usr/lib/mysql --with-mysql-inc=/usr/include/mysql
make
cp 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.cfg
cp config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
chown 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=123456
mysql -uroot
     mysql> create database nagios;
     mysql> grant all on nagios.* to nagios@localhost identified by '123456';
     mysql> flush privileges;
     mysql> q
mysql -unagios -p123456 nagios < db/mysql.sql
vim /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.gz
cd rrdtool-1.4.7
./configure --prefix=/usr/local/rrdtool && make && make install


4、Centreon安裝

chmod o=rwx /usr/local/centreon/log
tar -zxvf centreon-2.4.0.tar.gz
cd centreon-2.4.0
./install.sh -i
Do 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]:
> y
Do you want to install : Centreon CentCore
[y/n], default to [n]:
> y
Do you want to install : Centreon Nagios Plugins
[y/n], default to [n]:
> y
Do 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                                   OK
Where is your Centreon log directory
default to [/usr/local/centreon/log]
>
Path /usr/local/centreon/log                               OK
Where is your Centreon etc directory
default to [/etc/centreon]
>
Path /etc/centreon                                         OK
Where is your Centreon binaries directory
default to [/usr/local/centreon/bin]
>
Path /usr/local/centreon/bin                               OK
Where is your Centreon data informations directory
default to [/usr/local/centreon/data]
>
Path /usr/local/centreon/data                              OK
Where is your Centreon generation_files directory?
default to [/usr/local/centreon]
>
Path /usr/local/centreon                                   OK
Where is your Centreon variable library directory?
default to [/var/lib/centreon]
>
Path /var/lib/centreon                                     OK
Where is your CentPlugins Traps binary
default to [/usr/local/centreon/bin]
>
Path /usr/local/centreon/bin                               OK
Where 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.pm
Path /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                                              OK
Finding Apache user :                                      apache
Finding Apache group :                                     apache
What 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/                            OK
Add group centreon to user apache                          OK
Add group centreon to user centreon                        OK
Add group centreon to user apache                          OK
Add group centreon to user centreon                        OK
------------------------------------------------------------------------
        Configure Sudo
------------------------------------------------------------------------
Where is sudo configuration file
default to [/etc/sudoers]
>
/etc/sudoers                                               OK
What 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-3x
Your sudo is not configured
Do you want me to configure your sudo ? (WARNING)
[y/n], default to [n]:
> y
Configuring Sudo                                           OK
------------------------------------------------------------------------
        Configure Apache server
------------------------------------------------------------------------
Do you want to add Centreon Apache sub configuration file ?
[y/n], default to [n]:
> y
Create '/etc/httpd/conf.d/centreon.conf'                   OK
Configuring Apache                                         OK
Do you want to reload your Apache ?
[y/n], default to [n]:
> y
Configuring Sudo                                           OK
------------------------------------------------------------------------
 Configure Apache server
------------------------------------------------------------------------
Do you want to add Centreon Apache sub configuration file ?
[y/n], default to [n]:
> y
Create '/etc/httpd/conf.d/centreon.conf'                   OK
Configuring Apache                                         OK
Do you want to reload your Apache ?
[y/n], default to [n]:
> y
Reloading Apache service                                   OK
Preparing Centreon temporary files
Change right on /usr/local/centreon/log                    OK
Change right on /etc/centreon                              OK
Change macros for insertBaseConf.sql                       OK
Change macros for sql update files                         OK
Change macros for php files                                OK
Change right on /usr/local/nagios/etc                      OK
Copy CentWeb in system directory
Install CentWeb (web front of centreon)                    OK
Change right for install directory
Change right for install directory                         OK
Install libraries                                          OK
Write right to Smarty Cache                                OK
Copying libinstall                                         OK
Change macros for centreon.cron                            OK
Install Centreon cron.d file                               OK
Change macros for centAcl.php                              OK
Change macros for downtimeManager.php                      OK
Change macros for eventReportBuilder.pl                    OK
Change macros for dashboardBuilder.pl                      OK
Install cron directory                                     OK
Change right for eventReportBuilder.pl                     OK
Change right for dashboardBuilder.pl                       OK
Change macros for centreon.logrotate                       OK
Install Centreon logrotate.d file                          OK
Prepare export-mysql-indexes                               OK
Install export-mysql-indexes                               OK
Prepare import-mysql-indexes                               OK
Install import-mysql-indexes                               OK
Prepare indexes schema                                     OK
Install indexes schema                                     OK
------------------------------------------------------------------------
Pear Modules
------------------------------------------------------------------------
Check PEAR modules
PEAR                            1.4.9       1.9.4          OK
DB                              1.7.6                      NOK
DB_DataObject                   1.8.4                      NOK
DB_DataObject_FormBuilder       1.0.0RC4                   NOK
MDB2                            2.0.0                      NOK
Date                            1.4.6                      NOK
HTML_Common                     1.2.2                      NOK
HTML_QuickForm                  3.2.5                      NOK
HTML_QuickForm_advmultiselect   1.1.0                      NOK
HTML_Table                      1.6.1                      NOK
Archive_Tar                     1.1         1.3.7          OK
Auth_SASL                       1.0.1                      NOK
Console_Getopt                  1.2         1.2.3          OK
Net_SMTP                        1.2.8                      NOK
Net_Socket                      1.0.1                      NOK
Net_Traceroute                  0.21                       NOK
Net_Ping                        2.4.1                      NOK
Validate                        0.6.2                      NOK
XML_RPC                         1.4.5       1.5.4          OK
SOAP                            0.10.1                     NOK
Log                             1.9.11                     NOK
Archive_Zip                     0.1.2                      NOK
Do you want me to install/upgrade your PEAR modules
[y/n], default to [y]:
> y
Upgrading PEAR modules
Installing PEAR modules
DB                              1.7.6       1.7.14         OK
DB_DataObject                   1.8.4       1.11.2         OK
DB_DataObject_FormBuilder       1.0.0RC4    1.0.2          OK
MDB2                            2.0.0       2.4.1          OK
HTML_QuickForm_advmultiselect   1.1.0       1.5.1          OK
HTML_Table                      1.6.1       1.8.3          OK
Auth_SASL                       1.0.1       1.0.6          OK
Net_SMTP                        1.2.8       1.6.2          OK
Net_Traceroute                  0.21        0.21.3         OK
Net_Ping                        2.4.1       2.4.5          OK
Validate                        0.6.2       0.8.5          OK
SOAP                            0.10.1      0.13.0         OK
Log                             1.9.11      1.12.7         OK
Archive_Zip                     0.1.2       0.1.2          OK
Check PEAR modules
PEAR                            1.4.9       1.9.4          OK
DB                              1.7.6       1.7.14         OK
DB_DataObject                   1.8.4       1.11.2         OK
DB_DataObject_FormBuilder       1.0.0RC4    1.0.2          OK
MDB2                            2.0.0       2.4.1          OK
Date                            1.4.6       1.4.7          OK
HTML_Common                     1.2.2       1.2.5          OK
HTML_QuickForm                  3.2.5       3.2.13         OK
HTML_QuickForm_advmultiselect   1.1.0       1.5.1          OK
HTML_Table                      1.6.1       1.8.3          OK
Archive_Tar                     1.1         1.3.7          OK
Auth_SASL                       1.0.1       1.0.6          OK
Console_Getopt                  1.2         1.2.3          OK
Net_SMTP                        1.2.8       1.6.2          OK
Net_Socket                      1.0.1       1.0.14         OK
Net_Traceroute                  0.21        0.21.3         OK
Net_Ping                        2.4.1       2.4.5          OK
Validate                        0.6.2       0.8.5          OK
XML_RPC                         1.4.5       1.5.4          OK
SOAP                            0.10.1      0.13.0         OK
Log                             1.9.11      1.12.7         OK
Archive_Zip                     0.1.2       0.1.2          OK
All PEAR modules                                           OK
------------------------------------------------------------------------
                Centreon Post Install
------------------------------------------------------------------------
Create /usr/local/centreon/www/install/install.conf.php    OK
Create /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]:
> y
Path /var/run/centreon                                     OK
Where is your CentStorage binary directory
default to [/usr/local/centreon/bin]
> y
You select slash...
Where is your CentStorage binary directory
default to [/usr/local/centreon/bin]
>
Path /usr/local/centreon/bin                               OK
Where is your CentStorage RRD directory
default to [/var/lib/centreon]
>
Path /var/lib/centreon                                     OK
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
install www/install/createTablesCentstorage.sql            OK
Creating Centreon Directory '/var/lib/centreon/status'     OK
Creating Centreon Directory '/var/lib/centreon/metrics'    OK
Change macros for centstorage binary                       OK
Install CentStorage binary                                 OK
Install library for centstorage                            OK
Change right : /var/run/centreon                           OK
Change macros for centstorage init script                  OK
Do you want me to install CentStorage init script ?
[y/n], default to [n]:
> y
CentStorage init script installed                          OK
Do you want me to install CentStorage run level ?
[y/n], default to [n]:
> y
Change macros for logAnalyser                              OK
Install logAnalyser                                        OK
Change macros for logAnalyser-cbroker                      OK
Install logAnalyser-cbroker                                OK
Change macros for nagiosPerfTrace                          OK
Install nagiosPerfTrace                                    OK
Change macros for purgeLogs                                OK
Install purgeLogs                                          OK
Change macros for purgeCentstorage                         OK
Install purgeCentstorage                                   OK
Change macros for centreonPurge.sh                         OK
Install centreonPurge.sh                                   OK
Change macros for centstorage.cron                         OK
Install CentStorage cron                                   OK
Change macros for centstorage.logrotate                    OK
Install Centreon Storage logrotate.d file                  OK
Create /etc/centreon/instCentStorage.conf                  OK
------------------------------------------------------------------------
        Start CentCore Installation
------------------------------------------------------------------------
Where is your CentCore binary directory
default to [/usr/local/centreon/bin]
>
Path /usr/local/centreon/bin                               OK
/usr/bin/ssh                                               OK
/usr/bin/scp                                               OK
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change CentCore Macro                                      OK
Copy CentCore in binary directory                          OK
Change right : /var/run/centreon                           OK
Change right : /var/lib/centreon                           OK
Change macros for centcore.logrotate                       OK
Install Centreon Core logrotate.d file                     OK
Replace CentCore init script Macro                         OK
Do you want me to install CentCore init script ?
[y/n], default to [n]:
> y
CentCore init script installed                             OK
Do you want me to install CentCore run level ?
[y/n], default to [n]:
> y
Create /etc/centreon/instCentCore.conf                     OK
------------------------------------------------------------------------
        Start CentPlugins Installation
------------------------------------------------------------------------
Where is your CentPlugins lib directory
default to [/var/lib/centreon/centplugins]
> y
You select slash...
Where is your CentPlugins lib directory
default to [/var/lib/centreon/centplugins]
>
Do you want me to create this directory ? [/var/lib/centreon/centplugins]
[y/n], default to [n]:
> y
Path /var/lib/centreon/centplugins                         OK
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change macros for CentPlugins                              OK
Installing the plugins                                     OK
Change right on centreon.conf                              OK
CentPlugins is installed
------------------------------------------------------------------------
        Start CentPlugins Traps Installation
------------------------------------------------------------------------
Where is your SNMP configuration directory
default to [/etc/snmp]
>
/etc/snmp                                                  OK
Where is your SNMPTT binaries directory
default to [/usr/local/centreon/bin/]
>
/usr/local/centreon/bin/                                   OK
Finding Apache user :                                      apache
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change macros for CentPluginsTraps                         OK
Change macros for init scripts                             OK
Installing the plugins Trap binaries                       OK
Change macros for snmptrapd.conf                           OK
Change macros for snmptt.ini                               OK
SNMPTT init script installed                               OK
Install : snmptrapd.conf                                   OK
Install : snmp.conf                                        OK
Install : snmptt.ini                                       OK
Install : snmptt                                           OK
Install : snmptthandler                                    OK
Install : snmpttconvertmib                                 OK
Create /etc/centreon/instCentPlugins.conf                  OK
hostname: 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作初始化。

相關文章
相關標籤/搜索