Centos 5.6平台下安装Nagios监控平台
最近需要对公司内的所有服务器进行监控,当然现在有很多软件可以进行这个功能的实现,比如说微软的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程序
# yum install httpd
Total download size:1.6M
IS this OK: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
安装成功后将显示如下图所示内容:
http://tingdongwang.blog.运维网.com/attachment/201110/27/1056852_1319714894byB8.png
# chkconfig --levels 35 httpd on
# service httpd start
启动 httpd:[确定]
2) 安装配置PHP
[*] 安装PHP程序
# yum install php
Total download size: 4.9 M
Is this ok : y
安装完成后显示下图所示内容
http://tingdongwang.blog.运维网.com/attachment/201110/27/1056852_13197148949nhy.png
3)安装mysql,并设置mysql开机自启动,同时启动mysql
[*] 安装Mysql
# yum install mysql
Total download size: 10 M
Is this ok : Y
安装成功后,将显示下图所示内容
http://tingdongwang.blog.运维网.com/attachment/201110/27/1056852_1319714895PAvz.png
# yum install mysql-server
Total download size: 10 M
Is this ok :Y
# chkconfig --levels 35 mysqld on
# service mysqld start
[*]配置MySql的root密码
# 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
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
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
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
Reload privilege tables now? :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安装包
# 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安装包
# tar -zxvf nagios-3.2.3.tar.gz
? 安装GCC
注意:不装这个,后边的make all就没办法执行了,会报错的哦~
# cd nagios-3.2.3
# yum instll gcc
# ./configure --prefix=/usr/local/nagios
# ./configure
[*]为nagions增加用户,此步必需做,否则无法mak all编译
# useradd nagios
# mkdir /usr/local/nagios
# chown nagios.nagios /usr/local/nagios
# make all
# make install; make install-init;make install-commandmode;make install-config;make install-webconf
[*]验证程序是否被正确安装
# cd ~
# cd /usr/local/nagios
# ls
bin etc libexec sbin share var
如果有上述6个文件,说明就是安装成功了
[*]修改nagios页面文件
# more /etc/httpd/conf.d/nagios.conf
# cp /etc/httpd/conf.d/nagios.conf /var/www/html/
[*]生成nagios页面访问账号
# touch /usr/local/nagios/etc/htpasswd.users
# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users root
New password: (这里输入密码,注意输入内容是不会显示出来的哦)
Re-type new password:(这里再次输入密码,注意输入内容是不会显示出来的哦)
# cat /usr/local/nagios/etc/htpasswd.users
root:TTiPq0FKlL0iw
[*]修改nagios主配置文件
# vi /usr/local/nagios/etc/nagios.cfg
输完上边的命令后,将会出现一个编辑区域,你可以移动方向键到你想要添加的位置,按下字母I键进行编辑,编辑完成后,按ESC键,现按下右shift+;键,在出来的输入点处,输入WQ键,回车即可,如果你改错了,想不保存想重新进入编辑,也好办,只需要在输入点处,输入Q!回车,就退出来了,要是什么都没做要退出的话,只要在输入点处,输入Q键即可退出,好了,在下边的内容后换行增加对应的信息。
command_check_interval=15s
#command_check_interval=-1
# touch /usr/local/nagios/var/nagios.log
# chown nagios.nagios /usr/local/nagios/var/nagios.log
[*]测试nagios是否成功
# chkconfig nagios on
# service nagios start
# service httpd restart
[*]测试nagios是否成功启动
在IE输入 http:// 这里输入承担Nagios服务的Linux服务器IP地址/nagios/ ,在弹出的对话框中,输入“生成nagios页面访问账号”里新建的寻附上帐号及密码,如果输入密码正确的话就进入了Nagios的Web页面了。
http://tingdongwang.blog.运维网.com/attachment/201110/27/1056852_1319714895Msp4.png
总得来说,通过装Nagios学习了Linux下的命令,收获很大,嘻嘻~,分享一下。
页:
[1]