Chinaunix首页 | 论坛 | 博客
  • 博客访问: 206516
  • 博文数量: 60
  • 博客积分: 2142
  • 博客等级: 大尉
  • 技术积分: 560
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-13 00:08
文章分类

全部博文(60)

文章存档

2010年(2)

2009年(7)

2008年(30)

2007年(21)

我的朋友

分类: 服务器与存储

2008-07-02 15:51:13

中小型企业LVS负载均衡服务器监控 ---ganglia
作者:管志成
E-mail:guancheng1987@hotmail.com
unix/Linux系统工程师

集群监控软件ganglia

Ganglia监控软件主要是用来监控系统性能的软件,如:cpu 、mem、硬盘利用率, I/O负载、网络流量情况等,通过曲线很容易见到每个节点的工作状态,对合理调整、分配系统资源,提高系统整体性能起到重要作用。支持浏览器方式访问,但 不能监控节点硬件技术指标ganglia 是分布式的监控系统,有两个服务端:Daemon, 分别是:客户端。C/S架构。
和服务端Ganglia Meta Daemon (gmetad),还有Ganglia PHP Web Frontend(基于web的动态访问方式)组成。是一个Linux下图形化监控系统运行性能的软件,界面美观、丰富,功能强大。RRDtool是系统 存放和显示time-series (即网络带宽、温度、人数、服务器负载等) 。并且它提出有用的图表由处理数据强制执行有些数据密度。下载地址

A. 安装RRDTool
gmetad需要先安装RRDTool,默认的安装路径:/usr/local/rrdtool-1.2.18
[root@localhost ~]#tar rrdtool-1.2.18.tar.gz
[root@localhost ~]#cd rrdtool-1.2.18
[root@localhost rrdtool-1.2.18]#./configure –prefix=/usr
[root@localhost rrdtool-1.2.18]#make
[root@localhost rrdtool-1.2.18]#make install
会产生2个文件rrd.h in,librrd.a
rrd.h in /usr/local/rrdtool/include/rrd.h
librrd.a in /usr/local/rrdtool/lib/librrd.a
[root@localhost rrdtool-1.2.18]#./usr/local/rrdtool/bin/rrdtool #运行rrdtool测试一下,如提示找不到
librrd.so.2,rrdtool不能运行,请将librrd.so.2文件拷贝到/usr/lib/,再运行rrdtool测试一下。
B. gmetad的安装
[root@localhost ~]#tar –zxvf ganglia-3.0.4.tar.gz
[root@localhost ~]#cd ganglia-3.0.4
[root@localhost ganglia-3.0.4]#./configure --with-gmetad --enable-gexec
[root@localhost ganglia-3.0.4]#make
[root@localhost ganglia-3.0.4]#make install
a.为了保证在开始时启动,需要将gmetad.init文件拷贝到 /etc/rc.d/init.d/
[root@localhost ganglia-3.0.4]# cd ganglia-3.0.4/gmetad
[root@localhost ganglia-3.0.4]# cp gmetad.init /etc/rc.d/init.d/gmetad
将配置文件拷贝到/etc目录下
[root@localhost ganglia-3.0.4]# cp gmetad.conf /etc/gmetad.conf
b.Add GMETAD to the list of programs at startup
[root@localhost ganglia-3.0.4]# chkconfig --add gmetad
[root@localhost ganglia-3.0.4]# chkconfig --list gmetad
GMETAD 0:off 1:off 2:on 3:on 4:on 5:on 6:off
建立rrds目录并修改权限(需与gmetad.conf中的数据存放路径保持一致,这里采用gmetad默认的存放路径)
[root@localhost ganglia-3.0.4]# mkdir -p /var/lib/ganglia/rrds
[root@localhost ganglia-3.0.4]#chown –R nobody /var/lib/ganglia/rrds

C.启动gmetad
[root@localhost ganglia-3.0.4]#/etc/rc.d/init.d/gmetad start
Starting GANGLIA gmetad: [ OK ]
D.[root@localhost ganglia-3.0.4]#netstat -an | grep “8651”
tcp 0 0 0.0.0.0:8651 0.0.0.0:* LISTEN
就可以得到监控的各个主机的状态。

