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

一.安裝環(huán)境的配置
1.關(guān)閉防火墻
為了防止因為防火墻的原因影響我們安裝的環(huán)境,我們對防火墻進行關(guān)閉,如果在實際的生產(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,則可能在安裝完成后,會出現(xiàn)Internal Server Error錯誤
編輯/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文件
已知我們這臺機器的主機名為Nagios,則修改/etc/hosts
127.0.0.1 Nagios localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
添加上面紅色部分即可,否則啟動apache服務(wù)的時候可能出現(xiàn)
Starting httpd: httpd: apr_sockaddr_info_get() failed for Nagios
做完以上3個步驟后,我們需要重新啟動服務(wù)器。
二.軟件的準備
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,但是在以后的配置需要用到。
首先啟動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的編譯與安裝
首先進入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/
測試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配置無誤可正常啟動!
啟動Nagios服務(wù):
[root@Nagios nagios]# service nagios start
Starting nagios: done.
啟動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 ]
添加訪問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
這個時候就已經(jīng)添加好了訪問web網(wǎng)站的用戶了
5.Nagios plugin的安裝
首先進入Nagios plugin解壓目錄
[root@Nagios nagios]# cd ../nagios-plugins-1.4.16
進行編譯:
[root@Nagios nagios-plugins-1.4.16]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-extra-opts --enable-perl-modules --enable-libtap
編譯成功后,會出現(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加入啟動項,并自動啟動
[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
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
本文題目:CentOS6.4安裝Nagios3.5.0-創(chuàng)新互聯(lián)
文章轉(zhuǎn)載:http://chinadenli.net/article44/shsee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、App設(shè)計、網(wǎng)站改版、微信公眾號、域名注冊、手機網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容