设为首页 收藏本站
查看: 1426|回复: 0

[经验分享] CentOS集群上安装Ganglia-3.6.1监控

[复制链接]

尚未签到

发表于 2016-5-12 09:16:16 | 显示全部楼层 |阅读模式
CentOS集群上安装Ganglia-3.6.1监控

 

 

 



1、安装依赖


1、建议使用超级用户安装

yum -y install apr-devel apr-util check-devel cairo-devel pango-devel libxml2-devel \
rpmbuild glib2-devel dbus-devel freetype-devel fontconfig-devel gcc-c++ expat-devel \
python-devel libXrender-devel pcre pcre-devel
 
2、关闭selinux
#vi /etc/selinux/config
SELINUX=enforcing改成SELINUX=disable,重启机器。


2、安装expat依赖


#mkdir /home/ganglia
#cd /home/ganglia
#wget http://jaist.dl.sourceforge.net/project/expat/expat/2.1.0/expat-2.1.0.tar.gz
#tar -xf expat-2.1.0.tar.gz
#cd expat-2.1.0
#./configure --prefix=/usr/local/expat
#make
#make install
对于64位操作系统,需要手动的拷贝下动态链接库到lib64
mkdir /usr/local/expat/lib64
#cp -a /usr/local/expat/lib/* /usr/local/expat/lib64/
 


3、安装confuse


#cd /home/ganglia
#wget ftp://ftp.icm.edu.pl/vol/rzm1/linux-fedora-secondary/development/source/SRPMS/libconfuse-2.6-1.fc9.src.rpm
#tar -xf confuse-2.7.tar.gz
#cd confuse-2.7
#./configure CFLAGS=-fPIC --disable-nls --prefix=/usr/local/confuse
#make
#make install
64bit机器需要拷贝动态链接库:
#mkdir -p /usr/local/confuse/lib64
#cp -a -f /usr/local/confuse/lib/* /usr/local/confuse/lib64/


4、安装ganglia


#cd /home/ganglia
#wget http://jaist.dl.sourceforge.net/project/ganglia/ganglia%20monitoring%20core/3.6.1/ganglia-3.6.1.tar.gz
#tar -xf ganglia-3.6.1.tar.gz
#cd ganglia-3.6.1
#./configure --with-gmetad --enable-gexec --with-libconfuse=/usr/local/confuse --with-libexpat=/usr/local/expat --prefix=/usr/local/ganglia --sysconfdir=/etc/ganglia
#make
#make install


5、服务端配置(Gmetad节点)


#mkdir -p /var/lib/ganglia/rrds
#mkdir -p /var/lib/ganglia/dwoo
#chown -R root:root /var/lib/ganglia
配置一个数据源
vi /etc/ganglia/gmetad.conf,修改如下信息:
data_source "Hadoop" 192.168.1.108:8649
setuid_username "root"
说明:这里的 " hadoop " 表示的是集群的名称, 192.168.1.108:8649 Gmeta服务所在的IP和监听端口。
添加自启动脚本
#cp -f gmetad/gmetad.init /etc/init.d/gmetad
#cp -f /usr/local/ganglia/sbin/gmetad /usr/sbin/gmetad
#chkconfig --add gmetad
启动gmetad服务
#service gmetad start
看见Starting GANGLIA gmetad: [ OK ]就代表运行正常了。通过telnet localhost 8651验证gmetad是否正常


6、客户端配置(gmond节点)


本机安装如下:
#cp -f gmond/gmond.init /etc/init.d/gmond
#cp -f /usr/local/ganglia/sbin/gmond /usr/sbin/gmond
#chkconfig --add gmond
#gmond --default_config > /etc/ganglia/gmond.conf
对于生成的默认配置文件需要做适当的修改

