adminlng 发表于 2013-6-4 08:42:48

CentOS 6.4安装Nagios 3.5.0

Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。一.安装环境的配置1.关闭防火墙为了防止因为防火墙的原因影响我们安装的环境,我们对防火墙进行关闭,如果在实际的生产环境中,我们是不建议关闭防火墙的。# service iptables stop
iptables: Flushing firewall rules:                        
iptables: Setting chains to policy ACCEPT: filter         
iptables: Unloading modules:                              
# chkconfig iptables off2.关闭SELinux如果未关闭SELinux,则可能在安装完成后,会出现Internal Server Error错误编辑/etc/selinux/config# 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/hosts127.0.0.1Nagios localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
添加上面红色部分即可,否则启动apache服务的时候可能出现Starting httpd: httpd: apr_sockaddr_info_get() failed for Nagios
做完以上3个步骤后,我们需要重新启动服务器。
二.软件的准备1.安装必要的软件# yum -y install wget make openssl openssl-devel httpd php gcc glibc \
> glibc-common gd gd-devel net-snmp mysql \
> mysql-server mysql-devel perl perl-devel gnutls gnutls-devel
2.MySQL的配置(此步可省略)虽然现在还并未使用MySQL,但是在以后的配置需要用到。首先启动MySQL服务器# service mysqld start
接着设置更改MySQL root账户的密码# mysqladmin -u root password 123456

三.软件的安装1.Nagios账户及组的添加# useradd nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache

2.软件的下载Nagios软件的下载
# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.5.0.tar.gz
# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz

3.Nagios软件的解压# tar zxvf nagios-3.5.0.tar.gz

# tar zxvf nagios-plugins-1.4.16.tar.gz

4.Nagios的编译与安装
首先进入Nagios解压后所在的目录# cd nagios
# ./configure --with-command-group=nagcmd# make all
# makeinstall-init# makeinstall-config# makeinstall-commandmode# makeinstall-webconf
# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers/
测试nagios的配置文件# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果最后出现Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check就证明nagios配置无误可正常启动!
启动Nagios服务:# service nagios start
Starting nagios: done.
启动httpd服务:# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                         
添加访问WEB服务的账户及密码# htpasswd -c /usr/local/nagios/etc/htpasswd.users admin
New password:
Re-type new password:
Adding password for user admin
这个时候就已经添加好了访问web网站的用户了
5.Nagios plugin的安装首先进入Nagios plugin解压目录# cd ../nagios-plugins-1.4.16
进行编译:# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-extra-opts --enable-perl-modules --enable-libtap
编译成功后,会出现如下信息:
          --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

插件的安装
# make# make install
最后将nagios及httpd加入启动项,并自动启动# chkconfig --add nagios
# chkconfig --level 35 nagios on
# chkconfig --add httpd
# chkconfig --level 35 httpd on

jjfjjj 发表于 2013-6-4 08:46:29

相当不错,感谢无私分享精神!

haloi 发表于 2013-6-4 08:49:06

看尽天下A片,心中自然无码~

wsjz_01 发表于 2013-6-4 09:20:50

走,MM,咱们化蝶去……

南天一柱 发表于 2013-6-4 10:03:56

过来看看的

fjptec-xm 发表于 2013-6-4 10:21:53

此地禁止大小便,违者没收工具。

efn阿克说 发表于 2013-6-4 10:42:43

爱——不是想出来的,爱——是做出来的!!
页: [1]
查看完整版本: CentOS 6.4安装Nagios 3.5.0