Centos 5.6平台下安装Nagios监控平台

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:
  最近需要对公司内的所有服务器进行监控,当然现在有很多软件可以进行这个功能的实现,比如说微软的SCOM,还有就是今天的Nagios软件了,但是前者还好说Windows 平台下的产品,还是比较好配置和安装的,但是如果我们要安装Nagios的话,就可能会有一小些不好搞,因为这个东东是装在Linux平台上的,昨天晚上没怎么睡,搞了搞怎么去装,今天呢把相关的安装方法呢发上来,分享一下,供博友们参考参考。
          首先我们来看看,什么是Nagios?,Nagios是一款用来监视系统和网络的开源监控软件,它一般被运行于一个主服务器上,这个服务器运行 Liunx 或 Unix 操作系统。Nagios 可以通过强大的插件功能来实现对本机和远端服务的监控,当被监控对象出现异常,Nagios 就会及时给管理人员告警。这个功能不错哦,呵呵,再者说它其实也可以看成是一个基于TCP/IP协议的软件包,包含有nagios主程序和它的各个插件,配置非常灵活,可以监视的项目很多,也可以通过自定义一些shell 脚本进行监控服务,非常适合各类企业的网络和系统平台服务监控的应用。
         听起来Nagios功能非常强大,它可以监控服务和主机,但是其实他自身并不包括这部分功能的代码,所有的监控、检测功能都是有插件来完成的。比如说报警功能,如果监控系统发现问题不能报警那就没有意义了,所以报警也是nagios很重要的功能之一。但是,同样的,nagios自身也没有报警部分的代码,甚至没有插件这部分,我们也只能是找一些相关插件来搞定了,这里我们介绍的只是nagios安装,是指基本平台,也就是nagios软件包的安装。它是监控体系的框架,也是所有监控的基础,后期我也会根据配置的进度不定期地把后边的东东也发上来补充给大家,一同学习,一同进步。
        接下来,我们就一起来看看如何在Linux平台上安Nagios这个东东吧,在这里,我个人认为Centos还是比较不错的平台,如果大家要去安装的话Centos这个是不错的选择哦,而且大家还可以通过在Linux命令行下运行yum Update来实现系统的升级,我个人感觉相关方便好用。好了,接下来我们言归正传吧,谈谈怎么安装:
1) 安装apache,并设置开机启动
? 安装Apache程序
[root@localhost nagios-3.2.3]# yum install httpd
Total download size:1.6M
IS this OK[Y/N]Y
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) <centos-5-key@centos.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 Is this ok [y/N]Y
安装成功后将显示如下图所示内容:
image
[root@localhost nagios-3.2.3]# chkconfig --levels 35 httpd on
[root@localhost nagios-3.2.3]# service httpd start
启动 httpd:[确定]
2) 安装配置PHP
  •  安装PHP程序
[root@localhost nagios-3.2.3]# yum install php
Total download size: 4.9 M
Is this ok [y/N]: y
安装完成后显示下图所示内容
image
3)安装mysql,并设置mysql开机自启动,同时启动mysql
  •  安装Mysql
[root@localhost ~]# yum install mysql
Total download size: 10 M
Is this ok [y/N]: Y
安装成功后,将显示下图所示内容
image
[root@localhost ~]# yum install mysql-server
Total download size: 10 M
Is this ok [y/N]Y
[root@localhost ~]# chkconfig --levels 35 mysqld on
[root@localhost ~]# service mysqld start
  • 配置MySql的root密码
[root@localhost ~]# mysql_secure_installation
Enter current password for root (enter for none): ( 回车)
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password: (这里输入密码,注意输入内容是不会显示出来的哦)
Re-enter new password: (这里再次输入密码,注意输入内容是不会显示出来的哦)
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n]Y
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely(是否禁止root的远程登录)? [Y/n]:Y
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n] Y
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
4)Nagions安装
  • 下载Nagions-3.2.3安装包
? 解压Nagions-3.2.3安装包
[root@localhost ~]# tar -zxvf nagios-3.2.3.tar.gz
? 安装GCC
注意:不装这个,后边的make all就没办法执行了,会报错的哦~
[root@localhost ~]# cd nagios-3.2.3
[root@localhost ~]# yum instll gcc
[root@localhost ~]# ./configure --prefix=/usr/local/nagios
[root@localhost nagios-3.2.3]# ./configure
  • 为nagions增加用户,此步必需做,否则无法mak all编译
[root@localhost nagios-3.2.3]# useradd nagios
[root@localhost nagios-3.2.3]# mkdir /usr/local/nagios
[root@localhost nagios-3.2.3]# chown nagios.nagios /usr/local/nagios
[root@localhost nagios-3.2.3]# make all
[root@localhost nagios-3.2.3]# make install; make install-init;make install-commandmode;make install-config;make install-webconf
  • 验证程序是否被正确安装
[root@localhost nagios-3.2.3]# cd ~
[root@localhost ~]# cd /usr/local/nagios
[root@localhost nagios]# ls
bin etc libexec sbin share var
如果有上述6个文件,说明就是安装成功了
  • 修改nagios页面文件