globals {
daemonize = yes
setuid = yes
user = root /*运行Ganglia的用户*/
debug_level = 0
max_udp_msg_len = 1472
mute = no
deaf = no
host_dmax = 120 /*secs */
cleanup_threshold = 300 /*secs */
gexec = no
send_metadata_interval = 15 /*发送数据的时间间隔*/
}
cluster {
name = "hadoop" /*集群名称*/
owner = "root" /*运行Ganglia的用户*/
latlong = "unspecified"
url = "unspecified"
}
udp_send_channel {
# mcast_join = 239.2.11.71 /*注释掉组播*/
host = 192.168.1.108/*发送给安装gmetad的机器的IP*/
port = 8649
ttl = 1
}
udp_recv_channel { #接受UDP包配置
# mcast_join = 239.2.11.71
port = 8649
# bind = 239.2.11.71
}
  
其中name是将要在服务端进行的分组,是服务端的数据源。接下来开启服务
#service gmond start
看见Starting GANGLIA gmetad: [ OK ]代表启动成功。如果有失败,可以讲gmond.conf中的debug0改为100,看更多的日志,然后进行排查。

7、服务端的WEB配置

1PHP程序需要依赖Apache来运行,因此需要安装如下依赖
# yum -y install php httpd
# service httpd start //启动httpd 服务
2、下载最新版本的gweb(https://sourceforge.net/projects/ganglia/files/gweb/)本示例当前最新版本为3.6.2
# wget http://jaist.dl.sourceforge.net/project/ganglia/ganglia-web/3.6.2/ganglia-web-3.6.2.tar.gz
# tar -zxvf ganglia-web-3.6.2.tar.gz
# cd ganglia-web-3.6.2

3、编译Makefile
# vim Makefile

可以查看一些用户默认配置:


##########################################################
# User configurables:
##########################################################
# Location where gweb should be installed to (excluding conf, dwoo dirs).
GDESTDIR = /usr/share/ganglia-webfrontend
# Location where default apache configuration should be installed to.
GCONFDIR = /etc/ganglia-web
# Gweb statedir (where conf dir and Dwoo templates dir are stored)
GWEB_STATEDIR = /var/lib/ganglia-web
# Gmetad rootdir (parent location of rrd folder)
GMETAD_ROOTDIR = /var/lib/ganglia
APACHE_USER = www-data
##########################################################

 
4
、修改默认配置:
GDESTDIR = /var/www/html/ganglia
APACHE_USER = apache

注意:GDESTDIR 和 APACHE_USER 要与APACHE的配置文件(/etc/httpd/conf/httpd.conf)中的 DocumentRoot 、 User保持一致
#make install


8、F&Q


1Ganglia访问失败
There was an error collecting ganglia data (127.0.0.1:8652): fsockopen error: Permission denied
解决办法:
需要关闭selinuxvi /etc/selinux/config,把SELINUX=enforcing改成SELINUX=disable;需要重启机器。可以使用命令setenforce 0来关闭selinux而不需要重启,刷新页面,即可访问。但此方法只是一权宜之计。要想永久修改selinux设置,还是要使用第一种方法。
重启httpd服务器即可看到效果
9、附录


 1、监控HbadoopHbase


Hadoop HBase社区一直使用它作为监控集群的业界标准方案。在maste上安装gmetad,在masternodeslave上安装gmond。为了监HadoopHBase,需要对它们做一些配置。这里Hadoop使用的是2.2.0版本,HBase使用的是0.96.0这个版本。这里监控的分布式集群也是文章《UbuntuCentOS中分布式配置Hadoop-2.2.0http://www.iyunv.com/Linux/2014-01/95799.htm 和《CentOS分布式环境安装HBase-0.96.0http://www.iyunv.com/Linux/2014-01/95801.htm 中布置的hadoophbase
为了能让ganglia监控hadoopHadoop2.2.0需要配置hadoop-2.2.0/etc/hadoop/目录下的 hadoop-metrics.propertieshadoop-metrics2.properties文件。其中,hadoop- metrics.properties配置如下:
# Configuration of the "dfs" context for null
dfs.class=org.apache.hadoop.metrics.spi.NullContext
 
# Configuration of the "dfs" context for file
#dfs.class=org.apache.hadoop.metrics.file.FileContext
#dfs.period=10
#dfs.fileName=/tmp/dfsmetrics.log
 
# Configuration of the "dfs" context for ganglia
# Pick one: Ganglia 3.0 (former) or Ganglia 3.1 (latter)
# dfs.class=org.apache.hadoop.metrics.ganglia.GangliaContext
# dfs.class=org.apache.hadoop.metrics.ganglia.GangliaContext31
# dfs.period=10
# dfs.servers=localhost:8649
 
 
# Configuration of the "mapred" context for null
mapred.class=org.apache.hadoop.metrics.spi.NullContext
 
# Configuration of the "mapred" context for file
#mapred.class=org.apache.hadoop.metrics.file.FileContext
#mapred.period=10
#mapred.fileName=/tmp/mrmetrics.log
 
# Configuration of the "mapred" context for ganglia
# Pick one: Ganglia 3.0 (former) or Ganglia 3.1 (latter)
# mapred.class=org.apache.hadoop.metrics.ganglia.GangliaContext
# mapred.class=org.apache.hadoop.metrics.ganglia.GangliaContext31
# mapred.period=10
# mapred.servers=localhost:8649
 
 
# Configuration of the "jvm" context for null
#jvm.class=org.apache.hadoop.metrics.spi.NullContext
 
# Configuration of the "jvm" context for file
#jvm.class=org.apache.hadoop.metrics.file.FileContext
#jvm.period=10
#jvm.fileName=/tmp/jvmmetrics.log
 
# Configuration of the "jvm" context for ganglia
# jvm.class=org.apache.hadoop.metrics.ganglia.GangliaContext
# jvm.class=org.apache.hadoop.metrics.ganglia.GangliaContext31
# jvm.period=10
# jvm.servers=localhost:8649
 
# Configuration of the "rpc" context for null
rpc.class=org.apache.hadoop.metrics.spi.NullContext
 
# Configuration of the "rpc" context for file
#rpc.class=org.apache.hadoop.metrics.file.FileContext
#rpc.period=10
#rpc.fileName=/tmp/rpcmetrics.log
 
# Configuration of the "rpc" context for ganglia
# rpc.class=org.apache.hadoop.metrics.ganglia.GangliaContext
# rpc.class=org.apache.hadoop.metrics.ganglia.GangliaContext31
# rpc.period=10
# rpc.servers=localhost:8649
 
 
# Configuration of the "ugi" context for null
ugi.class=org.apache.hadoop.metrics.spi.NullContext
 
# Configuration of the "ugi" context for file
#ugi.class=org.apache.hadoop.metrics.file.FileContext
#ugi.period=10
#ugi.fileName=/tmp/ugimetrics.log
 
# Configuration of the "ugi" context for ganglia
# ugi.class=org.apache.hadoop.metrics.ganglia.GangliaContext
# ugi.class=org.apache.hadoop.metrics.ganglia.GangliaContext31
# ugi.period=10
# ugi.servers=localhost:8649
hadoop-metrics2.properties文件配置如下:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
 
# syntax: [prefix].[source|sink].[instance].[options]
# See javadoc of package-info.java for org.apache.hadoop.metrics2 for details
 
##############一定要注释掉原来的这块,否则会监控不到#########
#*.sink.file.class=org.apache.hadoop.metrics2.sink.FileSink
# default sampling period, in seconds
#*.period=10
#############################################################
 
# The namenode-metrics.out will contain metrics from all context
#namenode.sink.file.filename=namenode-metrics.out
# Specifying a special sampling period for namenode:
#namenode.sink.*.period=8
 
#datanode.sink.file.filename=datanode-metrics.out
 
# the following example split metrics of different
# context to different sinks (in this case files)
#jobtracker.sink.file_jvm.context=jvm
#jobtracker.sink.file_jvm.filename=jobtracker-jvm-metrics.out
#jobtracker.sink.file_mapred.context=mapred
#jobtracker.sink.file_mapred.filename=jobtracker-mapred-metrics.out
 
#tasktracker.sink.file.filename=tasktracker-metrics.out
 
#maptask.sink.file.filename=maptask-metrics.out
 
#reducetask.sink.file.filename=reducetask-metrics.out
 
*.sink.ganglia.class=org.apache.hadoop.metrics2.sink.ganglia.GangliaSink31
*.sink.ganglia.period=10
 
*.sink.ganglia.slope=jvm.metrics.gcCount=zero,jvm.metrics.memHeapUsedM=both
*.sink.ganglia.dmax=jvm.metrics.threadsBlocked=70,jvm.metrics.memHeapUsedM=40
 
namenode.sink.ganglia.servers=master:8649
resourcemanager.sink.ganglia.servers=master:8649
 
datanode.sink.ganglia.servers=master:8649
nodemanager.sink.ganglia.servers=master:8649
 
 
maptask.sink.ganglia.servers=master:8649
reducetask.sink.ganglia.servers=master:8649
为了让ganglia监控hbase,需要配置hbase-0.96.0目录下的conf目录中的hadoop-metrics2-hbase.properties文件。内容如下:
# syntax: [prefix].[source|sink].[instance].[options]
# See javadoc of package-info.java for org.apache.hadoop.metrics2 for details
 
##############一定要注释掉原来的这块,否则会监控不到#########
#*.sink.file*.class=org.apache.hadoop.metrics2.sink.FileSink
# default sampling period
#*.period=10
#############################################################
 
# Below are some examples of sinks that could be used
# to monitor different hbase daemons.
 
# hbase.sink.file-all.class=org.apache.hadoop.metrics2.sink.FileSink
# hbase.sink.file-all.filename=all.metrics
 
# hbase.sink.file0.class=org.apache.hadoop.metrics2.sink.FileSink
# hbase.sink.file0.context=hmaster
# hbase.sink.file0.filename=master.metrics
 
# hbase.sink.file1.class=org.apache.hadoop.metrics2.sink.FileSink
# hbase.sink.file1.context=thrift-one
# hbase.sink.file1.filename=thrift-one.metrics
 
# hbase.sink.file2.class=org.apache.hadoop.metrics2.sink.FileSink
# hbase.sink.file2.context=thrift-two
# hbase.sink.file2.filename=thrift-one.metrics
 
# hbase.sink.file3.class=org.apache.hadoop.metrics2.sink.FileSink
# hbase.sink.file3.context=rest
# hbase.sink.file3.filename=rest.metrics
 
*.sink.ganglia.class=org.apache.hadoop.metrics2.sink.ganglia.GangliaSink31
*.sink.ganglia.period=10
 
hbase.sink.ganglia.period=10
hbase.sink.ganglia.servers=master:8649
 


2、监控mongoDB


1rpm -ivh ganglia-gmond-modules-python-3.6.0-1.x86_64.rpm 
2yum -y install python-simplejson
3、检查python模块是否被挂载
gmond -d10
 
4、在https://github.com/ganglia/gmond_python_modules地址下载mongoDB python插件
将如下两个文件拷贝到对应目录中
cp mongodb.conf /etc/ganglia/conf.d/mongodb.pyconf
cp mongodb.py /usr/lib64/ganglia/python_modules/mongodb.py
5、修改mongodb.pyconf
value = "mongo --quiet --eval 'printjson(db.serverStatus())'"
value = "mongo --quiet --eval 'printjson(rs.status())'"
Value中的mongo替换成该文件的绝对路径,当然你也可以不必修改mongodb.pyconf,保证mongodb/binPATH环境变量里就可(mongodb启动不使用27017的还要加-port xxxxx
6、修改mongodb.py,将import json改成import simplejson as json
7、重启gmond,service gmond restart
8、重启httpd,service httpd restart
 


3、监控Mysqlmariadb


1yum install MySQL-python
2cd /etc/ganlia/conf.d ; mv mysql.pyconf.disabled mysql.pyconf
3vi mysql.pyconf 编辑用户名和密码
4、重启gmond
5、重启httpd

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-215860-1-1.html 上篇帖子: 在CentOS上MySQL数据库服务器配置方法 下篇帖子: CentOS 5 安装和配置无线网卡指南
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表