当前位置: 首页 > 工具软件 > Ganglia > 使用案例 >

Ganglia安装部署教程

萧业
2023-12-01

Ganglia安装部署教程

一、简介

Ganglia的组成
Ganglia监控系统有三部分组成,分别是gmond、gmetad、webfrontend,作用如下。

  • gmond: 即为ganglia monitoring daemon,是一个守护进程,运行在每一个需要监测的节点上,用于收集本节点的信息并发送到其他节点,同时也接收其他节点发过了的数据,默认的监听端口为8649。

  • gmetad: 即为ganglia meta daemon,是一个守护进程,运行在一个数据汇聚节点上,定期检查每个监测节点的gmond进程并从那里获取数据,然后将数据指标存储在本地RRD存储引擎中。

  • webfrontend: 是一个基于web的图形化监控界面,需要和Gmetad安装在同一个节点上,它从gmetad取数据,并且读取RRD数据库,通过rrdtool生成图表,用于前台展示,界面美观、丰富,功能强大

    一个Ganglia监控系统是由多个gmond进程和一个主gmetad进程组成,所有gmond进程将收集到的监控数据汇总到gmetad管理端,而gmetad将数据存储到RRD数据库中,最后通过PHP程序在Web界面进行展示。

二、安装

Ganglia的安装分为两个部分,分别是gmetad和gmond,gmetad安装在监控管理端,gmond安装在需要监控的客户端主机,对应的yum包名称分别为ganglia-gmetad和ganglia-gmond。

1.安装依赖和环境

所有主机(包括监控管理端和要监控的主机)

sudo yum -y install httpd php

sudo yum -y install rrdtool perl-rrdtool rrdtool-devel
sudo yum -y install apr-devel

yum -y install epel-release #安装epel源

2.安装ganglia

2.1yum安装(自动安装依赖)

#监控管理端
sudo yum -y install ganglia-gmetad 

#在需要监控的客户端主机
sudo yum install -y ganglia-gmond

#安装为web服务的节点
sudo yum -y install ganglia-web


安装部署情况

主中心 clu201: gmetad、gmond、ganglia-web

分中心clu202:gmond

2.2源码安装(自己编译配置)

分布式监控数据采集系统Ganglia实战 - 夫莱特 - 博客园 (cnblogs.com)

接着安装ganglia的依赖程序,首选是apr,可从http://apr.apache.org/download.cgi 网站下载,编译安装如下:

cd /public/software/

[root@monitor ~]#tar zxvf apr-1.7.0.tar.gz
[root@monitor ~]#cd apr-1.7.0/
[root@monitor apr-1.6.3]#./configure
[root@monitor apr-1.6.3]#make
[root@monitor apr-1.6.3]#make install

接着是confuse的安装,可从http://ftp.twaren.net/Unix/NonGNU/confuse/ 下载,操作过程如下:

[root@monitor ~]#tar zxvf confuse-2.7.tar.gz
[root@monitor ~]#cd confuse-2.7
[root@monitor confuse-2.7]#./configure CFLAGS=-fPIC --disable-nls
[root@monitor confuse-2.7]#make && make install

最后进入ganglia-gmetad的安装,过程如下:

[root@monitor ~]#tar zxvf ganglia-3.7.2.tar.gz
[root@monitor ~]#cd ganglia-3.7.2
[root@monitor ganglia-3.7.2]# ./configure --prefix=/opt/app/ganglia --with-static-modules --enable-gexec --enable-status --with-gmetad --with-python=/usr --with-libexpat=/usr --with-libconfuse=/usr/local --with-libpcre=/usr/local
[root@monitor ganglia-3.7.2]#make
[root@monitor ganglia-3.7.2]# make install
[root@monitor gmetad]# mkdir -p /opt/app/ganglia/var/run
[root@monitor gmetad]# systemctl  enable gmetad

至此,ganglia-gmetad安装完成。

