以前安装过ganglia的监控,过程比较复杂,最近在新的集群环境下部署了监控,这里做个笔记。
ganglia监控的架构图如下,相关的原理这里不多说了。
./configure --with-gmetad --sysconfdir=/etc/ganglia
make -j8
make install
2) mkdir -p /var/www/html/ganglia/ # make sure you have apache installed
3) cp -a web/* /var/www/html/ganglia/ # this is the web interface
4) cp gmetad/gmetad.init /etc/rc.d/init.d/gmetad # startup script
5) cp gmond/gmond.init /etc/rc.d/init.d/gmond
6) mkdir /etc/ganglia # where config files go,if existing ,no making
7) gmond -t | tee /etc/ganglia/gmond.conf # generate initial gmond config,if existing ,no making
8) cp gmetad/gmetad.conf /etc/ganglia/ # initial gmetad configuration
9) mkdir -p /var/lib/ganglia/rrds # place where RRDTool graphs will be stored
10) chown nobody:nobody /var/lib/ganglia/rrds # make sure RRDTool can write here.
11) chkconfig --add gmetad # make sure gmetad starts up at boot time
gmond的配置:
cluster {
name = "my cluster"
owner = "nobody"
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
#mcast_join = 192.168.1.59
#host=192.168.1.59
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
#port = 8649
bind = 239.2.11.71
}
/* You can specify as many tcp_accept_channels as you like to share
an xml description of the state of the cluster */
tcp_accept_channel {
port = 8649
}
gmetad的配置:
rrd_rootdir "/var/lib/ganglia/rrds"
data_source "my cluster" 5 192.168.1.17:8649
4、安装apache
sudo yum –y install apr-util-devel apr-devel apr-util
wget http://labs.renren.com/apache-mirror/httpd/httpd-2.0.64.tar.gz
tar –zxvf httpd-2.0.64 .tar.gz
cd httpd-2.0.64
./configure --prefix=/usr/local/apache2 --enable-modules=so --enable-rewrite
make
sudo make install
配置Apache服务的httpd.conf文件
*在LoadModule处添加 LoadModule php5_module module/libphp5.so
*在DirectoryIndex处添加 index.php
*在AddType application处添加
AddType application/x-httpd-php .php .phtml
AddType applicatoin/x-httpd-php-source .phps
<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>
LoadModule php5_module modules/libphp5.so
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
cd /usr/local/apache2/htdocs
mkdir ganglia
cd ganglia
cp -a /var/www/html/ganglia/* .
5、安装PHP5
#安装php5的依赖
sudo yum –y install freetype-devel libjpeg-turbo-devel libpng-devel GD-devel libxml2-devel
wget http://cn.php.net/get/php-5.3.6.tar.gz/from/this/mirror
tar –zxvf php-5.3.6.tar.gz
cd php-5.3.6
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/lib --with-mysql=/usr/local/mysql
make
cp -p .libs/libphp5.so /usr/local/apache2/modules
#sudo chown cdh:cdh /usr/local/apache2/modules/libphp5.so
#复制php5配置文件
sudo cp php.ini-development/usr/local/php/lib/php/php.ini
sudo make install
vi /usr/local/php/lib/php/php.ini
output_buffering = On
date.timezone = Asia/Chongqing