首页 > 代码库 > Ganglia安装

Ganglia安装

Ganglia是监控集群机器运行状态的软件

1、环境准备

1.1 expat安装
软件名称:expat-2.1.0.tar.gz
软件地址:http://sourceforge.net/projects/expat/files/expat/
安装步骤:tar -zxvf expat-2.1.0.tar.gz
cd expat-2.1.0
./configure --prefix=/opt/local/expat-2.1.0
make
make install
cd /opt/local/expat-2.1.0
mkdir lib64
cp -a -f lib/* lib64

1.2 apr安装
软件名称:apr-1.5.2.tar.gz
软件地址:http://apr.apache.org/download.cgi
安装步骤:tar -zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/opt/local/apr-1.5.2
make
make install
说明:ganglia编译时默认寻找/opt/local/apr-1.5.2/include下的文件,即需做
cd /opt/local/apr-1.5.2/include/apr-1
cp -R * /opt/local/apr-1.5.2/include
如果64位机器需要拷贝动态链接库
cd /opt/local/apr-1.5.2
mkdir lib64
cd lib
cp -R * /opt/local/apr-1.5.2/lib64

 

1.3 apr-util安装
软件名称:apr-util-1.5.4.tar.gz
软件地址:http://apr.apache.org/download.cgi
安装步骤:tar -zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/opt/local/apr-util-1.5.4 --with-apr=/opt/local/apr-1.5.2 --with-expat=/opt/local/expat-2.1.0
make
make install

1.4 confuse安装
软件名称:confuse-2.7.tar.gz
软件地址:http://download.savannah.gnu.org/releases/confuse/
安装步骤:tar -zxvf confuse-2.7.tar.gz
cd confuse-2.7
./configure CFLAGS=-fPIC --disable-nls --prefix=/opt/local/confuse-2.7
make
make install
cd /opt/local/confuse-2.7
mkdir lib64
cp -R lib/* lib64

1.5 rrdtool安装
软件名称:rrdtool-1.4.8.tar.gz
软件地址:http://oss.oetiker.ch/rrdtool/pub/
安装步骤:tar -zxvf rrdtool-1.4.8.tar.gz
cd rrdtool-1.4.8
./configure --prefix=/opt/local/rrdtool-1.4.8 --disable-tcl
make
make install

问题:PKG_CONFIG_PATH问题
解决 yum -y install cairo-devel、yum -y install pango-devel、yum -y install libxml2-devel

1.6 pcre安装
软件名称:pcre-8.36.tar.gz
软件地址:http://www.pcre.org/
安装步骤:tar -zxvf pcre-8.36.tar.gz
cd pcre-8.36
./configure --prefix=/opt/local/pcre-8.36
make
make install
cd /opt/local/pcre-8.36
mkdir lib64
cp -a -f lib/* lib64

1.7 httpd安装

软件名称:httpd-2.2.32.tar.gz
软件地址:http://httpd.apache.org/download.cgi 
安装步骤:tar -zxvf httpd-2.2.32.tar.gz
mkdir /opt/local/apache2
cd httpd-2.2.32
./configure --prefix=/opt/local/apache2 --enable-module=shared
make
make install

 

编辑 /usr/local/apache2/conf/httpd.conf 文件 
  vi conf/httpd.conf 
找到:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在后面添加:
AddType application/x-httpd-php .php(使Apcche支持PHP)
AddType application/x-httpd-php-source .php5 
找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
添加:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule> 
找到:
#ServerName www.example.com:80
修改为 ServerName 192.168.46.163:80

更改httpd的访问配置路径Document Root
mkdir -p /var/www/html/ 
找到Document Root修改为
DocumentRoot "/var/www/html"

找到Directory 修改
<Directory "/var/www/html">

打开apache配置文件httpd.conf,找到这么一段:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
deny from all
Satisfy all
</Directory>

问题:
httpd: unrecognized service”

解决方法:
将httpd注册为系统服务即可,可使用如下代码:
#cd /opt/local/apache2/bin/ ##进入你的Apache安装目录下的bin文件夹下 #cp apachectl /etc/rc.d/init.d/httpd
#vi /etc/rc.d/init.d/httpd
在#!/bin/sh这行下增加
# chkconfig: 2345 50 90 # description:Activates/Deactivates Apache Web Server)

 

1.8 安装PHP

软件名称:php-5.6.30.tar.gz
软件地址:http://www.php.net/downloads.php
安装步骤:tar -zxvf php-5.6.30.tar.gz
cd php-5.6.30
./configure --prefix=/opt/local/php --with-apxs2=/opt/local/apache2/bin/apxs
make
make install

cp /opt/php-5.6.30/php.ini-development /opt/local/php/lib/php.ini

 

2、ganglia的安装

软件下载:https://sourceforge.net/projects/ganglia/files/
安装步骤:tar -zxvf ganglia-3.7.2.tar.gz
cd ganglia-3.7.2
./configure --prefix=/opt/local/ganglia-3.7.2 --with-librrd=/opt/local/rrdtool-1.4.8 --with-libapr=/opt/local/apr-1.5.2 --with-libexpat=/opt/local/expat-2.1.0 --with-libconfuse=/opt/local/confuse-2.7 --enable-gexec --enable-status --with-gmetad --with-libpcre=/opt/local/pcre-8.36 --with-static-modules --sysconfdir=/etc/ganglia
make
make install

 

3、服务段配置

cd /opt/ganglia-3.7.2/gmetad --软件包解压位置
cp gmetad.init /etc/init.d/gmetad
修改 vi /etc/init.d/gmetad
将GMETAD=/usr/sbin/gmetad修改为GMETAD=/opt/local/ganglia-3.7.2/sbin/gmetad
将daemon $GMETAD 修改为daemon $GMETAD -c /etc/ganglia/gmetad.conf
说明:1、/opt/local/ganglia-3.7.2为ganglia安装位置
2、如果不修改GMETAD值,可执行“cp /opt/local/ganglia-3.7.2/sbin/gmetad /usr/sbin/”代替

修改 vi /etc/ganglia/gmetad.conf
data_source "hadoop cluster" hadoop-namenode-01
gridname "hadoop cluster"
setuid_username "nobody"
rrd_rootdir "/var/lib/ganglia/rrds"

(“Hadoop Cluster”为整个监控架构的名字,可自定义
hadoop-namenode-01 表示节点域名和IP)
说明:如果安装ganglia的./configure 没有参数 --sysconfdir=/etc/ganglia
则 mkdir /etc/ganglia
切换至ganglia-3.7.2.tar.gz解压目录ganglia-3.7.2/gmetad
执行“cp gmetad/gmetad.conf /etc/ganglia/”
查看gmetad运行是否正常 ps -ef|grep gmetad
查看日志 tail /var/log/messages

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

##因ods1主机(192.168.10.3)既是ganglia服务端又是客户端,所以可以直接之配置客户端服务 具体参照4.3,不需要重新安装,

 

4、客户端配置

4.1.软件准备
需安装:expat、apr、apr-util、confuse、pcre
具体安装方法见:4.2、4.3、4.4、4.5、4.7

4.2.ganglia安装
具体见5.1安装方法。
在“./configure”参数时稍作修改:
./configure --prefix=/opt/local/ganglia-3.7.2 --enable-gexec --enable-status --with-libapr=/opt/local/apr-1.5.2 --with-libexpat=/opt/local/expat-2.1.0 --with-libconfuse=/opt/local/confuse-2.7 --with-libpcre=/opt/local/pcre-8.36 --sysconfdir=/etc/ganglia
make
make install

4.3.客户端配置
cd /opt/ganglia-3.7.2/gmond ----软件包解压位置
cp gmond.init /etc/init.d/gmond
./gmond -t > /etc/ganglia/gmond.conf
说明:如果安装ganglia的./configure 没有参数 --sysconfdir=/etc/ganglia
则 mkdir /etc/ganglia

修改 vi /etc/init.d/gmond
将GMOND=/usr/sbin/gmond修改为GMOND=/opt/local/ganglia-3.7.2/sbin/gmond
将daemon $GMOND 修改为daemon $GMOND -c /etc/ganglia/gmond.conf

说明:1、/opt/local/ganglia-3.7.2为ganglia安装位置
2、如果不修改GMOND值,可执行“cp /opt/local/ganglia-3.7.2/sbin/gmond /usr/sbin/”代替

修改 vi /etc/ganglia/gmond.conf

globals {
  daemonize = yes
  setuid = yes
  user = nobody --若要修改

/*
* The cluster attributes specified will be used as part of the <CLUSTER>
* tag that will wrap all hosts collected by this instance.
*/
cluster {
  name = "hadoop cluster"
  owner = "nobody"
  latlong = "unspecified"
  url = "unspecified"
}

