安装Ganglia


Ganglia由gmond、gmetad和gweb三部分组成

gmond(Ganglia Monitoring Daemon)是一种轻量级服务,安装在每台需要收集指标数据的节点主机上。gmond在每台主机上完成实际意义上的指标数据收集工作,并通过侦听/通告协议和集群内其他节点共享数据。使用gmond,你可以很容易收集很多系统指标数据,如CPU、内存、磁盘、网络和活跃进程的数据等。

gmetad(Ganglia Meta Daemon)是一种从其他gmetad或gmond源收集指标数据,并将其以RRD格式存储至磁盘的服务。gmetad为从主机组收集的特定指标信息提供了简单的查询机制,并支持分级授权,使得创建联合监测域成为可能。

gweb(Ganglia Web)gweb是一种利用浏览器显示gmetad所存储数据的PHP前端。在Web界面中以图表方式展现集群的运行状态下收集的多种不同指标数据。 

准备环境

# lsb_release -a
LSB Version::base-4.0-amd64:base-4.0-noarch: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:CentOS
Description:CentOS release 6.5 (Final)
Release:6.5
Codename:Final

S1、安装gmond

在本地软件库中搜索gmond安装包
[root@stonex ~]# yum search ganglia-gmond
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
Warning: No matches found for: ganglia-gmond
No Matches found

显示搜索失败,可能是当前RPM发行版中没有Ganglia安装包。

[root@stonex ~]# rpm -Uvh \
> http://dl.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.L2dC50: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
[root@stonex ~]#

再搜索(首次执行会下载epel/primary_db)
[root@stonex ~]# yum search ganglia-gmond
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
省略了一些行......
ganglia-gmond.x86_64 : Ganglia Monitoring daemon
ganglia-gmond-python.x86_64 : Ganglia Monitor daemon python DSO and metric modules
省略了一些行......
[root@stonex ~]#

安装
[root@stonex ~]# yum install ganglia-gmond -y
yum安装会自动解决头疼的依赖包问题

S2、安装gmetad

和gmond安装中介绍的相同,如果本地软件库不提供gmetad,那么需要安装EPEL。
[root@stonex ~]# yum install ganglia-gmetad -y
会发现安装了以下依赖包:
Dependency Installed:
dejavu-fonts-common.noarch 0:2.30-2.el6 dejavu-lgc-sans-mono-fonts.noarch 0:2.30-2.el6 dejavu-sans-mono-fonts.noarch 0:2.30-2.el6 fontpackages-filesystem.noarch 0:1.41-1.1.el6 rrdtool.x86_64 0:1.3.8-6.el6

S3、安装gweb

Wiki:http://sourceforge.net/apps/trac/ganglia/wiki/ganglia-web-2#Installation


在进行gweb的安装和配置前,请先检查是否已经
满足下面需求:
Apache Web Server
PHP 5.2及更新版本
PHP JSON 扩展的安装和启用

首先安装Apache和PHP 5
[root@stonex ~]# yum install httpd php
会发现安装了以下依赖包:
Dependency Installed:
apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 httpd-tools.x86_64 0:2.2.15-29.el6.centos mailcap.noarch 0:2.1.31-2.el6 php-cli.x86_64 0:5.3.3-27.el6_5 php-common.x86_64 0:5.3.3-27.el6_5

需要启用PHP的JSON扩展,JSON已经包含在PHP 5.2及更新版本中。
通过检查/etc/php.d/json.ini文件来检查JSON扩展的状态,如果已经启用JSON扩展,在该文件中应该包含类似下面语句的内容:
extension=json.ini

下载最新版本的gweb(https://sourceforge.net/projects/ganglia/files/gweb/)
本示例当前最新版本为3.5.12
[root@stonex ~]# wget http://ncu.dl.sourceforge.net/project/ganglia/ganglia-web/3.5.12/ganglia-web-3.5.12.tar.gz
[root@stonex down]# tar -zxvf ganglia-web-3.5.12.tar.gz
[root@stonex down]# cd ganglia-web-3.5.12

编译Makefile
[root@stonex ganglia-web-3.5.12]# 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
##########################################################

修改默认配置:
GDESTDIR = /var/www/html/ganglia2
APACHE_USER = apache
注意:GDESTDIR 和 APACHE_USER 要与APACHE的配置文件(/etc/httpd/conf/httpd.conf)中的 DocumentRoot 、 apache保持一致

S4、状态检查

检查httpd是否启动:
[root@stonex ~]# service httpd status
启动httpd:
[root@stonex ~]# service httpd start

检查gmetad是否启动:
[root@stonex ~]# service gmetad status
启动gmetad:
[root@stonex ~]# service gmetad start

检查本地gmond是否启动:
[root@stonex ~]# service gmond status
启动gmond:
[root@stonex ~]# service gmond start

S5、关闭SELinux

如果你跳过这一步,打开http://<server ip address>/ganglia2会出现以下异常:
There was an error collecting ganglia data (127.0.0.1:8652): fsockopen error: Permission denied

SELinux是什么?
http://wiki.centos.org/zh/HowTos/SELinux

查看SELinux状态:
[root@stonex ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: permissive
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted

关闭SELinux:
[root@stonex ~]# setenforce 0
setenforce 这个指令可以即时切换 Enforcing 及 Permissive 这两个模式,但这些改动在系统重新开机时不会被保留。
要想在下次开机后生效,需要在 /etc/selinux/config 内修改 SELINUX= 这一行为 enforcing。

S6、访问Ganglia监控平台

http://<server ip address>/ganglia2/

目录“/ganglia2”可以在 ganglia-web的Makefile文件中GDESTDIR被修改,修改后需要重新编译

(完)

相关内容