CentOS 6.4安装Nagios 3.5.0

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。

一.安装环境的配置

1.关闭防火墙

为了防止因为防火墙的原因影响我们安装的环境,我们对防火墙进行关闭,如果在实际的生产环境中,我们是不建议关闭防火墙的。

[root@Nagios ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@Nagios ~]# chkconfig iptables off

2.关闭SELinux

如果未关闭SELinux,则可能在安装完成后,会出现Internal Server Error错误

编辑/etc/selinux/config

[root@Nagios ~]# 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/hosts

127.0.0.1  Nagios 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.安装必要的软件

[root@Nagios ~]# yum -y install wget make openssl openssl-devel httpd php gcc glibc \

> glibc-common gd gd-devel net-snmp mysql \

> mysql-server mysql-devel php-mysql perl perl-devel gnutls gnutls-devel

2.MySQL的配置(此步可省略)

虽然现在还并未使用MySQL,但是在以后的配置需要用到。

首先启动MySQL服务器

[root@Nagios ~]# service mysqld start
接着设置更改MySQL root账户的密码

[root@Nagios ~]# mysqladmin -u root password 123456

三.软件的安装

1.Nagios账户及组的添加

[root@Nagios ~]# useradd nagios
[root@Nagios ~]# groupadd nagcmd
[root@Nagios ~]# usermod -a -G nagcmd nagios
[root@Nagios ~]# usermod -a -G nagcmd apache


2.软件的下载

Nagios软件的下载
[root@Nagios ~]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.5.0.tar.gz
[root@Nagios ~]# wget 
http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz


3.Nagios软件的解压

[root@Nagios ~]# tar zxvf nagios-3.5.0.tar.gz

[root@Nagios ~]# tar zxvf nagios-plugins-1.4.16.tar.gz


4.Nagios的编译与安装

首先进入Nagios解压后所在的目录

[root@Nagios ~]# cd nagios
[root@Nagios nagios]# ./configure --with-command-group=nagcmd

[root@Nagios nagios]# make all

[root@Nagios nagios]# make install 

[root@Nagios nagios]# make  install-init

[root@Nagios nagios]# make  install-config

[root@Nagios nagios]# make  install-commandmode

[root@Nagios nagios]# make  install-webconf


[root@Nagios nagios]# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
[root@Nagios nagios]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers/

测试nagios的配置文件

[root@Nagios 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服务:

[root@Nagios nagios]# service nagios start
Starting nagios: done.

启动httpd服务:

[root@Nagios nagios]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                          [  OK  ]

添加访问WEB服务的账户及密码

[root@Nagios nagios]# 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解压目录

[root@Nagios nagios]# cd ../nagios-plugins-1.4.16
进行编译:

[root@Nagios 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


插件的安装


[root@Nagios nagios-plugins-1.4.16]# make

[root@Nagios nagios-plugins-1.4.16]# make install


最后将nagios及httpd加入启动项,并自动启动

[root@Nagios nagios-plugins-1.4.16]# chkconfig --add nagios
[root@Nagios nagios-plugins-1.4.16]# chkconfig --level 35 nagios on
[root@Nagios nagios-plugins-1.4.16]# chkconfig --add httpd
[root@Nagios nagios-plugins-1.4.16]# chkconfig --level 35 httpd on


本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1215237


相关文章
|
3天前
|
Linux 虚拟化 Windows
VMware隐藏黑科技!CentOS安装这个神器效率翻倍 文件互传竟比U盘还快?
### 安装VMtools的作用及步骤 安装VMtools可以实现Windows与CentOS之间的字符串和命令粘贴、文件夹共享等操作。在CentOS中,通过VMware菜单栏选择“VMware Tools”,将下载的压缩包拷贝到`/opt`目录并解压。接着进入终端,使用`./vmware-install.pl`命令完成安装。安装后重启系统,即可实现Windows与CentOS之间的字符和文件共享。具体步骤包括解压文件、启动命令行终端、安装VMtools以及配置文件共享。
34 16
VMware隐藏黑科技!CentOS安装这个神器效率翻倍 文件互传竟比U盘还快?
|
3天前
|
存储 IDE Linux
零基础保姆级教程!手把手教你免费玩转Linux CentOS安装+学习环境搭建(附避坑指南)
本文详细介绍了在VMware虚拟机中安装CentOS 6.8的全过程。首先,需确保已安装VMware并开启V-CPU虚拟化功能,可通过BIOS设置或使用LeoMoon CPU-V工具检测。接着,下载CentOS镜像文件,并在VMware中新建虚拟机,配置CPU、内存、硬盘等参数。最后,加载ISO镜像启动虚拟机,按照提示完成CentOS的安装,包括语言、键盘、存储方式、地区、密码设置及硬盘分区等步骤。安装完成后,以root用户登录即可进入系统桌面,开始学习Linux命令和操作。
39 12
零基础保姆级教程!手把手教你免费玩转Linux CentOS安装+学习环境搭建(附避坑指南)
|
16天前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
98 25
|
26天前
|
监控 Linux PHP
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
75 20
|
2月前
|
存储 分布式计算 Hadoop
Centos7.9安装kerberos
Centos7.9安装kerberos
93 25
|
2月前
|
存储 Shell 网络安全
Centos7.9安装openldap
Centos7.9安装openldap
62 16
|
2月前
|
数据可视化 Linux 应用服务中间件
Centos7.9安装phpldapadmin
Centos7.9安装phpldapadmin
71 15
|
2月前
|
网络协议 Java 应用服务中间件
centos7环境下tomcat8的安装与配置
本文介绍了在Linux环境下安装和配置Tomcat 8的详细步骤。首先,通过无网络条件下的文件交互软件(如Xftp 6或MobaXterm)下载并解压Tomcat安装包至指定路径,启动Tomcat服务并测试访问。接着,修改Tomcat端口号以避免冲突,并部署Java Web应用项目至Tomcat服务器。最后,调整Linux防火墙规则,确保外部可以正常访问部署的应用。关键步骤包括关闭或配置防火墙、添加必要的端口规则,确保Tomcat服务稳定运行。
|
4月前
|
SQL 存储 Linux
从配置源到数据库初始化一步步教你在CentOS 7.9上安装SQL Server 2019
【11月更文挑战第16天】本文介绍了在 CentOS 7.9 上安装 SQL Server 2019 的详细步骤,包括配置系统源、安装 SQL Server 2019 软件包以及数据库初始化,确保 SQL Server 正常运行。
194 4
|
5月前
|
Linux 网络安全 数据安全/隐私保护
Linux系统之Centos7安装cockpit图形管理界面
【10月更文挑战第12天】Linux系统之Centos7安装cockpit图形管理界面
204 1
Linux系统之Centos7安装cockpit图形管理界面

热门文章

最新文章