51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 6740|回复: 2
打印 上一主题 下一主题

[原创文章] nagios安装

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-11-7 17:26:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
刚进入项目组时,项目比较还比较小,服务器不多,看到有一小伙子每天早上高峰时就用xshell打开各个服务器盯着看负载,看日志。
可是以后用户逐步增多,服务器肯定也是越来越做,业务不断提出的要求,服务模块也会不断的增加。作为运维要求7*24小时总不能也这样去做。
网上去搜了一下,nagios 比较合适。监控类的开源软件,觉得应该适用,于是就搭建了一个。后面也证明很实用。
以下是参考了网上的一些博客,安装中也遇到了自己的问题,都整理了一下,为以后参考使用。
参考 :
http://blog.sina.com.cn/s/blog_6b9293150102wmbt.html
http://imcn.me/html/y2013/16928.html
创建nagios用户和用户组
  1. useradd -s /sbin/nologin nagios
  2. mkdir /usr/local/nagios
  3. chown -R nagios.nagios /usr/local/nagios
复制代码

apache用户加入到nagios组,以便于在通过web操作nagios时能够具有足够的权限
usermod -a -G nagios apache

编译安装nagios核心

  1. tar zxf nagios-4.1.0rc1.tar.gz
  2. cd nagios-4.1.0rc1
  3. ./configure
  4. make all
  5. make install
  6. make install-init
  7. make install-commandmode
  8. make install-config
复制代码


创建几个文件夹,后面会用到
  1. mkdir /etc/httpd
  2. mkdir /etc/httpd/conf.d
  3. mkdir /etc/httpd/conf.d/nagios.conf
复制代码

make install-webconf #httpd的配置文件目录conf.d中创建NagiosWeb程序配置文件
发现没有安装appache,需要下载安装,见后面appache安装

创建一个登录nagios web程序的用户,这个用户帐号在以后通过web登录nagios认证时所用
  1. htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
复制代码



appache安装
参考:


  1. http://wenku.baidu.com/link?url=o_XnM_DkJUrctBLuem3Jwkk8lR43AM1i2oCAQqN4yoVY2Vu8Dfb0FY0bfoyCnZ1pOzxlRQoxFNeJvW6pfTPl7zKTutmN9JznaCvNOSrOtY3


  2. ./configure --prefix=/usr/local/apache --enable-so--enable-cgi--enable-info--enable-rewrite--enable-speling--enable-sertrack--enable-deflate --enable-ssl--enable-mime-magic--enable-module=so--enable-module=rewrite--enable-shared=max --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
  3. make &&make install
复制代码
报错:
  1. configure: error: APR not found.  Please read the documentation.
复制代码


需要安装几个依赖包,见安装APR
安装APR:
  a:解决apr not found问题>>>>>>


  1. <p style="margin: 0pt;"><span style='font-family: 宋体; font-size: 10.5pt; mso-spacerun: "yes"; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-font-kerning: 1.0000pt;'>1.[root@xt test]# tar -zxf apr-1.4.5.tar.gz  </span></p><p style="margin: 0pt;"><span style='font-family: 宋体; font-size: 10.5pt; mso-spacerun: "yes"; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-font-kerning: 1.0000pt;'>2.[root@xt test]# cd  apr-1.4.5  </span></p><p style="margin: 0pt;"><span style='font-family: 宋体; font-size: 10.5pt; mso-spacerun: "yes"; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-font-kerning: 1.0000pt;'>3.[root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr  </span></p><p style="margin: 0pt;"><span style='font-family: 宋体; font-size: 10.5pt; mso-spacerun: "yes"; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-font-kerning: 1.0000pt;'>4.[root@xt apr-1.4.5]# make && make install  </span></p><p style="margin: 0pt;"><span style='font-family: 宋体; font-size: 10.5pt; mso-spacerun: "yes"; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-font-kerning: 1.0000pt;'>5. b:<font face="宋体">解决</font><font face="Calibri">APR-util not found</font><font face="宋体">问题</font><font face="Calibri">>>>></font></span></p>
复制代码
  1. 1.[root@xt test]# tar -zxf apr-util-1.3.12.tar.gz  
  2. 2.[root@xt test]# cd apr-util-1.3.12  
  3. 3.[root@xt apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config  
  4. 4.[root@xt apr-util-1.3.12]# make && make install
复制代码

c:解决pcre问题>>>>>>>>>
  1. 1.[root@xt test]#unzip -o pcre-8.10.zip  
  2. 2.[root@xt test]#cd pcre-8.10  
  3. 3.[root@xt pcre-8.10]#./configure --prefix=/usr/local/pcre  
  4. 4.[root@xt pcre-8.10]#make && make install
  5. 4.最后编译Apache时加上:

  6. --with-apr=/usr/local/apr \

  7. --with-apr-util=/usr/local/apr-util/ \

  8. --with-pcre=/usr/local/pcre
复制代码

成功编译完成~






分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
 楼主| 发表于 2019-11-8 10:33:55 | 只看该作者
来源:
  1. <<a href="http://www.linuxidc.com/Linux/2012-06/62289.htm">http://www.linuxidc.com/Linux/2012-06/62289.htm>
复制代码
回复 支持 反对

使用道具 举报

该用户从未签到

3#
 楼主| 发表于 2019-11-8 10:41:30 | 只看该作者
nrpe插件安装:
参考http://blog.chinaunix.net/uid-24960107-id-461499.html
  1. ./configure --with-ssl=/usr/local/openssl/ --with-ssl-inc=/usr/local/openssl/include/ --with-ssl-lib=/usr/local/openssl/lib/ --with-kerberos-inc=/usr/ --with-log-facility=syslog --with-nagios-user=nagios --with-nagios-group=nagios --with-nrpe-user=nagios --with-nrpe-group=nagios --with-kerberos-inc=/usr/include/
复制代码


安装出现错误:
  1. checking for SSL headers... configure: error: Cannot find ssl headers
复制代码


需要安装openssl-devel:
  1. [root@localhost nagios]# rpm -ivh openssl-devel-1.0.1e-42.el6.x86_64.rpm
  2. error: Failed dependencies:
  3. krb5-devel is needed by openssl-devel-1.0.1e-42.el6.x86_64
  4. openssl = 1.0.1e-42.el6 is needed by openssl-devel-1.0.1e-42.el6.x86_64
复制代码


需要安装 krb5-devel:
  1. /usr/local/apache/bin/apachectl restart
复制代码

由于需要各种安装包,所以通过在本地虚拟机上安装缓存所有需要的包,然后copy到服务器上去安装(见:无网络yum安装-虚拟机上缓存后)

nagios配置:
  1. http://wenku.baidu.com/view/9ebef012a216147917112884.html
复制代码


php安装:
  1. ./configure  --prefix=/usr/local/php --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-mcrypt --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-apxs2=/usr/local/apache/bin/apxs
复制代码

以上信息中生成的mysql支持包为mysqlnd ,在nagios和cacti的结合中必须使用这个。
  1. make
  2. make install
  3. ./libtool --finish /software/nagios/php-5.6.14/libs  

  4. chmod 755 /usr/local/apache/modules/libphp5.so
复制代码


--nagiosgraph 安装:
  1. http://wenku.baidu.com/link?url=2UbKovDKhwCeXrSX3wY30t4JTOd-eoth13rU_sK-BFGW18B5UKLqf5E9RDzUEuIp2XjnD71HR2AHI-ngBknYEihf7_3VGWbbE4TwUe-CEuu
复制代码

需要perl GD 模块等:
  1. http://www.simpalace.net/itShow.asp?ID=16
复制代码

在安装过程各个模块后,还是无法通过 check-prereq
直接查找模块
  1. find / -name GD
复制代码

发现是已经有的,但是不在perl -V中列出的@INC目录下
处理方法:
  1. PERL5LIB=/usr/lib64/perl5
  2. export PERL5LIB
复制代码


重新做perl install.pl --check-prereq
缺Nagios:Config模块,下载Nagios-Objects 的模块进行安装,测试时发现还需要安装Test-Exception和Test-NoWarning,List_Comppare 3个模块。
全部下载安装后就可以了


在nagios页面上看到的是源代码,而不是网页内容
是因为 cgi文件没有被编译
修改httpd.conf
打开这个配置:
  1. Addhandler sctipt .cgi  
复制代码

增加:
  1. LoadModule cgi_module         modules/mod_cgi.so
复制代码

modules/mod_cgi.so 找不到,需要通过编译生成一个
  1. /usr/local/apache/bin/apxs -i -a -c mod_cgi.c
复制代码

至此解决问题。


以前没有用过php,这个安装过程真的是花了很长时间,遇到很多问题

回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-4-20 14:57 , Processed in 0.066836 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表