设为首页 收藏本站
查看: 2953|回复: 0

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

[复制链接]

尚未签到

发表于 2019-1-16 10:04:21 | 显示全部楼层 |阅读模式
           最近需要对公司内的所有服务器进行监控,当然现在有很多软件可以进行这个功能的实现,比如说微软的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) " from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 Is this ok [y/N]Y
  安装成功后将显示如下图所示内容:
  
  [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
  安装完成后显示下图所示内容
  
  3)安装mysql,并设置mysql开机自启动,同时启动mysql
  

  • 安装Mysql
  [root@localhost ~]# yum install mysql
  Total download size: 10 M
  Is this ok [y/N]: Y
  安装成功后,将显示下图所示内容
  
  [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安装包
  [root@localhost ~]# wget http://ncu.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.2.3/nagios-3.2.3.tar.gz
  ? 解压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页面了。
  
  总得来说,通过装Nagios学习了Linux下的命令,收获很大,嘻嘻~,分享一下。




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-663880-1-1.html 上篇帖子: nagios监控配置详解五主机群 下篇帖子: nagios服务端配置及客户的安装配置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表