/* Feel free to specify as many udp_send_channels as you like. Gmond
used to only support 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
  host = 192.168.46.163
  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 = 192.168.46.163
  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

}

 

5、WEB端配置

5.1.软件安装
  软件名称:ganglia-web-3.7.2
  软件地址:http://sourceforge.net/projects/ganglia/files/
  安装步骤:tar -zxvf ganglia-web-3.7.2.tar.gz -C /var/www/html/
       cd /var/www/html/ganglia-web-3.7.2
         vi Makefile

  GDESTDIR = /var/www/html/ganglia
  APACHE_USER = nobody

  make install --yum -y install rsync
5.2.软件配置
  cd /var/www/html/ganglia
  cp conf_default.php conf.php
修改 vi conf.php
将$conf[‘external_location‘] = "http://localhost/ganglia-2";
修改为 $conf[‘external_location‘] = "http://192.168.46.163/ganglia";

将相应目录修改为777权限
chmod 777 -R /var/lib/ganglia-web/dwoo

 

6、启动服务

service gmetad start
service gmond start
service httpd start

 

7、问题解决

问题1、gmetad进程没有起来
步骤:
先修改将datasource减少

若还不行自行创建/var/lib/ganglia的目录
mkdir -p /var/lib/ganglia/rrds
mkdir -p /var/lib/ganglia/dwoo

启动httpd报错查看日志/opt/local/apache2/logs

 

问题2、/opt/pcre-8.36/missing: line 81: automake-1.14: command not found
解决方式:autoreconf -v --install --force



问题3、/usr/local/lib/libpython2.7.a: could not read symbols: Bad value
解决方式:
重新编译Python
./configure --prefix=/usr/local/ CFLAGS=-fPIC
make
make install


问题4、Can‘t locate ExtUtils/MakeMaker.pm
解决方式:
yum install -y perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

 

问题5、ganglia图片显示不了
cd /var/www/html/ganglia/
vi conf.php
$conf[‘rrdtool‘] = "/opt/local/rrdtool-1.4.8/bin/rrdtool";

 

问题6、 please set date.timezone to select your timezone. in /var/www/html/ganglia/header.php on line 5
问题解决:
date_default_timezone_set(‘Asia/Shanghai‘); //设置时间区域为“亚洲/上海”,也就是中国。

 

问题7、Ganglia访问失败 There was an error collecting ganglia data (127.0.0.1:8652): fsockopen error: Permission denied

解决:需要关闭selinux:vi /etc/selinux/config,把SELINUX=enforcing改成SELINUX=disabled;需要重启机器。

 

问题8、 please set date.timezone to select your timezone. in /var/www/html/ganglia/header.php on line 5
问题解决:
date_default_timezone_set(‘Asia/Shanghai‘); //设置时间区域为“亚洲/上海”,也就是中国。

 

8、配置Hadoop

 

vi hadoop-metrics2.properties

hadoop集群配置ganglia

修改namenode节点

namenode.sink.ganglia.servers=hadoop-namenode-01:8649

#datanode.sink.ganglia.servers=yourgangliahost_1:8649,yourgangliahost_2:8649

resourcemanager.sink.ganglia.servers=hadoop-namenode-01:8649

#nodemanager.sink.ganglia.servers=yourgangliahost_1:8649,yourgangliahost_2:8649

mrappmaster.sink.ganglia.servers=hadoop-namenode-01:8649

jobhistoryserver.sink.ganglia.servers=hadoop-namenode-01:8649


修改datanode节点

#namenode.sink.ganglia.servers=nna:8649

datanode.sink.ganglia.servers=zk-datanode-01:8649

#resourcemanager.sink.ganglia.servers=nna:8649

nodemanager.sink.ganglia.servers=zk-datanode-01:8649

#mrappmaster.sink.ganglia.servers=nna:8649

#jobhistoryserver.sink.ganglia.servers=nna:8649

 

其他的类推配置。

 

Ganglia安装