红联Linux门户
Linux帮助

CentOS 6.4 minimal初始安装后再安装Ganglia

发布时间:2015-04-19 16:13:41来源:linux网站作者:linux人

说明

ganglia项目用于集群监控真的很好用,可惜安装起来依赖太多了。

以下是以CentOS6.4的minimal系统为初始环境,并且是原汁原味的刚刚装完系统后,只启用网卡服务的系统作为ganglia的安装环境,


一、安装服务端
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 perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker make rsync wget
2、安装apache的组件
安装apr-1.4.6
wget http://apache.etoak.com//apr/apr-1.4.6.tar.gz
tar -xf apr-1.4.6.tar.gz && cd apr-1.4.6
./configure --prefix=/usr/local/apr && make && make install && cd ..
安装apr-util-1.5.2
wget http://apache.etoak.com//apr/apr-util-1.5.2.tar.gz
tar -xf apr-util-1.5.2.tar.gz && cd apr-util-1.5.2
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install && cd ..
安装httpd-2.2.24
wget http://mirror.esocc.com/apache//httpd/httpd-2.2.24.tar.gz
tar -xf httpd-2.2.24.tar.gz && cd httpd-2.2.24
./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most --with-included-apr --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util && make && make install && cd ..
#将httpd写入启动脚本并启动(可选)
echo '/usr/local/apache2/bin/apachectl start' >>/etc/rc.d/rc.local && /usr/local/apache2/bin/apachectl start
3、安装和配置php
安装
wget http://www.php.net/get/php-5.3.18.tar.gz/from/cn2.php.net/mirror
tar -xf php-5.3.18.tar.gz && cd php-5.3.18
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs && make && make install && cd ..
在httpd中配置php
修改/usr/local/apache2/conf/httpd.conf配置文件
添加内容
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
修改内容
在<IfModule dir_module>中添加index.php
4、安装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-*
5、安装pcre
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz
tar -xf pcre-8.31.tar.gz && cd pcre-8.31
./configure && make && make install && cd ..
echo '/usr/local/lib' >/etc/ld.so.conf.d/libpcre.conf && ldconfig -v
6、安装rrdtool
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz
tar -xf rrdtool-1.4.7.tar.gz && cd rrdtool-1.4.7
./configure --prefix=/usr/local && make && make install && cd ..
echo '/usr/local/lib' >/etc/ld.so.conf.d/librrd.conf && ldconfig -v
7、安装ganglia后台服务并设置
安装
wget http://sourceforge.net/projects/ganglia/files/ganglia%20monitoring%20core/3.4.0/ganglia-3.4.0.tar.gz/download
tar -xf ganglia-3.4.0.tar.gz && cd ganglia-3.4.0
./configure --prefix=/usr/local/ganglia --with-gmetad --with-librrd=/usr/local/lib --sysconfdir=/etc/ganglia && make && make install && cd ..
将gmond和gmetad作为服务运行,并加入开机服务启动中(可选)
复制到服务,并设开机启动
cp ganglia-3.4.0/gmond/gmond.init /etc/rc.d/init.d/gmond
cp ganglia-3.4.0/gmetad/gmetad.init /etc/rc.d/init.d/gmetad
chkconfig --add gmond && chkconfig gmond on
chkconfig --add gmetad && chkconfig gmetad on
修改服务配置信息
修改/etc/rc.d/init.d/gmetad文件将GMETAD变量改为:GMETAD=/usr/local/ganglia/sbin/gmetad
和/etc/rc.d/init.d/gmond文件将GMOND变量改为:GMOND=/usr/local/ganglia/sbin/gmond
设置rrd的存储位置
mkdir -p /var/lib/ganglia/rrds
chown nobody:nobody /var/lib/ganglia/rrds
生成gmond的配置文件并修改配置信息(可选)
/usr/local/ganglia/sbin/gmond -t |tee /etc/ganglia/gmond.conf
修改cluster配置段内容,例如: name = "Cluster"。可以默认不修改
修改gmetad的配置信息(可选)
修改/etc/ganglia/gmetad.conf配置文件
把data_source配置名称以及服务器名称修改为自己的。可以默认
把gridname前的注释放开,改为自己的名称,例如:"cluster"。可以默认
8、安装ganglia的web端以及设置
下载和解压
wget http://sourceforge.net/projects/ganglia/files/ganglia-web/3.5.4/ganglia-web-3.5.4.tar.gz/download
tar -xf ganglia-web-3.5.4.tar.gz
cp -r ganglia-web-3.5.4 /usr/local/apache2/htdocs/ganglia
修改Makefile文件并安装
cd /usr/local/apache2/htdocs/ganglia
修改Makefile中GDESTDIR和APACHE_USER参数,然后执行make install安装
GDESTDIR=/usr/local/apache2/htdocs/ganglia
APACHE_USER=daemon
make install
修改php配置文件
cp conf_default.php conf.php
修改conf.php文件
如果设置rrd的存储位置的时候是按照上文设置的话,就可以跳过对$conf['gmetad_root']和$conf['rrds']的修改,否则改为相应位置
$conf['rrdtool'] = "/usr/local/bin/rrdtool";
$conf['external_location'] = http://localhost/ganglia;
$conf['case_sensitive_hostnames'] = false;
9、启动ganglia
启动或重启httpd
/usr/local/apache2/bin/apachectl start
启动gmetad
service gmetad start
启动gmond
service gmond start


二、安装客户端
1、安装依赖
yum -y install apr-devel apr-util
2、安装libconfuse相关
同服务端
3、安装pcre
同服务端
4、安装和配置ganglia
安装
tar -xf ganglia-3.4.0.tar.gz && cd ganglia-3.4.0
./configure --prefix=/usr/local/ganglia --sysconfdir=/etc/ganglia && make && make install && cd ..
配置
复制服务端配置
scp ip:/etc/rc.d/init.d/gmond /etc/rc.d/init.d/gmond
mkdir /etc/ganglia
scp ip:/etc/ganglia/gmond.conf /etc/ganglia
把gmond加入服务并开机启动
cp ganglia-3.4.0/gmond/gmond.init /etc/rc.d/init.d/gmond
chkconfig --add gmond && chkconfig gmond on
5、启动ganglia客户端
/etc/init.d/gmond start


三、特殊要求
如果你的服务器有两块网卡,eth0使用公网地址,eth1使用局域网地址,而你的监控服务器和被监控服务器之间的通信你希望通过局域网地址实现以减少公网网卡的负载,那么可以使用以下命令
ip route add 239.2.11.71 dev eth1
因为239.2.11.71是ganglia默认的多点传输通道,所以要加一条路由使它通过eth1,也就是内网网卡,239.2.11.71这个地址你可以在/etc/ganglia/gmond.conf中修改。