CentOS 下安裝 nagios 詳細攻略

CentOS 下安裝 nagios 詳細攻略

一、安裝環境 1.CentOS 6.5 64 位 2.nagios-4.3.2 3.nagios-plugins-2.2.1
二、安裝步驟
1.su root #切換到 root 用戶
2.yum install -y gcc glibcglibc-common gd gd-devel xinetd openssl-devel httpd php unzip perl

  1. vim /etc/selinux/config
    #關閉防火牆,將 SELINUX=enforcing 改爲 SELINUX=disabled,然後 重啓。 /usr/sbin/sestatus –v #查看防火牆狀態,若提示如下,說明關閉成功。

4.建立用戶和用戶組
[root@Nagios-Server /]# useradd -s /sbin/nologin nagios
[root@Nagios-Server /]# mkdir /usr/local/nagios
[root@Nagios-Server /]# chown -R nagios.nagios /usr/local/nagios

並將 nagios 以及 apache 用戶加入到 nagcmd 組中,確保 nagios 和 apache 有權限

groupadd nagcmd

usermod -G nagcmd nagios

usermod -G nagcmd apache

5.下載並安裝 Nagios
#wget https://assets.nagios.com/downloads/nagioscore/releases/nagios4.3.2.tar.gz

tar -zxvf nagios-4.3.2.tar.gz

cd nagios-4.3.2

#./configure --prefix=/usr/local/nagios --with-command-group=nagcmd

make all

make install

make install-init #初始化腳本

make install-config #示例配置文件

make install-commandmode #設置目錄權限 如果安裝完成之後使用命令:

ls /usr/local/nagios // 能夠在/usr/local/nagios 的目錄下面看 到這些目錄(bin etc sbin share var)就說明 nagios 安裝成功了。

make install-webconf #安裝完成以後是默認安裝到 Apache 的 conf.d 的目錄下的。

6.使用 apache 來創建基本的 web 頁認證方式

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

#回車後會提示輸入兩次密碼, 看 到如下提示,說明賬號設置成功(賬號:admin,密碼需牢記,頁面登錄需要用)
7.啓動服務
[root@localhost nagios-4.3.2]# service httpd restart #啓動 httpd 服務 Stopping httpd: [ OK ] Starting httpd: [ OK ]
[root@localhost nagios-4.3.2]# chkconfig --level 235 httpd on #設置開機啓動
8.下載並安裝 nagios-plugins 插件
[[email protected]]#wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
[root@localhost nagios-4.3.2]# tar -zxvf nagios-plugins-2.2.1.tar.gz
[root@localhost nagios-4.3.2]# cd nagios-plugins-2.2.1
[root@localhost nagios-plugins-2.2.1]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
#make

make install

#chkconfig --add nagios
#chkconfig nagios on //設置開機啓動

9.檢查配置文件的正確性
[root@localhost nagios-plugins-2.2.1]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/n agios.cfg
10.啓動 nagios 服務
[root@localhost nagios-plugins-2.2.1]# service nagios start
[root@localhost nagios-plugins-2.2.1]# service httpd start
在瀏覽器輸入 http://localhost/nagios 彈出窗口輸入賬號密碼,即可打開主頁

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章