Nagiosserver端安装部署具体解释(1)

下载地址例如以下: http://sourceforge.net/projects/nagios/files/

具体具体下载地址:http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.6.tar.gz

1 開始下载:
 wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.0.6/nagios-4.0.6.tar.gz/download?use_mirror=jaist
例如以下图所看到的,下载free版本号的。
?

安装前准备工作,安装一些lib包:

[[email protected] root]# yum -y install httpd gcc glibc glibc-common

# yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel

2 进行selinux设置,或者关闭selinux

查看SELinux状态:

(1)/usr/sbin/sestatus -v      ##假设SELinux status參数为enabled即为开启状态

SELinux status:                 enabled

(2)getenforce                 ##也能够用这个命令检查

关闭SELinux:

(3)暂时关闭(不用重新启动机器):

setenforce 0                  ##设置SELinux 成为permissive模式

##setenforce 1 设置SELinux 成为enforcing模式

(4)改动配置文件须要重新启动机器:

改动/etc/selinux/config 文件

将SELINUX=enforcing改为SELINUX=disabled

重新启动机器就可以

3 開始准备nagios安装环境

(1) 加入?nagios运行所须要的用户和组:

groupadd nagcmd

useradd -m nagios

usermod -a -G nagcmd nagios

把apache加入到nagcmd组,以便于在通过web Interface操作nagios时能够具有足够的权限:

# usermod -a -G nagcmd apache

4 编译安装准备

./configure --with-command-group=nagios --prefix=/opt/app/nagios --enable-embedded-perl --with-httpd-conf=/usr/local/apache2/conf

[[email protected] nagios-4.0.6]# ./configure --with-command-group=nagios  --prefix=/opt/app/nagios --enable-embedded-perl  --with-httpd-conf=/usr/local/apache2/conf
checking for a BSD-compatible install... /usr/bin/install -c
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
.............................
 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):  /bin/traceroute

Review the options above for accuracy.  If they look okay,
type ‘make all‘ to compile the main program and CGIs.

5 開始make安装
5.1 make all

[[email protected] nagios-4.0.6]#  make all

cd ./base && make
make[1]: Entering directory `/root/nagios-4.0.6/base‘
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nagios.o nagios.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE   -c -o broker.o broker.c
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE   -c -o nebmods.o nebmods
.........................
For more information on obtaining support for Nagios, visit:

       http://support.nagios.com

*************************************************************

Enjoy.

5.2 make install
[[email protected] nagios-4.0.6]# make install

cd ./base && make install
make[1]: Entering directory `/root/nagios-4.0.6/base‘
make install-basic
make[2]: Entering directory `/root/nagios-4.0.6/base‘
.....................................................
make[2]: Entering directory `/root/nagios-4.0.6/cgi‘
for file in *.cgi; do 		/usr/bin/strip /usr/local/nagios/sbin/$file; 	done

5.3 make install-config

[[email protected] nagios-4.0.6]# make install-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
....................................................
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg

*** Config files installed ***

5.4 make install-commandmode

[[email protected] nagios-4.0.6]# make install-commandmode
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw

*** External command directory configured ***

Remember, these are *SAMPLE* config files.  You‘ll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.


5.5 make install-init

[[email protected] nagios-4.0.6]# make install-init
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios

*** Init script installed ***

[[email protected] nagios-4.0.6]#

加到启动项里面去:

# chkconfig --add nagios

# chkconfig --level 35 nagios on

# chkconfig --list nagios

检查主机配置文件是否正确:

/var/www/nagios/bin/nagios -v /var/www/nagios/etc/nagios.cfg

5.6 Check安装是否正确:

5.6.1说明:

切换文件夹到安装路径(这里是/usr/local/nagios),看是否存在etc、bin、sbin、share、var 这五个文件夹,假设存在则能够表明程序被正确的安装到系统了。Nagios 各个文件夹用途说明例如以下:

bin    Nagios 可运行程序所在文件夹

etc   Nagios 配置文件所在文件夹

sbin  Nagios CGI 文件所在文件夹,也就是运行外部命令所需文件所在的文件夹

share        Nagios网页文件所在的文件夹

libexec      Nagios 外部插件所在文件夹

var   Nagios 日志文件、lock 等文件所在的文件夹

var/archives     Nagios 日志自己主动归档文件夹

