前言
看了网上关于ganglia的安装教程,非常麻烦需要安装N多依赖包:rrdtools expat apr等,我试着做了,结果在编译ganglia环节出了问题,最后气愤寻求它路。这里讲的是老外的一篇文章,我试过觉得非常不错,文章最后有原文链接。
准备:
安装fedora yum仓库,server端和client端都需要,根据自己的OS挑选匹配版本:
To enable EPEL for CentOS 5
For 32-bits
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
For 64-bits
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
To enable EPEL for CentOS 4For 32-bits
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/4/i386/epel-release-4-10.noarch.rpm
For 64-bits
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/4/x86_64/epel-release-4-10.noarch.rpm
安装
server端
yum install rrdtool ganglia ganglia-gmetad ganglia-gmond ganglia-web httpd php
client端
yum install ganglia-gmond
配置
Server端
①
> vi /etc/gmond.conf
cluster {
name = "heipark" // 这个名称很重要
....
}
udp_send_channel {
host = 192.168.1.5 // 使用host为单播,mcast_join为多播
port = 8649
ttl = 1
}
udp_recv_channel { // 如果使用单机广播,要删除“mcast_join”和“bind”
port = 8649
}
②
> vi /etc/gmetad.conf
# 配置一个数据源,名称“heipark”要和/etc/gmond.conf中一致,后面的ip为server的ip
data_source "heipark" 192.168.1.5:8649
③
# 开机运行采集进程
chkconfig --levels 235 gmond on
# 开机运行数据存储进程
chkconfig --levels 235 gmetad on
# 开机运行apache服务
chkconfig --levels 235 httpd on
client端
①
# 在server端执行scp,将配置文件分发到client端
scp /etc/gmond.conf root@{ip}:/etc/gmond.conf
②
# 设置开机运行数据采集进程
chkconfig --levels 235 gmond on
运行
Server端
service gmond start
service gmetad start
service httpd start
Client端
service gmond start
测试
# 命令行打印当前活动client
gstat -a
# web显示当前client状态
http://{your_ip}/ganglia
Apache密码验证
通过web方式访问ganglia不需要密码,所以我们通过apache设置密码达到安全目的。
①
htpasswd -c /etc/httpd/conf.d/passwords {your_name}
②
cd /usr/share/ganglia
vi .htaccess // 创建apache目录密码文件,并写入下面内容
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/httpd/conf.d/passwords
Require user {your_name}
③
vi /etc/httpd/conf/httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
修改为:
<Directory />
Options FollowSymLinks
AllowOverride AuthConfig
</Directory>
参考:
★老外神作版本:
http://linuxcluster.wordpress.com/2010/01/01/installing-and-configuring-ganglia-on-centos-5-4/
阿泰菜园版本:
http://arch.huatai.me/?p=280&cpage=1#comment-586
手工配置版本:
http://www.blogjava.net/xylz/archive/2011/07/21/354744.html
-- end --