网上说3.0.3的依赖最少,因此下了个: http://sourceforge.net/projects/ganglia/files/ganglia%20monitoring%20core/3.0.3%20%28Orwille%29/
1. 服务端安装 (gmetad)
服务端的服务为gmetad,安装前需要先安装RRDTool(数据库和绘图工具,服务端收集的客户端信息由其来保存),因为要绘制曲线图,所以安装RRDTool前,还必须安装好libpng,freetype,zlib这些库(也是php的gd库需要的),下载地址http://www.rrdtool.org/ 。
安装完了RRDTool,就可以安装gmetad了
tar –zxvf ganglia3.0.3.tar.gz ./configure CFLAGS="-I/usr/local/rrdtool/include" CPPFLAGS="-I/usr/local/rrdtool/include" LDFLAGS="-L/usr/local/rrdtool/lib" --with-gmetad --enable-gexec make install |
将gmetad.init文件拷贝到 /etc/init.d/:
cd ganglia-3.0.3/gmetad cp gmetad.init /etc/init.d/gmetad #若是ganglia安装在别的目录,则修改gmetad.init里的gmetad路径 cp gmetad.conf /etc/gmetad.conf chkconfig gmetad on chkconfig --list gmetad GMETAD 0:off 1:off 2:on 3:on 4:on 5:on 6:off
|
创建rrd数据存储的文件夹, 修改属性拥有者为: "nobody":
mkdir /var/lib/ganglia/rrds chown nobody:nobody /var/lib/ganglia/rrds |
启动gmetad:
service gmetad start Starting GANGLIA gmetad: [ OK ] |
修改 /etc/gmetad.conf文件:
data_source "hadoop" localhost 192.168.1.1 #所要监控的客户端 可以写多个 # default: "/var/lib/ganglia/rrds" #定义该客户端的数据保存的路径 |
重新启动gmetad:
service gmetad start Starting GANGLIA gmetad: [ OK ] |
验证gmetad正常工作:
telnet localhost 8651 |
就可以得到监控的各个主机的状态。
安装客户端gmond
在每台需要监控的机器上,安装gmond
安装ganglia:
tar zxvf ganglia-3.0.3.tar.gz cd ganglia-3.0.3 ./configure --prefix=/usr/local/ganglia make; make install cd gmond ./gmond –t > /etc/gmond.conf |
vi gmond.init 修改里面的GMOND 改为GMOND=/usr/local/ganglia/sbin/gmond # cp gmond.init /etc/init.d/gmond # chkconfig --list gmond gmond 0:off 1:off 2:on 3:on 4:on 5:on 6:off # service gmond start Starting GANGLIA gmond: [ OK ] #若不成功的话,就用/usr/local/ganglia/sbin/gmond手动启动
|
出现多播问题的话:
route add -host 239.2.11.71 dev eth1 即可。
验证gmond正常工作:
telnet localhost 8649 |
Web端安装
web端用于通过web来查看监控状态。
因为web端程序是php写的,所以需要安装apache。同时需要编译php的gd库。web端需要和服务器端在一块。
# cp -a ganglia-3.0.3/web /var/www/html/ganglia
确定web server支持PHP4
对apache来说,php模块mod_php的状态应该是enabled,貌似默认就是的^_^
配制文件是/var/www/html/ganglia/conf.php
# Where gmetad stores the rrd archives. $gmetad_root = "/var/lib/ganglia"; # $rrds = "/usr/local/rrdtool-1.0.50/"; #数据源路径,这里实际可以什么都不用做
# Leave this alone if rrdtool is installed in $gmetad_root, # otherwise, change it if it is installed elsewhere (like /usr/bin) define("RRDTOOL", "/usr/local/rrdtool-1.0.50/bin/rrdtool"); # rrdtool执行路径
# # 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 = "localhost"; $ganglia_port = 8652; #$ganglia_port = 8649;
|
在浏览器地址栏输入http://localhost/ganglia/应该可以看到有页面显示了。
遇到安装问题查看命令:
Gmetad –d1
Gmond –d1
这两个命令是大杀器啊!
此外,出现的问题是c01b01上面的gmond配置文件总在/usr/local/etc/下,不知道是怎么回事。
参考: http://drunkedcat.diandian.com/post/2012-08-02/40047438801