nagios安装
刚进入项目组时,项目比较还比较小,服务器不多,看到有一小伙子每天早上高峰时就用xshell打开各个服务器盯着看负载,看日志。可是以后用户逐步增多,服务器肯定也是越来越做,业务不断提出的要求,服务模块也会不断的增加。作为运维要求7*24小时总不能也这样去做。网上去搜了一下,nagios 比较合适。监控类的开源软件,觉得应该适用,于是就搭建了一个。后面也证明很实用。以下是参考了网上的一些博客,安装中也遇到了自己的问题,都整理了一下,为以后参考使用。参考 :http://blog.sina.com.cn/s/blog_6b9293150102wmbt.htmlhttp://imcn.me/html/y2013/16928.html创建nagios用户和用户组useradd -s /sbin/nologin nagiosmkdir /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios
把apache用户加入到nagios组,以便于在通过web操作nagios时能够具有足够的权限usermod -a -G nagios apache
编译安装nagios核心
tar zxf nagios-4.1.0rc1.tar.gz
cd nagios-4.1.0rc1
./configure
make all
make install
make install-init
make install-commandmode
make install-config
创建几个文件夹,后面会用到mkdir /etc/httpd
mkdir /etc/httpd/conf.d
mkdir /etc/httpd/conf.d/nagios.conf
make install-webconf #在httpd的配置文件目录conf.d中创建Nagios的Web程序配置文件发现没有安装appache,需要下载安装,见后面appache安装
创建一个登录nagios web程序的用户,这个用户帐号在以后通过web登录nagios认证时所用htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
appache安装 参考:
http://wenku.baidu.com/link?url=o_XnM_DkJUrctBLuem3Jwkk8lR43AM1i2oCAQqN4yoVY2Vu8Dfb0FY0bfoyCnZ1pOzxlRQoxFNeJvW6pfTPl7zKTutmN9JznaCvNOSrOtY3
./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
make &&make install报错:configure: error: APR not found.Please read the documentation.
需要安装几个依赖包,见安装APR安装APR: a:解决apr not found问题>>>>>>
<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.# 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.# cdapr-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.# ./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.# 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.# tar -zxf apr-util-1.3.12.tar.gz
2.# cd apr-util-1.3.12
3.# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
4.# make && make install
c:解决pcre问题>>>>>>>>>1.#unzip -o pcre-8.10.zip
2.#cd pcre-8.10
3.#./configure --prefix=/usr/local/pcre
4.#make && make install
4.最后编译Apache时加上:
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/ \
--with-pcre=/usr/local/pcre
成功编译完成~
来源:
<<a href="http://www.linuxidc.com/Linux/2012-06/62289.htm">http://www.linuxidc.com/Linux/2012-06/62289.htm> nrpe插件安装:
参考http://blog.chinaunix.net/uid-24960107-id-461499.html
./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/
安装出现错误:
checking for SSL headers... configure: error: Cannot find ssl headers
需要安装openssl-devel:
# rpm -ivh openssl-devel-1.0.1e-42.el6.x86_64.rpm
error: Failed dependencies:
krb5-devel is needed by openssl-devel-1.0.1e-42.el6.x86_64
openssl = 1.0.1e-42.el6 is needed by openssl-devel-1.0.1e-42.el6.x86_64
需要安装 krb5-devel:
/usr/local/apache/bin/apachectl restart
由于需要各种安装包,所以通过在本地虚拟机上安装缓存所有需要的包,然后copy到服务器上去安装(见:无网络yum安装-虚拟机上缓存后)
nagios配置:
http://wenku.baidu.com/view/9ebef012a216147917112884.html
php安装:
./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的结合中必须使用这个。
make
make install
./libtool --finish /software/nagios/php-5.6.14/libs
chmod 755 /usr/local/apache/modules/libphp5.so
--nagiosgraph 安装:
http://wenku.baidu.com/link?url=2UbKovDKhwCeXrSX3wY30t4JTOd-eoth13rU_sK-BFGW18B5UKLqf5E9RDzUEuIp2XjnD71HR2AHI-ngBknYEihf7_3VGWbbE4TwUe-CEuu
需要perl GD 模块等:
http://www.simpalace.net/itShow.asp?ID=16
在安装过程各个模块后,还是无法通过 check-prereq
直接查找模块
find / -name GD
发现是已经有的,但是不在perl -V中列出的@INC目录下
处理方法:
PERL5LIB=/usr/lib64/perl5
export PERL5LIB
重新做perl install.pl --check-prereq
缺Nagios:Config模块,下载Nagios-Objects 的模块进行安装,测试时发现还需要安装Test-Exception和Test-NoWarning,List_Comppare 3个模块。
全部下载安装后就可以了
在nagios页面上看到的是源代码,而不是网页内容
是因为 cgi文件没有被编译
修改httpd.conf
打开这个配置:
Addhandler sctipt .cgi
增加:
LoadModule cgi_module modules/mod_cgi.so
modules/mod_cgi.so 找不到,需要通过编译生成一个
/usr/local/apache/bin/apxs -i -a -c mod_cgi.c
至此解决问题。
以前没有用过php,这个安装过程真的是花了很长时间,遇到很多问题:dizzy:
页:
[1]