[root@localhost nagios]# more /etc/httpd/conf.d/nagios.conf
[root@localhost nagios]# cp /etc/httpd/conf.d/nagios.conf /var/www/html/
  • 生成nagios页面访问账号
[root@localhost nagios]# touch /usr/local/nagios/etc/htpasswd.users
[root@localhost nagios]# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users root
New password: (这里输入密码,注意输入内容是不会显示出来的哦)
Re-type new password:(这里再次输入密码,注意输入内容是不会显示出来的哦)
[root@localhost nagios]# cat /usr/local/nagios/etc/htpasswd.users
root:TTiPq0FKlL0iw
  • 修改nagios主配置文件
[root@localhost nagios]# vi /usr/local/nagios/etc/nagios.cfg

输完上边的命令后,将会出现一个编辑区域,你可以移动方向键到你想要添加的位置,按下字母I键进行编辑,编辑完成后,按ESC键,现按下右shift+;键,在出来的输入点处,输入WQ键,回车即可,如果你改错了,想不保存想重新进入编辑,也好办,只需要在输入点处,输入Q!回车,就退出来了,要是什么都没做要退出的话,只要在输入点处,输入Q键即可退出,好了,在下边的内容后换行增加对应的信息。
command_check_interval=15s
#command_check_interval=-1
[root@localhost nagios]# touch /usr/local/nagios/var/nagios.log
[root@localhost nagios]# chown nagios.nagios /usr/local/nagios/var/nagios.log
  • 测试nagios是否成功
[root@localhost nagios]# chkconfig nagios on
[root@localhost nagios]# service nagios start
[root@localhost nagios]# service httpd restart
  • 测试nagios是否成功启动
在IE输入 http:// 这里输入承担Nagios服务的Linux服务器IP地址/nagios/ ,在弹出的对话框中,输入“生成nagios页面访问账号”里新建的寻附上帐号及密码,如果输入密码正确的话就进入了Nagios的Web页面了。
image
总得来说,通过装Nagios学习了Linux下的命令,收获很大,嘻嘻~,分享一下。



本文转自wangtingdong 51CTO博客,原文链接:http://blog.51cto.com/tingdongwang/699279,如需转载请自行联系原作者
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
Linux 网络安全 数据安全/隐私保护
如何在 VM 虚拟机中安装 CentOS Linux 9 操作系统保姆级教程(附链接)
如何在 VM 虚拟机中安装 CentOS Linux 9 操作系统保姆级教程(附链接)
170 0
|
2月前
|
关系型数据库 MySQL Linux
centos7.0环境下安装MySql_8.0.12
centos7.0环境下安装MySql_8.0.12
|
1月前
|
存储 JavaScript Linux
Linux环境下安装nmp(Centos环境)保姆级教学 一步到位
Linux环境下安装nmp(Centos环境)保姆级教学 一步到位
|
3天前
|
Linux
centos 6.5安装yum
centos 6.5安装yum
22 0
|
3天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置PXE服务
PXE是Intel开发的预启动执行环境,允许工作站通过网络从远程服务器启动操作系统。它依赖DHCP分配IP,DNS服务分配主机名,TFTP提供引导程序,HTTP/FTP/NFS提供安装源。要部署PXE服务器,需关闭selinux和防火墙,安装dhcpd、httpd、tftp、xinetd及相关服务,配置引导文件和Centos7安装源。最后,通过syslinux安装引导文件,并创建pxelinux.cfg/default配置文件来定义启动参数。
15 0
|
3天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置postfix服务
安装CentOS7的Postfix和Dovecot,配置Postfix的`main.cf`文件,包括修改完全域名、允许所有IP、启用邮箱等。然后,配置Dovecot的多个配置文件以启用auth服务和调整相关设置。重启Postfix和Dovecot,设置开机自启,并关闭防火墙进行测试。最后,创建邮箱账户并在Windows邮箱客户端中添加账户设置。
10 0
|
3天前
|
Linux 网络安全
Centos6.5安装并配置NFS服务
该内容描述了在Linux系统中设置NFS服务的步骤。首先挂载yum源,然后安装NFS服务,并编辑配置文件。接着,重启rpcbind和NFS服务,可能需要重复此过程以解决初始可能出现的问题。此外,关闭防火墙策略,并再次重启服务。最终,根目录被共享,特定IP网段被允许访问。
9 0
|
4天前
|
存储 Linux 网络安全
centos7使用yum网络安装
这些是使用Yum进行网络安装的基本步骤。根据你的需求,你可以重复步骤3和4来安装其他软件包。请注意,执行Yum操作需要root或具有sudo权限的用户。
16 1
|
10天前
|
关系型数据库 MySQL Linux
centos7安装mysql-带网盘安装包
centos7安装mysql-带网盘安装包
60 2
|
17天前
|
存储 Linux Shell
centos 部署docker容器 安装 、基本使用方法(一)
centos 部署docker容器 安装 、基本使用方法(一)
32 0

热门文章

最新文章