由于要搭建的nagios主机是一个裸机,所以搭建nagios监控系统前需要搭建一个简单的LAMP平台,
这里我就直接用yum安装了
yum -y install http* mysql* php-*
对于英语不好的我,每做完一步我就喜欢用echo $? 验证一下 看看返回值是不是0 如果是0说明 *** 作正确,否则错误,这种方法对我很实用,谁让英语差呢!
[root@localhost ~]# service httpd start
启动 httpd: [确定]
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
231 User apache
232 Group apache
391 DirectoryIndex index.php index.html index.html.var
992 #setting for nagios
993ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
994
995AuthType Basic
996 Options ExecCGI
997 AllowOverride None
998 Order allow,deny
999 Allow from all
1000AuthName "nagios access"
1001AuthUserFile /usr/local/nagios/etc/htpasswd
1002Require valid-user
1003
1004Alias /nagios "/usr/local/nagios/share"
1005
1006 AuthType Basic
1007 Options ExecCGI
1008AllowOverride None
1009 Order allow,deny
1010 Allow from all
1011AuthName "nagios access"
1012AuthUserFile /usr/local/nagios/etc/htpasswd
1013 Require valid-user
1014
创建apache目录的验证文件,mkdir -p /usr/local/nagios/etc/htpasswd
添加用户
[root@localhost ~]# htpasswd -c /usr/local/nagios/etc/htpasswd cainiao
二:nagios安装
(1)创建nagios程序用户、组
[root@localhost ~]# useradd -s /sbin/nologin nagios
[root@localhost ~]# mkdir /usr/local/nagios/
[root@localhost ~]# chown -R nagios:nagios /usr/local/nagios/
( 2) 安装和编译nagios
搭建nagios所需要的软件已经放在/nagios
[root@localhost nagios]# tar zxf nagios-3.2.0.tar.gz
[root@localhost nagios]# 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
(3)安装nagios插件
[root@localhost nagios]# tar zxf nagios-plugins-1.4.14.tar.gz
[root@localhost nagios]# cd nagios-plugins-1.4.14
[root@localhost nagios-plugins-1.4.14]# ./configure --prefix=/usr/local/nagios/ make make insta
(4)安装Nagios的汉化包
[root@localhost nagios]# tar jxf nagios-cn-3.2.0.tar.bz2
[root@localhost nagios]# cd nagios-cn-3.2.0
[root@localhost nagios-cn-3.2.0]# ./configure make all make install
接下来通过浏览器验证nagios是否安装成功
http:.//nagios的ip/nagios 这里就假如nagios的服务器的ip是:192.168.1.1
将nagios添加到服务中设置服务为自启动
检测nagios的配置是否正确,在后面配置nagios过程中我们为了检测配置的是否正确需要不断执行该命令来检查配置文件。
#service nagios start 启动nagios
需要注意的是,Centos默认打开了selinux并且运行于强制安全模式,这将导致在打开nagios的web界面时会出现Internet Server Error的错误。
查看是否运行于强制模式,结果为1表示是
更改selinux运行于宽容模式
但是这个设置重启后就会失效,如需要重启后保持该设置需要修改/etc/sysconfig/selinux,将其中的SELINUX= enforcing更改为SELINUX= permissive并重启系统。当然你也可以改成disable禁用selinux
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)