nagios的安装和配置(一)

1、安装编译基础支持包

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

yum install mysql mysql-server php httpd* mysql-devel

其中mysql安装出错可以采用以下方法安装:

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

rpm -ivh mysql57-community-release-el7-8.noarch.rpm

 yum -y install mysql-server

 

2、创建用户组

useradd nagios

groupadd nagiosgroup

usermod -G nagiosgroup nagios

 usermod -G nagiosgroup apache

3、下载nagios的源码

创建源码目录 mkdir nagios并进入该目录

wget http://nchc.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.5/nagios-4.0.5.tar.gz

 

4、下载nagios插件源码

wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz

 

5、编译nagios源码并安装

解压nagios的源码到/usr/src

tar -xf nagios-4.0.5.tar.gz -C /usr/src

cd /usr/src/nagios-4.0.5/

./configure --with-nagios-user=nagios --with-nagios-group=nagiosgroup --with-gd-lib=/usr/lib --with-gd-inc=/usr/include

make all

make install

make install-init

make install-config

make install-webconf

make install-exfoliation(make install-classicui)两种皮肤选择其一即可

 

6、编译安装插件

解压nagios插件的源码到/usr/src

tar -xf nagios-plugins-2.1.1.tar.gz -C /usr/src

cd /usr/src/nagios-plugins-2.1.1/

./configure --with-nagios-user=nagios --with-nagios-group=nagiosgroup --with-gd-lib=/usr/lib --with-gd-inc=/usr/include

make

make install

 

7、创建web页面用户

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

检查nagios的配置是否正确:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

 

8、启动nagios和http服务

systemctl restart nagios.service

systemctl restart httpd.service

 

9、访问测试页面

http://x.x.x.x/nagios

出现nagios主页面,成功(用户名nagiosadmin+密码)

 

posted @ 2019-01-20 16:38  大唐中郎将  阅读(270)  评论(0)    收藏  举报