gmetad.conf的配置
# data_source "another source" 1.3.4.7:8651 1.3.4.8
data_source "SERVER" 10 node1:端口号 node2:端口号
data_source是最重要的参量,在GMOND的Cluser name配置必须与data_source的相同,这个参量被设置为群的名字,被监测以便能监测那群状态。如果有二个或更多监测对象,当有一对象不能被监 测,将读取data_source 配置的下一个对象。端口号可以根据您自己的要求任意设置,这样可以起到一定的安全作用,防止其它的gmetad访问到你的客户机数据。
# The name of this Grid. All the data sources above will be wrapped in a GRID
# tag with this name.
# default: Unspecified
gridname "Network-status" #在web上显示GRID的名字,自己可以随意设置
# List of machines this gmetad will share XML with. Localhost
# is always trusted.
# default: There is no default value
# trusted_hosts 127.0.0.1 169.229.50.165 my.gmetad.org #可以设置多台gmetad的XML数据共享,这样您可以对不同网域设置多台gmetad,由中央gmetad收集XML数据显示在web上。
#设置用户的访问,自己可以根据需要进行修改
# If you don't want gmetad to setuid then set this to off
# default: on #默认需要验证用户
# setuid off
#User gmetad will setuid to (defaults to "nobody")
# default: "nobody" #默认用户为nobody
# setuid_username "用户" #用户需为本机有的用户,但测试发现只有用户为nobody时,gmetad可以正常启动(也许是权限问题,待解决)
#数据存放路径为默认/var/lib/ganglia/rrds,在这里可以看到监测群及群内的机器.
# Where gmetad stores its round-robin databases
# default: "/var/lib/ganglia/rrds"
# rrd_rootdir "/some/other/place"

2) client端安装和配置
a.在linux客户机上安装ganglia
[root@localhost ~]#tar –zxvf ganglia-3.0.4tar.gz
[root@localhost ~]#cd ganglia-3.0.4
[root@localhost ganglia-3.0.4]#./configure
[root@localhost ganglia-3.0.4]#make
[root@localhost ganglia-3.0.4]#make install
[root@localhost ganglia-3.0.4]#cd gmond
[root@localhost gmond]# gmond –t >/etc/gmond.conf
[root@localhost gmond]#cp gmond.init /etc/rc.d/init.d/gmond
[root@localhost gmond]# chkconfig --add gmond
[root@localhost gmond]# chkconfig --list gmond
gmond off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost gmond]#/etc/rc.d/init.d/gmond start
Starting GANGLIA gmond: [ OK ]
[root@localhost ~]#telnet localhost 8649 #就可以获取机群内运行gmond的主机的信息,端口号为gmetad.conf中设置的数值。
c.配置gmond.conf
[root@localhost ~]#vi /etc/gmond.conf
gmond.conf
globals {
setuid = yes
user = nobody #可修改为gmetad.conf中setuid_username对应的用户名,由于gmetad的原因这里没有做更改
cleanup_threshold = 300 /*secs */
}

cluster {
name = "unspecified" # #Cluser name 根据您在gmetad设置的组名称修改监控组名称
}
##udp发送信道,host是发送udp的电脑(linux下不能更改只能使用系统默认,待研究),端口port为gmetad设置的端口号。如果WINDOWS客户机在服务端无法显示该机器数据时,修改host为本机IP地址,可以解决。
udp_send_channel {
host = host.foo.com
port = 2389
}
#ACCESS CONTROL #访问控制
#The udp_recv_channel and tcp_accept_channel directives can contain an Access Control List (ACL). This ACL allows you to specify exactly which hosts gmond process data from
udp_recv_channel #udp接受信道,端口port为gmetad设置的端口号
udp_recv_channel {
mcast_join = 239.2.11.71
bind = 239.2.11.71
port = 8649
}
tcp_accept_channel #端口port为gmetad设置的端口号
tcp_accept_channel {
port = 8649
}

#可以在udp_recv_channel或tcp_accept_channel 里面添加访问控制命令
acl {
default = "deny"
access {
ip = x.x.x.x
mask = netmask
action = "allow"
}
}
配置完成后重新启动gmond.

d.安装web
cp -R ganglia/web /var/www/html #拷贝ganglia下的web文件夹
mv web ganglia #重命名web文件夹为ganglia
在apache里,php模块mod_php的状态是enabled
修改为DirectoryIndex index.htm index.html index.php index.php3 index.html.var
添加AddType application/x-httpd-php .php .php3
建立一个虚拟主机
修改配制文件/var/www/html/ganglia/conf.php
# Where gmetad stores the rrd archives. 
#gmetad_root 要与gmetad.conf的数据存放路径一致
$gmetad_root = "/var/lib/ganglia";
$rrds = "$gmetad_root/rrds";
# Leave this alone if rrdtool is installed in $gmetad_root,
# otherwise, change it if it is installed elsewhere (like /usr/bin)
define("RRDTOOL", "/usr/bin/rrdtool"); 
#RRDTOOL文件的安装路径,可根据你安装RRDTOOL路径进行设置。
#如果要从位于其它地方的ganglia取得数据的,并在web上显示,需要将ganglia_ip 和ganglia_port,更改为相对应的ganglia的ip地址和端口。
# If you want to grab data from a different ganglia source specify it here.
# Although, it would be strange to alter the IP since the Round-Robin
# databases need to be local to be read.
#
$ganglia_ip = "127.0.0.1"; #默认为从本地读取要显示的数据
$ganglia_port = 8652;
在浏览器地址栏输入
阅读(828) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~