资源描述
ganglia安装配置
一、 基本环境
apache+php+mysql
yum install httpd httpd-devel php*
二、 安装ganglia
1.ganglia相关依赖包
1. yum install rrdtool rrdtool-devel
2. libconfuse:
rpm安装:
官方网站下载失败,下载了版本稍旧一点rpm包:http://pkgs.repoforge.org/libconfuse/
wget http://pkgs.repoforge.org/libconfuse/libconfuse-2.6-2.el5.rf.x86_64.rpm
wget http://pkgs.repoforge.org/libconfuse/libconfuse-devel-2.6-2.el5.rf.x86_64.rpm
rpm -ivh libconfuse-*
源码安装:
wget http://savannah.nongnu.org/download/confuse/confuse-2.7.tar.gz
tar zxvf confuse-2.7.tar.gz
cd confuse-2.7
./configure CFLAGS=-fPIC --disable-nls
make && make install
调整lib库的位置:
echo /usr/local/lib > /etc/ld.so.conf.d/libconfuse.conf
ldconfig -v
3. yum install pcre*
4. yum install expat*
5. 其他依赖
yum 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 make*
2.安装ganglia管理端(gmetad)
wget
tar zxvf ganglia-3.5.0.tar.gz
cd ganglia-3.5.0
./configure --prefix=/usr/local/ganglia --with-librrd --with-libapr --with-libexpat --with-libconfuse --with-gmetad --enable-gexec --enable-status
make
make install
为rrdtool创建数据存放目录
mkdir -p /var/lib/ganglia/rrds
chown -R nobody:nobody /var/lib/ganglia/rrds
将gmetad添加到系统服务
cp {ganglia解压目录}gmetad/gmetad.init /etc/init.d/gmetad
将gmetad命令加入到/usr/sbin/目录
cp /usr/local/ganglia/sbin/gmetad /usr/sbin/
gmetad给 chkconfig托管
chkconfig --add gmetad
开启gmetad服务
service gmetad start
Starting GANGLIA gmetad: [ OK ]
见到[OK]字样说明启动成功。
3. 安装ganglia节点(gmond)ps:主控端也需要安装
依赖:yum install prce* expat* apr-devel apr-util check-devel cairo-devel pango-devel libxml2-devel rpmbuild glib2-devel dbus-devel freetype-devel fontconfig-devel gcc-c++ python-devel libXrender-devel
安装libconfuse
rpm安装:
官方网站下载失败,下载了版本稍旧一点rpm包:http://pkgs.repoforge.org/libconfuse/
wget http://pkgs.repoforge.org/libconfuse/libconfuse-2.6-2.el5.rf.x86_64.rpm
wget http://pkgs.repoforge.org/libconfuse/libconfuse-devel-2.6-2.el5.rf.x86_64.rpm
rpm -ivh libconfuse-*
wget
(1) 解压同gmetad
(2) ./configure --prefix=/usr/local/ganglia --with-librrd --with-libapr --with-libexpat --with-libconfuse --enable-gexec --enable-status --sysconfdir=/etc/ganglia
./configure --prefix=/usr/local/ganglia --sysconfdir=/etc/ganglia
(3) make && make install
(4) 将gmond加入系统服务{ganglia解压目录}
cp gmond/gmond.init /etc/init.d/gmond
(5) 将gmond命令加入到/usr/sbin/目录
cp /usr/local/ganglia/sbin/gmond /usr/sbin/
(9) 生成gmond的默认配置文件
mkdir /etc/ganglia
/usr/local/ganglia/sbin/gmond -t |tee /etc/ganglia/gmond.conf
(10) 将gmond给 chkconfig托管
chkconfig --add gmond
(11) 修改gmond配置文件/etc/ganglia/gmond.conf
cluster {
name = "test cluster"
owner = "nobody"
latlong = "unspecified"
url = "unspecified"
}
(12) 开启gmond服务
service gmond start
Starting GANGLIA gmetad: [ OK ]
(6) 见到[OK]字样说明启动成功。
4. 安装ganglia web页面
4.2. 构建web服务器
wget
tar -xf ganglia-web-3.5.4.tar.gz
cp -r ganglia-web-3.5.4 /{apache:wwwroot}/ganglia
cd /{apache:wwwroot}/ganglia
vim Makefile,修改参数GDESTDIR和APACHE_USER,然后执行make install进行安装:
GDESTDIR=/usr/local/apache2/htdocs/ganglia
APACHE_USER=daemon
make install
cp conf_default.php conf.php
vim conf.php,修改如下参数:
$conf['gmetad_root'] = "/var/lib/ganglia";
$conf['rrds'] = "${conf['gmetad_root']}/rrds";
$conf['rrdtool'] = "/usr/local/bin/rrdtool";
$conf['external_location'] = "http://SERVER:10000/ganglia"; //把SERVER替换成自己的g
$conf['case_sensitive_hostnames'] = false;
禁用 SELinux
setenforce 0
启动并访问:
service gmetad start
service gmond start
http://SERVER/ganglia/ //把SERVER替换成自己的ganglia服务器IP
三. 集群式部署
集群的部署依靠配置文件:
vim /usr/local/ganglia/etc/gmetad.conf
这里需要配置的是集群名称和server端地址
data_source "my cluster" localhost
? /etc/ganglia/gmond.conf
这里需要配置cluster下的name和owner属性与gmetad端一致
cluster {
name = "my cluster"
owner = "nobody"
latlong = "unspecified"
url = "unspecified"
}
? 如果修改owner,同时也要修改Rrdtool的数据文件目录的owner:
chown -R nobody:nobody /var/lib/ganglia/rrds
四.添加apache监控插件(客户端)
1.下载插件
插件下载:
git clone git:// apache_status
cp apache_status/conf.d/apache_status.conf /etc/ganglia/conf.d/
cp -R apache_status/python_modules /etc/ganglia/
2.修改apache_status地址
vim /etc/ganglia/conf.d/apache_status.conf
modules {
module {
name = "apache_status"
language = "python"
param url {
value = "http://192.168.126.142/server-status?auto" #指向本机ip。
}
param virtual_host {
value = "health"
}
}
}
3.修改modpython.conf配置
vim /etc/ganglia/conf.d/modpython.conf
modules {
module {
name = "python_module"
path = "modpython.so"
params = "/etc/ganglia/python_modules"#指向上面拷贝到/etc/ganglia/下的python_modules目录
}
}
4.重启service gmond restart
5.效果如下
点击某个节点的详细监控信息页面:
6.集群apache监控
如果需要看整个集群的监控画面,则需要做一些配置,如下:
修改/var/www/html/ganglia/conf.php,找到 $optional_graphs,去掉注释,修改为 $optional_graphs = array(' apache'),保存,刷新监控页面即可看到监控图。
五.安装过程中遇到的问题
1 安装rrdtool过程中提示pkg-config错误
一般是库没有装全,记得要安装dev库
2 安装ganglia过程中找不到confuse,expat,apr等库
如果是64位机,ganglia会在依赖库的lib64目录下去查找文件,所以需要将lib目录下文件拷贝到lib64目录下
3 gmetad启动失败:
查看gmetad状态:service gmetad status
gmetad dead but subsys locked
在gmetad.conf中修改了用户
setuid_username "root" 这里需要username和rrd数据目录的owner一致
4 gmond启动失败:
查看gmond状态:service gmond status
gmond dead but subsys locked
可能是没有配置网关或者cluster的owner配置有问题
5 访问网页保错:
Ganglia cannot find a data source. Is gmond running?
There was an error collecting ganglia data XML error : Invalid document
现象是页面只有一行错误信息
解决办法是修改conf.php中的$ganglia_ip = "127.0.0.1";这里不能使用机器的ip,原因还不清楚。
6 图片无法显示:
一般是php-gd没有安装或者/var/www/html/ganglia/conf.php中rrdtool的配置有问题
7 访问网页保错Forbidden,You don’t have permission to access /ganglia/ on this server
是SELinux没有禁用
8.ganglia web页面每个节点显示别名(如图)
修改ganglia主控端的hosts文件
vim /ets/hosts
格式:ip hostname
例如:
192.168.19.9 lvs-1
192.168.19.10 lvs-2
展开阅读全文