Nagios服務器架設之一
Nagios服務器架設之一
實驗環境:RHEL 5.4
一、Nagios服務器安裝過程
1)配置服務器端IP地址
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0c:29:fe:39:A1
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.6.199
GATEWAY=192.168.6.1
TYPE=Ethernet
2)安裝Nagios
A,安裝前準備
1)創建nagios程序用戶、組
[root@localhost ~]# useradd -s /sbin/nologin nagios ---阻止用戶登錄服務器
-s :用戶登錄shell
[root@localhost ~]# mkdir /usr/local/nagios
[root@localhost ~]# chown -R nagios.nagios /usr/local/nagios/ ---修改它的屬主屬組權限
2)保證系統中sendmail服務器要開啓
[root@localhost ~]# service sendmail status
sendmail (pid 3090) 正在運行...
B、編譯安裝Nagios
[root@localhost ~]# cd /aaa/
[root@localhost aaa]# tar zxf nagios-3.2.0.tar.gz
[root@localhost aaa]# cd nagios-3.2.0
[root@localhost nagios-3.2.0]# ./configure --prefix=/usr/local/nagios/
[root@localhost nagios-3.2.0]# make all ; make install ; make install-init ; make install-commandmode ; make install-config
[root@localhost nagios-3.2.0]# chkconfig --add nagios
[root@localhost nagios-3.2.0]# chkconfig nagios on
[root@localhost nagios-3.2.0]# chkconfig --list nagios ---查看nagios服務是否運行
nagios 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
C、安裝Nagios插件
[root@localhost aaa]# tar zxf nagios-plugins-1.4.14.tar.gz
[root@localhost aaa]# cd nagios-plugins-1.4.14
[root@localhost nagios-plugins-1.4.14]# ./configure --prefix=/usr/local/nagios/ ; make ; make install
D、安裝Nagios的漢化包
[root@localhost aaa]# tar jxf nagios-cn-3.2.0.tar.bz2
[root@localhost aaa]# cd nagios-cn-3.2.0
[root@localhost nagios-cn-3.2.0]# ./configure ; make all ; make install
E、安裝LAMP架構
[root@localhost ~]# mount /dev/cdrom /media/
[root@localhost ~]# vi /etc/yum.repos.d/rhel-debuginfo.repo
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debugbaseurl=file:///media/Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@localhost ~]# yum -y install php* mysql* http*
[root@localhost ~]# service httpd start
啓動 httpd: [確定]
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf
231 User apache
232 Group apache
391 DirectoryIndex index.php index.html index.html.var
992 #setting for nagios
993 ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
994 <Directory "/usr/local/nagios/sbin">
995 AuthType Basic
996 Options ExecCGI
997 AllowOverride None
998 Order allow,deny
999 Allow from all
1000 AuthName "nagios access"
1001 AuthUserFile /usr/local/nagios/etc/htpasswd
1002 Require valid-user
1003 </Directory>
1004 Alias /nagios "/usr/local/nagios/share"
1005 <Directory "/usr/local/nagios/share">
1006 AuthType Basic
1007 Options ExecCGI
1008 AllowOverride None
1009 Order allow,deny
1010 Allow from all
1011 AuthName "nagios access"
1012 AuthUserFile /usr/local/nagios/etc/htpasswd
1013 Require valid-user
1014 </Directory>
創建apache目錄的驗證文件“/usr/local/nagios/etc/htpasswd”
[root@localhost ~]# htpasswd -c /usr/local/nagios/etc/htpasswd benet
New password:
Re-type new password:
Adding password for user benet
重啓apache服務器並進行驗證nagios登陸情況
[root@localhost ~]# service httpd restart
停止 httpd: [確定]
啓動 httpd: [確定]
至此nagios服務器安裝結束
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.