Total Pageviews

Saturday 31 March 2012

Ganglia的安装与配置

第一步:下载所需套件
1)ganglia-3.1.11.tar.gz
wget [url]http://aayyooh.ucoz.com/ganglia3.1.11-install.tar.gz[/url]
第二步:安装所下载的软件
1)安装expat-2.0.1.tar.gz
tar xvzf expat-2.0.1.tar.gz
cd expat*;./configure --prefix=/usr/local/expat-2.0.1;make;make install
2)安装apr-1.3.2.tar.bz2
tar xvjf apr-1.3.2.tar.bz2
cd apr-1.3.2;./configure --prefix=/usr/local/apr-1.3.2;make;make install
3)安装apr-util-1.3.2.tar.bz2
tar xvjf apr-util-1.3.2.tar.bz2
cd apr-util-1.3.2;./configure --with-apr=/usr/local/apr --with-expat=/usr/local/expat(./configure --with-apr=/usr/local/apr-1.3.3 --with-expat=/usr/local/expat-2.0.1)
make;make install
cp /usr/local/apr/include/apr-1/* /usr/local/apr/include/目录,因为ganglia安装时默认会去/usr/local/apr/include下寻找apr的库文件。
 cp /usr/local/apr-1.3.3/include/apr-1/* /usr/local/apr-1.3.3/include/
cp /usr/local/apr/include/apr-1/* /usr/local/apr/include/
4)安装confuse-2.6
tar zxvf confuse-2.6.tar.gz
cd confuse-2.6;./configure --prefix=/usr/local/confuse-2.6;make;make install

5)安装rrdtool-1.2.27.tar.gz
tar xvzf rrdtool-1.2.27.tar.gz
cd rrdtool-1.2.27;./configure --prefix=/usr/local/rrdtool
make;make install
5)先在集群服务器管理节点(为了消除服务器单点故障,最好是在lvs服务器上)上安装ganglia-3.1.0.tar.gz
a)tar xvzf ganglia-3.1.0.tar.gz
b) ./configure --prefix=/Data/apps/ganglia-3.1.1 --with-librrd=/usr/local/rrdtool-* --with-libapr=/usr/local/apr --with-libexpat=/usr/local/expat-2.0.1 --with-libconfuse=/usr/local/confuse-2.6 --with-gmetad --enable-gexec --enable-status
c)make;make install
将gmond gmetad及相应启动脚本分别挎至/usr/sbin与/etc/init.d目录下
d)cp gmond/gmond /usr/sbin;cp gmond/gmond.init /etc/init.d/gmond;cp gmetad/gmetad /usr/sbin;cp gmetad/gmetad.init /etc/init.d/gmetad;  cp gmetad/gmetad.conf /etc/ganglia/;cp web web的DocumentRoot
e)让gmond.init与gmetad.init服务随机启动或者是修改heartbeat的haresources配置文件,让heartbeat来接管gmond.init与gmetad.init(但仅限是在lvs服务器上)
f)因为gmond与gmetad默认会去/etc/ganglia目录下找配置文件,所以
    11)mkdir /etc/ganglia;/Data/apps/ganglia-3.1.1/sbin/gmond  --default_config>/etc/ganglia/gmond.conf

    修改gmond.conf中如下内容(只修改下面内容即可,其它默认):
     cluster {
  name = "360quan"(同你在gmetad.conf配置文件中指定的集群名)
  owner = "360quan"(同上)
  latlong = "360quan"(同上)
  url = "360quan"(同上)
}
/* The host section describes attributes of the host, like the location */
host {
  location = "$hostname"(你你所在节点主机名)
}
   更改/etc/ganglia/gmetad.conf 中的data─source
这行,使其适合你自己的集群环境。如下
data_source "360quan" localhost 60.28.208.*
"360quan"是指集群名(可以任意,但gmond.conf文件中集群名需与此一致),后面参数是指你集群节点的ip地址也可以是主机名
22)创建/var/lib/ganglia/rrds目录,gmond会将监测到的节点信息放至此目录
{     f)将源代码下的web目录挎至apache2根目录下,修改conf.php配置文件,只更改下面内容即可
# Where gmetad stores the rrd archives.
$gmetad_root = "/var/lib/ganglia";
$rrds = "$gmetad_root/rrds";
# Leave this alone if rrdtool is installed in $gmetad_root,
# otherwise, change it if it is installed elsewhere (like /usr/bin)
define("RRDTOOL", "/usr/bin/rrdtool");
}  这步操作可以不做


6)在集群服务器内的节点上安装ganglia-3.1.tar.gz
a)tar xvzf ganglia-3.1.0.tar.gz
b)./configure \
--prefix=/usr/local/ganglia --with-librrd=/usr/local/rrdtool \
--with-libapr=/usr/local/apr --with-libexpat=/usr/local/expat \
--with-libconfuse=/usr/local/confuse --enable-gexec  \
--enable-status
(./configure --prefix=/Data/apps/ganglia-3.1.1 --with-librrd=/usr/local/rrdtool-1.0.50 --with-libapr=/usr/local/apr-1.3.3 --with-libexpat=/usr/local/expat-2.0.1 --with-libconfuse=/usr/local/confuse-2.6 --enable-gexec)

(注意:少了--with-gmetad选项,gmetad服务程序只是在集群节点管理器是必须的,它主要功能是轮询gmond程序,统计gmond检测到的集群节点信息,结合rrdtool函数库以便管理员能够以web方式直观的检测节点的相关信息。
c)make;make install
其它安装方法同上,不重复
7) 先启动集群节点的gmond.init程序,检查8649端口是否启动,然后再启动集群节点管理器上的gmond.init与gmetad.init 程序,检查8649与8651/8652端口是否启动。如果一切正常,现在你你可以通过web方式检测集群节点的相关信息了。

***************
安装后不显示图形

如果你在RHEL 4以上版本安装Ganglia那么就是SELinux在作怪,可以关闭SELinux
或者执行以下步骤:

vi /etc/selinux/targeted/contexts/files/file_contexts
添加:
/var/lib/ganglia/rrds(/.*)?     system_u:object_r:httpd_sys_script_exec_t
保存退出
执行:setfiles /etc/selinux/targeted/contexts/files/file_contexts /var/lib/ganglia/rrds/
如果还有问题
vi /$web'DocumentRoot/web/conf.php
将define("RRDTOOL", "/usr/local/bin/rrdtool"); 修改成自己的rrdtool路径

No comments:

Post a Comment