var/rw      用来存放外部命令文件的文件夹

5.6.2 check
 cd /usr/local/nagios
ll

[[email protected] nagios-4.0.6]# cd /usr/local/nagios
[[email protected] nagios]# ll
总用量 24
drwxrwxr-x.  2 nagios nagios 4096 5月   5 15:31 bin
drwxrwxr-x.  3 nagios nagios 4096 5月   5 15:32 etc
drwxrwxr-x.  2 nagios nagios 4096 5月   5 15:31 libexec
drwxrwxr-x.  2 nagios nagios 4096 5月   5 15:31 sbin
drwxrwxr-x. 10 nagios nagios 4096 5月   5 15:31 share
drwxrwxr-x.  5 nagios nagios 4096 5月   5 15:32 var

5.7 安装nagios插件
wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz

[[email protected] ~]# wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
--2014-05-05 15:52:52--  http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
正在解析主机 nagios-plugins.org... 72.14.186.43
正在连接 nagios-plugins.org|72.14.186.43|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
............................................
2014-05-05 15:53:00 (373 KB/s) - 已保存 “nagios-plugins-2.0.tar.gz” [2501847/2501847])

[[email protected] ~]# tar -xvf nagios-plugins-2.0.tar.gz
[[email protected] ~]# cd nagios-plugins-2.0
[[email protected] ~]#./configure --with-nagios-user=nagios --with-nagios-group=nagios  --prefix=/usr/local/nagios --with-mysql
[[email protected] ~]# make && make install

5.8 安装配置apache和php
(1)安装apache
下载 wget http://archive.apache.org/dist/httpd/httpd-2.4.7.tar.gz

[[email protected] ~]# wget http://archive.apache.org/dist/httpd/httpd-2.4.7.tar.gz
--2014-05-05 16:15:48--  http://archive.apache.org/dist/httpd/httpd-2.4.7.tar.gz
正在解析主机 archive.apache.org... 192.87.106.229, 140.211.11.131, 2001:610:1:80bc:192:87:106:229
正在连接 archive.apache.org|192.87.106.229|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:6747087 (6.4M) [application/x-gzip]
正在保存至: “httpd-2.4.7.tar.gz”

 1% [=>                                                ..............................................................
2014-05-05 16:16:01 (574 KB/s) - 已保存 “httpd-2.4.7.tar.gz” [6747087/6747087])

開始安装:
 tar -xvf httpd-2.4.7.tar.gz
 cd httpd-2.4.7
 ./configure --prefix=/usr/local/apache2
make && make install

[[email protected] ~]# tar -xvf httpd-2.4.7.tar.gz
[[email protected] ~]# cd httpd-2.4.7
[[email protected] httpd-2.4.7]# ./configure --prefix=/usr/local/apache2
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found.  Please read the documentation.
Google之后,发现可能是gcc版本号太低了,可能是apache版本号太高,换低点的2.2.23版本号吧。
wget http://archive.apache.org/dist/httpd/httpd-2.2.23.tar.gz
tar -xvf  httpd-2.2.23.tar.gz
cd httpd-2.2.23
./configure --prefix=/usr/local/apache2
make && make install

(2) 安装php版本号

wget http://cn2.php.net/distributions/php-5.4.26.tar.gz

tar -xvf php-5.4.26.tar.gz

cd php-5.4.26

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs

有报错信息:

Configuring extensions

checking size of long... (cached) 8

checking size of int... (cached) 4

checking for int32_t... yes

checking for uint32_t... yes

checking for sys/types.h... (cached) yes

checking for inttypes.h... (cached) yes

checking for stdint.h... (cached) yes

checking for string.h... (cached) yes

checking for stdlib.h... (cached) yes

checking for strtoll... yes

checking for atoll... yes

checking for strftime... (cached) yes

checking which regex library to use... php

checking whether to enable LIBXML support... yes

checking libxml2 install dir... no

checking for xml2-config path...

configure: error: xml2-config not found. Please check your libxml2 installation.

须要又一次安装lib包

yum install libxml2 –y

yum install libxml2-devel –y

之后继续make,成功了:

Make && make install