下面介绍Ganglia客户端的安装过程,ganglig-gmond的安装与ganglia-gmetad大致相同,对于系统依赖包和基础软件包的安装完全相同,只是ganglig-gmond不需要rrdtool的支持,因此重点讲述ganglig-gmond的编译安装过程。

[root@node1 ~]#tar zxvf ganglia-3.7.2.tar.gz
[root@node1 ~]#cd ganglia-3.7.2
[root@node1 ganglia-3.7.2]#./configure --prefix=/opt/app/ganglia --enable-gexec
#成功会出现ganglia字样
[root@node1 ganglia-3.7.2]#make
[root@node1 ganglia-3.7.2]#make install
[root@node1 gmond]#cd gmond
[root@node1 gmond]#./gmond -t > /opt/app/ganglia/etc/gmond.conf
[root@node1 gmond]#mkdir -p /opt/app/ganglia/var/run
[root@node1 gmond]# systemctl  enable  gmond

到这里为止,ganglig-gmond安装完成。

3.配置

3.1 在Web服务节点和监控端(clu201)

vim /etc/httpd/conf.d/ganglia.conf  

修改内容如下:

# Ganglia monitoring system php web frontend
#Alias /ganglia /usr/share/ganglia
<Location /ganglia>  
	Order deny,allow  
 	#Deny from all  
 	Allow from all  
 	#Allow from 127.0.0.1  
 	#Allow from ::1  
 	# Allow from .example.com
 </Location>
vim /etc/ganglia/gmetad.conf

修改内容如下:

data_source "mccps" clu201 clu202
#data_source "集群名字" 节点域名或ip
vim /etc/ganglia/gmond.conf

修改内容如下:

/*
 * The cluster attributes specified will be used as part of the <CLUSTER>
 * tag that will wrap all hosts collected by this instance.
 */
cluster {
  name = "mccps"		#与前面配置中的集群名一致
  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 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=10.3.1.201		#绑定监控客户端的主机IP(clu201)
  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 = 10.3.1.201		#绑定监控客户端的主机IP(clu201)
  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
}

3.2 在普通被监控的主机上(clu202)

vim /etc/ganglia/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
  host = 10.3.1.201		#发送到监控端的IP
  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
}

4.启动服务

主节点:
(base) [root@clu201 ~]# systemctl start httpd
(base) [root@clu201 ~]# systemctl start gmetad
(base) [root@clu201 ~]# systemctl start gmond


子节点
[root@clu202 mca]# systemctl start gmond

5.访问测试

http://10.3.1.201/ganglia/

监控端的IP

(默认浏览器的端口用80,与httpd服务的端口有关)

问题:

1.安装ganglia后,访问浏览器出现"You don’t have permission to access /ganglia/ on this server"

修改/etc/httpd/conf.d/ganglia.conf

最后注释了上面的这些规则,添加了“ Require all granted”后,重启httpd问题解决。

vim  /etc/httpd/conf.d/ganglia.conf   ## Ganglia monitoring system php web frontend#Alias /ganglia /usr/share/ganglia<Location /ganglia>  #Order deny,allow  #Deny from all  #Allow from all  #Allow from 127.0.0.1  #Allow from ::1  # Allow from.example.com  Require all granted</Location>

2.能打开网页,但是不显示任何节点的信息

解决方法:
关闭防火墙!!!
或者配置规则,开放8694等端口。尤其是主中心,要接收各个子中心信息,

3.看不到子节点的信息

systemctl start gmond 启动成功,但是状态发送失败

主从节点的启动顺序问题,要先启动主节点的gmetad和gmond,再启动子节点的gmond

参考教程

高可用Hadoop平台-Ganglia安装部署 - 哥不是小萝莉 - 博客园 (cnblogs.com)

配置文件的详细说明:

分布式监控数据采集系统Ganglia实战 - 夫莱特 - 博客园 (cnblogs.com)

 类似资料: