ganglia 安装

来源:互联网 发布:软件残余清理 编辑:程序博客网 时间:2024/05/16 03:18
主机IP地址为192.168.138.22
主机操作系统版本:(选择基本安装)
[root@localhost rpm-gpg]# lsb_release  -a
LSB Version:    :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 6.2 (Santiago)
Release:        6.2
Codename:       Santiago

安装ganglia的步骤
一. 建立yum 数据源,在redhat企业版中如果没有序列号,不提供yum的数据源安装.但是我们可以把安装光盘制作成数据源.因为光盘上已经有了我们日常常用的软件,常用的包 .这样可以节约很多时间.
二. rrdtool 工具,这个工具需要三个包同时安装
三. 编译libconfuse,注意在编译的时候需要加上  ./configure CFLAGS=-fPIC --disable-nls
四. 编译ganglia
五. 配置ganglia,并验证服务

下面是详细安装步骤(本试验是针对Red Hat Enterprise Linux Server release 6.2,采用基本配置安装的操作,其它环境可能有些包没有预装.用yum应该能很好解决)

a) 安装vsftp工具
    rpm -ivh vsftpd-2.2.2-11.el6_3.1.x86_64.rpm
b) 拷贝安装包到ftp服务器
    mkdir /var/ftp/redhat
    mkdir /mnt/cdrom
    mount /dev/cdrom /mnt/cdrom   (插入光盘)
    cp -r /mnt/cdrom/* /var/ftp/redhat
c) 配置yum 安装(更改/etc/yum.repos.d/rhel-source.repo 请看红色部分)
[root@localhost yum.repos.d]# cat rhel-source.repo
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=ftp://192.168.138.22/redhat
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
d) 安装程序包
yum install rrdtool-devel
yum install compat-expat1
yum install httpd
yum install gcc g++
yum -y install apr-util-devel
yum install pcre-devel
yum install zlib-devel
yum instal php
yum install php-gd
yum install xorg-x11-server-Xorg

 tar -zxvf confuse-2.7.tar.gz
 cd confuse-2.7
 ./configure CFLAGS=-fPIC --disable-nls
 make install
 tar -zxvf ganglia-3.6.0.tar.gz
 cd ganglia-3.6.0
 ./configure --prefix=/usr/local/ganglia-3.6.0 --with-gmetad
 出现下面图形表示
Welcome to..
     ______                  ___
    / ____/___ _____  ____ _/ (_)___ _
   / / __/ __ `/ __ \/ __ `/ / / __ `/
  / /_/ / /_/ / / / / /_/ / / / /_/ /
  \____/\__,_/_/ /_/\__, /_/_/\__,_/
                   /____/

Copyright (c) 2005 University of California, Berkeley

Version: 3.6.0
Library: Release 3.6.0 0:0:0

Type "make" to compile.

./make install

编译客户端
 ./configure --prefix=/usr/local/ganglia-3.6.0

 cp /home/ocdc/ganglia-3.6.0/gmetad/gmetad.init /etc/rc.d/init.d/gmetad
 cp /home/ocdc/ganglia-3.6.0/gmond/gmond.init /etc/rc.d/init.d/gmond

 ln -s /usr/local/ganglia-3.6.0/sbin/gmetad /usr/sbin/gmetad
 ln -s /usr/local/ganglia-3.6.0/sbin/gmond /usr/sbin/gmond

chkconfig --add gmetad

chkconfig --add gmond

chkconfig --level 345 gmetad on

chkconfig --level 345 gmond on


生成默认配置文件

gmond -t | tee /usr/local/ganglia-3.6.0/etc/gmond.conf


创建 rrds 数据文件存放目录

mkdir -p /var/lib/ganglia/rrds
chown nobody:nobody /var/lib/ganglia/rrds


-- 下面配置文件可以不必编辑,默认安装就可以使用(对于配置文件的修改请参考相关网页)

vi /usr/local/ganglia-3.6.0/etc/gmetad.conf
vi /usr/local/ganglia-3.6.0/etc/gmond.conf

service gmetad restart
service gmond  restart
--检查 gmetad 服务
telnet localhost 8651

--检查 gmond 服务
telnet localhost 8649


安装ganglia-web  
a) 执行 setenforce 0  (需要执行,否则会报不允许访问)

b)拷贝ganglia-web 到/var/www/html/ganglia 并设定配置文件
mv ganglia-web-3.5.10 /var/www/html/ganglia
c) 编辑 conf.php
cp  conf_default.php conf.php

$conf['gweb_root'] = "/var/www/html/ganglia";
$conf['gweb_confdir'] = "/var/www/html/ganglia";

#下面的路径与gweb_confdir 的路径有关 /var/www/html/ganglia 代表 gweb_confdir路径
mkdir -p /var/www/html/ganglia/dwoo/compiled
mkdir -p /var/www/html/ganglia/dwoo/cache
chmod 777 /var/www/html/ganglia/dwoo/compiled
chmod 777 /var/www/html/ganglia/dwoo/cache

启动httpd 服务

service httpd restart

检验 http://192.168.138.22/ganglia



部署客户端到其他服务器(下面shell是在本环境下直接拷贝文件部署到其他服务器,服务器的操作系统必须一致)
#!/bin/bash
cd /usr/local
tar -cvf ./ganglia-3.6.0.tar ./ganglia-3.6.0

for rh in cloud01 cloud02 cloud03
do
scp ganglia-3.6.0.tar $rh:/usr/local
ssh $rh "cd /usr/local; tar -xvf ./ganglia-3.6.0.tar; rm ./ganglia-3.6.0.tar"
scp /usr/lib64/libapr-1.so* $rh:/usr/lib64

scp  /etc/rc.d/init.d/gmetad  $rh:/etc/rc.d/init.d/
scp  /etc/rc.d/init.d/gmond   $rh:/etc/rc.d/init.d/

ssh $rh ln -s /usr/local/ganglia-3.6.0/sbin/gmetad /usr/sbin/gmetad
ssh $rh ln -s /usr/local/ganglia-3.6.0/sbin/gmond /usr/sbin/gmond

ssh $rh chkconfig --add gmetad
ssh $rh chkconfig --add gmond

ssh $rh service gmond  restart

done
rm ./ganglia-3.6.0.tar

其他内容:

配置分组

gmetad.conf

data_source "NameNode" 192.168.138.23:8649
data_source "DataNode" 192.168.138.24:8650


gmond.conf

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 you like as well. */
udp_recv_channel {
  mcast_join = 239.2.11.71
  port = 8649
  bind = 239.2.11.71
  retry_bind = true
  # Size of the UDP buffer. If you are handling lots of metrics you really
  # should bump it up to e.g. 10MB or even higher.
  # buffer = 10485760
}

