实验环境如下图所示
1.上图中三台机器均为rhel 5.8 x86_64,三台机器IP地址和主机名已按上图设置完毕
2.各软件版本如下
◆.confuse-2.7.tar.gz
◆.ganglia-3.2.0.tar.gz
◆.rrdtool-1.4.5.tar.gz
3.管理节点(admin),hosts文件已添加完毕,如下所示
192.168.10.11 admin
192.168.10.100 node1
192.168.10.101 node2
4.本次实验ganglia通信采用单播方式
【管理端(admin)安装ganglia】
一:安装所需软件
[[email protected] ~]#yum -y install apr-devel expat-devel \
> pcre-devellibxml2-devel cairo-devel \
> pango-develpython-devel
注:RHEL 6系列不能只安装python-devel,可以直接python*,还要加装perl-ExtUtils*
二:编译安装confuse
[[email protected]]# tar xzf confuse-2.7.tar.gz
[[email protected]]# cd confuse-2.7
[[email protected]]# ./configure --enable-shared --libdir=/usr/lib64
[[email protected]]# make
[[email protected]]# make install
三:编译安装rrdtool
[[email protected]]# tar xzf rrdtool-1.4.5.tar.gz
[[email protected]]# cd rrdtool-1.4.5
[[email protected]]# ./configure --prefix=/usr/local/rrdtool
[[email protected]]# make
[[email protected]]# make install
四:编译安装ganglia
[[email protected]]# ./configure --prefix=/usr/local/ganglia \
>--sysconfdir=/etc/ganglia \
>--with-librrd=/usr/local/rrdtool \
> --with-gmetad\
>--enable-gexec \
>--enable-status
[[email protected]]# make
[[email protected]]# make install
五:配置ganglia
◆.链接命令文件
[[email protected]]# ln -s /usr/local/ganglia/bin/* /usr/local/bin/
[[email protected]]# ln -s /usr/local/ganglia/sbin/* /usr/local/sbin/
◆.配置gmetad
1.[[email protected]]# cd gmetad
2.[[email protected]]# cp gmetad.init /etc/init.d/gmetad
3.[[email protected]]# chkconfig --add gmetad;chkconfig --list gmetad
gmetad 0:off 1:off 2:on 3:on 4:on 5:on 6:off
4.[[email protected]]# vi /etc/init.d/gmetad 修改GMETAD=/usr/sbin/gmetad为GMETAD=/usr/local/ganglia/sbin/gmetad
5.[[email protected]]# vi /etc/ganglia/gmetad.conf,找到第45行:data_source "my cluster" localhost,把"my cluster"可一更改为自己喜欢的名称,比如wjcyf,其他默认即可
6.创建所需目录,并设置所有者和权限
[[email protected] gmetad]#mkdir -p /var/lib/ganglia/rrds
[[email protected]]# chown nobody:nobody /var/lib/ganglia/rrds/
[[email protected]]# chmod 1777 /var/lib/ganglia/rrds/
7.启动gmetad服务
[[email protected]]# /etc/init.d/gmetad start
Starting GANGLIAgmetad: [ OK ]
◆.配置gmond
1.[[email protected]]# cd ../gmond/
2.[[email protected]]# cp gmond.init /etc/init.d/gmond
3.[[email protected]]# chkconfig --add gmond ;chkconfig --list gmond
gmond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
4. [[email protected]]# vi /etc/init.d/gmond修改GMOND=/usr/sbin/gmond为GMOND=/usr/local/ganglia/sbin/gmond
5.生成默认配置文件gmond.conf
[[email protected]]# ./gmond -t >/etc/ganglia/gmond.conf
6. [[email protected]]# vi /etc/ganglia/gmond.conf,本次实验配置ganglia server节点为“单收”,配置文件需要修改的地方为下面红色文字所示,其余均默认
/* This configuration is as close to 2.5.x defaultbehavior as possible
The valuesclosely match ./gmond/metric.h definitions in 2.5.x */
globals {
daemonize =yes
setuid = yes
user = nobody
debug_level =0
max_udp_msg_len = 1472
mute = yes
deaf = no
allow_extra_data = yes
host_dmax = 0/*secs */
host_tmax = 20/*secs */
cleanup_threshold = 300 /*secs */
gexec = no
send_metadata_interval = 0 /*secs */
}
/*
* The clusterattributes specified will be used as part of the <CLUSTER>
* tag that willwrap all hosts collected by this instance.
*/
cluster {
name = "wjcyf"
owner ="unspecified"
latlong ="unspecified"
url ="unspecified"
}
/* The host section describes attributes of the host,like the location */
host {
location ="unspecified"
}
/* Feel free to specify as many udp_send_channels asyou like. Gmond
used to onlysupport having a single channel */
udp_send_channel {
#bind_hostname= yes # Highly recommended, soon to be default.
# This option tells gmond to use a source address
# that resolves to the machine‘s hostname. Without
# this, the metrics may appear to come from any
# interface and the DNS names associated with
# those IPs will be used to create the RRDs.
mcast_join =239.2.11.71
port = 8649
ttl = 1
}
/* You can specify as many udp_recv_channels as youlike as well. */
udp_recv_channel {
port= 8649
bind= 192.168.10.11
}
/* You can specify as many tcp_accept_channels as youlike to share
an xmldescription of the state of the cluster */
tcp_accept_channel {
port = 8649
acl {
default = "deny"
access {
ip= 127.0.0.1
mask= 32
action= "allow"
}
}
}
以下配置文件略
7.启动gmond服务
[[email protected]]# /etc/init.d/gmond start
Starting GANGLIAgmond: [ OK ]
六:安装apache配置ganglia-web
1. [[email protected]]# yum -y install httpd php php-gd
2. [[email protected]]# cp -r web/ /var/www/html/ganglia
3. [[email protected]]# cd /var/www/html/ganglia/
4. [[email protected]]# cp conf.php conf.php.bak
5.[[email protected] ganglia]#vi conf.php,更改第33行define("RRDTOOL","/usr/bin/rrdtool");为
define("RRDTOOL","/usr/local/rrdtool/bin/rrdtool");
6.创建所需目录,并设置所有者和权限
[[email protected]]# mkdir /var/lib/ganglia/dwoo
[[email protected]]# chown apache:apache /var/lib/ganglia/dwoo/
[[email protected]]# chmod 777 /var/lib/ganglia/dwoo/
7. [[email protected]]# vi /etc/httpd/conf/httpd.conf,把第256行#ServerName www.example.com:80前面的#号去掉
8.启动apache服务
[[email protected]]# /etc/init.d/httpd start ; chkconfig httpd on
Startinghttpd: [ OK ]
七:访问ganglia server
1.http://192.168.10.11/ganglia,因为此服务器被配置为“单收”,所以会出现下面的网页显示(有被监控端后,显示正常)
【被监控端安装ganglia】
一:安装所需软件
[[email protected] ~]#yum -y install apr-devel expat-devel pcre-devel python-devel
二:编译安装confuse
[[email protected]]# tar xzf confuse-2.7.tar.gz
[[email protected]]# cd confuse-2.7
[[email protected]]# ./configure --enable-shared --libdir=/usr/lib64
[[email protected]]# make
[[email protected]]# make install
三:编译安装ganglia
[[email protected]]# ./configure --prefix=/usr/local/ganglia \
>--sysconfdir=/etc/ganglia \
>--enable-gexec \
>--enable-status
[[email protected]]# make
[[email protected]]# make install
四:配置ganglia
1.创建ganglia配置文件存放目录
[[email protected] ganglia-3.2.0]#mkdir /etc/ganglia
2.[[email protected]]# cd gmond/
3.[[email protected]]# cp gmond.init /etc/init.d/gmond
4.[[email protected]]# chkconfig --add gmond ;chkconfig --list gmond
gmond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
5. [[email protected]]# vi /etc/init.d/gmond修改GMOND=/usr/sbin/gmond为GMOND=/usr/local/ganglia/sbin/gmond
6.生成默认配置文件gmond.conf
[[email protected]]# ./gmond -t >/etc/ganglia/gmond.conf
7.[[email protected]]# vi /etc/ganglia/gmond.conf,本次实验配置被监控节点为“单发”,配置文件需要修改的地方为下面红色文字所示,其余均默认
/* This configuration is as close to 2.5.x defaultbehavior as possible
The valuesclosely match ./gmond/metric.h definitions in 2.5.x */
globals {
daemonize =yes
setuid = yes
user = nobody
debug_level =0
max_udp_msg_len= 1472
mute = no
deaf = yes
allow_extra_data = yes
host_dmax = 86400/*secs */
host_tmax = 20/*secs */
cleanup_threshold = 300 /*secs */
gexec = no
send_metadata_interval= 300 /*secs */
}
/*
* The clusterattributes specified will be used as part of the <CLUSTER>
* tag that willwrap all hosts collected by this instance.
*/
cluster {
name = "wjcyf"
owner ="unspecified"
latlong ="unspecified"
url ="unspecified"
}
/* The host section describes attributes of the host,like the location */
host {
location ="unspecified"
}
/* Feel free to specify as many udp_send_channels asyou like. Gmond
used to onlysupport having a single channel */
udp_send_channel {
host= 192.168.10.11
port= 8649
}
以下配置文件略
8.启动gmond服务
[[email protected] ~]#/etc/init.d/gmond start
注:node2操作同node1
五:重新访问ganglia server,则可正常显示node1和node2的信息,如下列图中所示
碰到的问题
- 在启动/etc/init.d/gmond服务时报错:gmond dead but subsys locked
A:原来是在目录/etc/ganglia/conf.d/下有个文件modpython.conf,我这样做了一个备份cp modpython.conf ~modpython.conf的缘故,删除~modpython.conf后,gmond服务正常启动