[activating module `php5‘ in /usr/local/apache2/conf/httpd.conf]

Installing PHP CLI binary:        /usr/local/php/bin/

Installing PHP CLI man page:      /usr/local/php/php/man/man1/

Installing PHP CGI binary:        /usr/local/php/bin/

Installing PHP CGI man page:      /usr/local/php/php/man/man1/

Installing build environment:     /usr/local/php/lib/php/build/

Installing header files:          /usr/local/php/include/php/

Installing helper programs:       /usr/local/php/bin/

program: phpize

program: php-config

Installing man pages:             /usr/local/php/php/man/man1/

page: phpize.1

page: php-config.1

Installing PEAR environment:      /usr/local/php/lib/php/

[PEAR] Archive_Tar    - installed: 1.3.11

[PEAR] Console_Getopt - installed: 1.3.1

warning: pear/PEAR requires package "pear/Structures_Graph" (recommended version 1.0.4)

warning: pear/PEAR requires package "pear/XML_Util" (recommended version 1.2.1)

[PEAR] PEAR           - installed: 1.9.4

Wrote PEAR system config file at: /usr/local/php/etc/pear.conf

You may want to add: /usr/local/php/lib/php to your php.ini include_path

[PEAR] Structures_Graph- installed: 1.0.4

[PEAR] XML_Util       - installed: 1.2.1

/root/php/php-5.4.26/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin

ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar

Installing PDO headers:          /usr/local/php/include/php/ext/pdo/

(3) 配置apache

Apache的配置文件在 /usr/local/apache2/conf/httpd.conf ,vim打开

User daemon

Group daemon

改动成:

User nagios

Group nagios

<IfModule dir_module>

  DirectoryIndex index.html

</IfModule>

改动成:

<IfModule dir_module>

  DirectoryIndex index.html index.php

AddType application/x-httpd-php .php

</IfModule>

为了安全起见:nagios的web监控页面须要经过授权才干訪问,这须要添加?验证配置,即在httpd.conf 文件最后加入?例如以下信息:

#setting for nagios

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

<Directory "/usr/local/nagios/sbin">

AuthType Basic

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName "Nagios Access"

AuthUserFile /usr/local/nagios/etc/htpasswd  //用于此文件夹訪问身份验证的文件

Require valid-user

</Directory>

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">

AuthType Basic

Options None

AllowOverride None

Order allow,deny

Allow from all

AuthName "nagios Access"

AuthUserFile /usr/local/nagios/etc/htpasswd

Require valid-user

</Directory>

(4) 创建apache文件夹验证文件

在上面的配置中,指定了文件夹验证文件htpasswd,以下要创建这个文件:

/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd david

[[email protected] php-5.4.26]#  /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd david

New password:

Re-type new password:

Adding password for user david

查看认证文件的内容:

[[email protected] php-5.4.26]#  cat /usr/local/nagios/etc/htpasswd

david:$apr1$Pf9XIJjd$m5hR2vw70MlqwrChgN7zc/

[[email protected] php-5.4.26]#

启动apache服务:

/usr/local/apache2/bin/apachectl start

[[email protected] php-5.4.26]# /usr/local/apache2/bin/apachectl start

httpd: Could not reliably determine the server‘s fully qualified domain name, using 10.254.3.41 for ServerName

(98)Address already in use: make_sock: could not bind to address [::]:80

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

no listening sockets available, shutting down

Unable to open logs

改动ServerName以及Port

vi /usr/local/apache2/conf/httpd.conf

ServerName 改成 10.xx.3.x1

Listen 80 改成 Listen 81

http://10.xx.3.x1:81/nagios/,能够打开了,例如以下所看到的:

Nagiosserver端安装部署具体解释(1),布布扣,bubuko.com

时间: 2024-10-10 21:46:42

Nagiosserver端安装部署具体解释(1)的相关文章

zabbix 3.2.7 (源码包)安装部署

Zabbix 3.2.7 + CentOS7 安装 环境准备: 操作系统 CentOS Linux release 7.2.1511 (Core) zabbix server 10.30.94.60 zabbix agent 10.25.198.179 一.zabbix server 端安装部署 1.快速部署lamp环境: yum -y install httpd httpd-devel mariadb* php php-mysql php-common php-gd php-mbstring 

java自动化测试成长日记-之CVS客户端和服务端安装和部署1:CVS服务端的配置和基本使用

CVS服务端的配置和基本使用 在做java自动化测试集成环境搭建的时候,无论怎样,你都会选择一个源代码管理工具,如:SVN,CVS,VSS等:但如果你使用Eclipse工具,建议你使用CVS源代码管理工具,因为它本身就自带了CVS客户端插件,可以直接使用(具体使用情况,可参考:java自动化测试成长日记-之CVS客户端和服务端安装和部署2:CVS客户端的配置和基本使用章节): 首先,你需要下载:cvsnt-2.5.03.2151安装包.msi,服务端安装软件(可在百度里面搜索找到,相应的资源).

zabbix3.0安装部署文档

zabbix v3.0安装部署 摘要: 本文的安装过程摘自http://www.ttlsa.com/以及http://b.lifec-inc.com ,和站长凉白开的<ZABBIX从入门到精通v3.0.1 - 运维生存时间(2016)>一书. 关于zabbix及相关服务软件版本: Linux:centos 6.6 nginx:1.9.15 MySQL:5.5.49 PHP:5.5.35 一.安装nginx: 安装依赖包: yum -y install gcc gcc-c++ autoconf

淘宝分布式 key/value 存储引擎Tair安装部署过程及Javaclient測试一例

文件夹 1. 简单介绍 2. 安装步骤及问题小记 3. 部署配置 4. Javaclient測试 5. 參考资料 声明 1. 以下的安装部署基于Linux系统环境:centos 6(64位),其他Linux版本号可能有所差异. 2. 网上有人说tair安装失败可能是由于gcc版本号问题,高版本号的gcc可能不支持某些特性导致安装失败.经过实验证明.该说法是错误的,tair安装失败有各种可能的原因但绝对与gcc版本号无关,比方我的gcc開始版本号为4.4.7,后来tair安装失败,我又一次编译低版

zabbix v3.0安装部署

zabbix v3.0安装部署 摘要: 本文的安装过程摘自http://www.ttlsa.com/以及http://b.lifec-inc.com ,和站长凉白开的<ZABBIX从入门到精通v3.0.1 - 运维生存时间(2016)>一书. 关于zabbix及相关服务软件版本: Linux:centos 6.6 nginx:1.9.15 MySQL:5.5.49 PHP:5.5.35 一.安装nginx: 安装依赖包: yum -y install gcc gcc-c++ autoconf

redis概念及安装部署

第1章 Redis介绍 1.1 Redis是什么 Redis是一种基于键值对的NoSQL数据库,与很多键值对数据库不同,redis中的值可以有string,hash,list,set,zset,geo等多种数据结构和算法组成. 因为Redis会将所有的数据都放在内存中,所以他的读写性能非常惊人. 不仅如此,Redis还可以将内存中的数据利用快照和日志的形式保存到硬盘上 Redis还提供了键过期,发布订阅,事务,流水线等附加功能. 1.2 Redis重要特性 1.速度快 Redis所有的数据都存放

CronHub 的安装部署

一.基础环境 IP:10.29.181.32 # mkdir -p /opt/software/tools # ls /opt/software/tools apache-ant-1.9.9-bin.tar.bz2   jdk-8u51-linux-x64.tar.gz apache-tomcat-8.0.24.tar.gz   master.zip 二.安装MYSQL (1)可以使用yum进行安装 # yum -y install mysql-server # yum -y install p

Sqlserver2008安装部署文档

Sqlserver2008部署文档 注意事项: 如果你要安装的是64位的服务器,并且是新机器.那么请注意,你需要首先需要给64系统安装一个.net framework,如果已经安装此功能,请略过这一步.   具体安装.net framework的方法是:在图标<我的电脑>上右击选择<管理>,打开以后选择<功能>选项卡,如下图所示,然后点击添加功能,勾选..net framework,然后一直点击下一步安装即可. 安装的过程中,需要注意如果你要安装的服务器有外挂或者附加的

虚拟化Vmware之安装部署vCenter

vCenter是vSphere解决方案的基础物理架构核心,可以提供如访问控制.性能监控和配置功能等,并且可以将多台ESXi主机资源集中,使这些资源在整个数据中心的虚拟机之间共享.vCenter是一种服务,充当连接网络的ESXi主机的中心管理员. 安装部署vCenterer 一.实验环境 自己的真实机当作客户机 1.首先将DC/DNS(benet.com)服务器的防火墙关闭 2.真实机和虚拟机都设在同一网段 DNS指向DNS服务器. 安装高版本的flash 二.配置sql server    我在