/* You can specify as many tcp_accept_channels as you like to share
   an xml description of the state of the cluster */
tcp_accept_channel {
  port = 8649
  # If you want to gzip XML output
  gzip_output = no
}

/* Channel to receive sFlow datagrams */
#udp_recv_channel {
#  port = 6343
#}


配置unicast  (在配置接收信息的时候 ,udp_recv_channel 配置端口就可以了)

udp server
udp_recv_channel {
  port = 8649
}

udp client
udp_send_channel {
  host = xxx.xxx.xxx.xxx
  port = 8649
  ttl = 1
}

mod_python 配置

拷贝配置
cp ganglia-3.6.0/gmond/python_modules/process/procstat.py /usr/local/ganglia-3.6.0/lib64/ganglia/python_modules/
cp ganglia-3.6.0/gmond/python_modules/conf.d/procstat.pyconf  /usr/local/ganglia-3.6.0/etc/conf.d/

编辑 procstat.pyconf 配置文件 详细配置可以参考procstat.py 源代码



备注:
一 rrd 路径需要在web配置文件中配置

二 ganglia 多播问题
1、安装客户端完了以后,启动gmond失败:
可以用$gmond -d1 显示错误信息
Error creating multicast server mcast_join=239.2.11.71 port=8649 mcast_if=NULL family='inet4'. Exiting.
办法如下:
$/sbin/route add -host 239.2.11.71 dev eth0(这个是与服务器端相连的网卡,server端也要修改)
可以把这句添加在/etc/rc.d/rc.local里面,让它每次启动时执行
239.2.11.71 是gmond.conf里的默认多播地址
然后启动gmond 就OK了
2、似乎ganglia不支持mesh结构,通过与server连的IP获取client地址;
3、ganglia各节点机器名由hosts文件中的配置决定。

三 ganglia 不能获取主机信息
    问题描述:某些节点用pssh 启动gmond后不能获取主机信息
    问题处理: 用ssh 登陆后启动gmond问题解决
四 ganglia 启动gmond后有些主机指标无法收集
    问题描述: 启动主机后部分主机指标显示无法收集
    问题处理: ganglia中需要所有监控主机时间一致才能获取指标信息.故配置ntp后问题解决.






原创粉丝点击