溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

CentOS 6.4安裝Nagios 3.5.0

發(fā)布時(shí)間:2020-07-22 07:32:07 來(lái)源:網(wǎng)絡(luò) 閱讀:1957 作者:rong341233 欄目:移動(dòng)開(kāi)發(fā)

Nagios是一款開(kāi)源的免費(fèi)網(wǎng)絡(luò)監(jiān)視工具,能有效監(jiān)控Windows、Linux和Unix的主機(jī)狀態(tài),交換機(jī)路由器等網(wǎng)絡(luò)設(shè)置,打印機(jī)等。在系統(tǒng)或服務(wù)狀態(tài)異常時(shí)發(fā)出郵件或短信報(bào)警第一時(shí)間通知網(wǎng)站運(yùn)維人員,在狀態(tài)恢復(fù)后發(fā)出正常的郵件或短信通知。

一.安裝環(huán)境的配置

1.關(guān)閉防火墻

為了防止因?yàn)榉阑饓Φ脑蛴绊懳覀儼惭b的環(huán)境,我們對(duì)防火墻進(jìn)行關(guān)閉,如果在實(shí)際的生產(chǎn)環(huán)境中,我們是不建議關(guān)閉防火墻的。

[root@Nagios ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@Nagios ~]# chkconfig iptables off

2.關(guān)閉SELinux

如果未關(guān)閉SELinux,則可能在安裝完成后,會(huì)出現(xiàn)Internal Server Error錯(cuò)誤

編輯/etc/selinux/config

[root@Nagios ~]# vim /etc/selinux/config

將SELINUX=disabled


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.

SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

3.修改hosts文件

已知我們這臺(tái)機(jī)器的主機(jī)名為Nagios,則修改/etc/hosts

127.0.0.1  Nagios localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

添加上面紅色部分即可,否則啟動(dòng)apache服務(wù)的時(shí)候可能出現(xiàn)

Starting httpd: httpd: apr_sockaddr_info_get() failed for Nagios


做完以上3個(gè)步驟后,我們需要重新啟動(dòng)服務(wù)器。


二.軟件的準(zhǔn)備

1.安裝必要的軟件

[root@Nagios ~]# yum -y install wget make openssl openssl-devel httpd php gcc glibc \

> glibc-common gd gd-devel net-snmp mysql \

> mysql-server mysql-devel php-mysql perl perl-devel gnutls gnutls-devel

2.MySQL的配置(此步可省略)

雖然現(xiàn)在還并未使用MySQL,但是在以后的配置需要用到。

首先啟動(dòng)MySQL服務(wù)器

[root@Nagios ~]# service mysqld start
接著設(shè)置更改MySQL root賬戶的密碼

[root@Nagios ~]# mysqladmin -u root password 123456

三.軟件的安裝

1.Nagios賬戶及組的添加

[root@Nagios ~]# useradd nagios
[root@Nagios ~]# groupadd nagcmd
[root@Nagios ~]# usermod -a -G nagcmd nagios
[root@Nagios ~]# usermod -a -G nagcmd apache


2.軟件的下載

Nagios軟件的下載
[root@Nagios ~]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.5.0.tar.gz
[root@Nagios ~]# wget
http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz


3.Nagios軟件的解壓

[root@Nagios ~]# tar zxvf nagios-3.5.0.tar.gz

[root@Nagios ~]# tar zxvf nagios-plugins-1.4.16.tar.gz


4.Nagios的編譯與安裝

首先進(jìn)入Nagios解壓后所在的目錄

[root@Nagios ~]# cd nagios
[root@Nagios nagios]# ./configure --with-command-group=nagcmd

[root@Nagios nagios]# make all

[root@Nagios nagios]# make install

[root@Nagios nagios]# make  install-init

[root@Nagios nagios]# make  install-config

[root@Nagios nagios]# make  install-commandmode

[root@Nagios nagios]# make  install-webconf


[root@Nagios nagios]# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
[root@Nagios nagios]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers/

測(cè)試nagios的配置文件

[root@Nagios nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果最后出現(xiàn)

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

就證明nagios配置無(wú)誤可正常啟動(dòng)!


啟動(dòng)Nagios服務(wù):

[root@Nagios nagios]# service nagios start
Starting nagios: done.

啟動(dòng)httpd服務(wù):

[root@Nagios nagios]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                          [  OK  ]

添加訪問(wèn)WEB服務(wù)的賬戶及密碼

[root@Nagios nagios]# htpasswd -c /usr/local/nagios/etc/htpasswd.users admin
New password:
Re-type new password:
Adding password for user admin

這個(gè)時(shí)候就已經(jīng)添加好了訪問(wèn)web網(wǎng)站的用戶了


5.Nagios plugin的安裝

首先進(jìn)入Nagios plugin解壓目錄

[root@Nagios nagios]# cd ../nagios-plugins-1.4.16
進(jìn)行編譯:

[root@Nagios nagios-plugins-1.4.16]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-extra-opts --enable-perl-modules --enable-libtap

編譯成功后,會(huì)出現(xiàn)如下信息:

          --with-apt-get-command:
             --with-ping6-command: /bin/ping6 -n -U -w %d -c %d %s
              --with-ping-command: /bin/ping -n -U -w %d -c %d %s
                      --with-ipv6: yes
                     --with-mysql: /usr/bin/mysql_config
                   --with-openssl: yes
                    --with-gnutls: no
              --enable-extra-opts: yes
                      --with-perl: /usr/bin/perl
            --enable-perl-modules: yes
                    --with-cgiurl: /nagios/cgi-bin
              --with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin
                  --enable-libtap: yes


插件的安裝


[root@Nagios nagios-plugins-1.4.16]# make

[root@Nagios nagios-plugins-1.4.16]# make install


最后將nagios及httpd加入啟動(dòng)項(xiàng),并自動(dòng)啟動(dòng)

[root@Nagios nagios-plugins-1.4.16]# chkconfig --add nagios
[root@Nagios nagios-plugins-1.4.16]# chkconfig --level 35 nagios on
[root@Nagios nagios-plugins-1.4.16]# chkconfig --add httpd
[root@Nagios nagios-plugins-1.4.16]# chkconfig --level 35 httpd on


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI