集群监视软件Ganglia安装配置

参考资料
http://www.ibm.com/developerworks/cn/linux/l-ganglia-nagios-1/
http://blog.csdn.net/tobeabetterman_he/archive/2006/12/13/1441516.aspx
http://aix.chinaunix.net/doc/2008/05/06/1108706.shtml
可选包
wget http://oss.oetiker.ch/rrdtool/pub/libs/pango-1.17.5.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/glib-2.12.13.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/cairo-1.4.10.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/libpng-1.2.10.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/fontconfig-2.4.2.tar.gz
安装APR
wget [url=ftp://mirror.switch.ch/pool/1/mirror/scientificlinux/5rolling/x86_64/SL/apr-util-1.2.7-11.el5_5.2.x86_64.rpm]ftp://mirror.switch.ch/pool/1/mirror/scientificlinux/5rolling/x86_64/SL/apr-util-1.2.7-11.el5_5.2.x86_64.rpm[/url]
wget [url=ftp://mirror.switch.ch/pool/1/mirror/scientificlinux/5rolling/x86_64/SL/apr-devel-1.2.7-11.el5_5.3.x86_64.rpm]ftp://mirror.switch.ch/pool/1/mirror/scientificlinux/5rolling/x86_64/SL/apr-devel-1.2.7-11.el5_5.3.x86_64.rpm[/url]
rpm -ivh apr-devel-1.2.7-11.el5_5.3.x86_64.rpm apr-util-1.2.7-11.el5_5.2.x86_64.rpm
wget [url=ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/fedora/linux/releases/9/Everything/x86_64.newkey/os/Packages/libconfuse-2.6-1.fc9.x86_64.rpm]ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/fedora/linux/releases/9/Everything/x86_64.newkey/os/Packages/libconfuse-2.6-1.fc9.x86_64.rpm[/url]
[url=ftp://ftp.isu.edu.tw/pub/Linux/Fedora/linux/development/x86_64/os/Packages/libconfuse-devel-2.6-1.fc9.x86_64.rpm]ftp://ftp.isu.edu.tw/pub/Linux/Fedora/linux/development/x86_64/os/Packages/libconfuse-devel-2.6-1.fc9.x86_64.rpm[/url]
rpm -ivh libconfuse-devel-2.6-1.fc9.x86_64.rpm libconfuse-2.6-1.fc9.x86_64.rpm
安装软件 rrdtool-1.0.49 
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool.tar.gz
tar zvxf rrdtool.tar.gz ; cd rrdtool-1.4.5/ ;./configure --prefix=/usr/local/rrdtool ;make -j8;make install
which rrdtool
ldconfig
wget http://sourceforge.net/projects/ganglia/files/ganglia%20monitoring%20core/3.1.7/ganglia-3.1.7.tar.gz/download
tar -zvxf ganglia-3.1.7.tar.gz 
cd ganglia-3.1.7;./configure CFLAGS="-I/usr/local/rrdtool/include" CPPFLAGS="-I/usr/local/rrdtool/include" LDFLAGS="-L/usr/local/rrdtool/lib"  --with-gmetad --enable-gexec --sysconfdir=/etc/ganglia;make -j8;make install
php安装:
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
./configure --prefix=/usr/local;make;make install
http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download
./configure;make;make install
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
./configure;make;make install
cd ../
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
http://vps.googlecode.com/files/mcrypt-2.6.8.tar.gz
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure;make;make install
cd ../
http://www.php.net/get/php-5.2.17.tar.gz/from/cn.php.net/mirror
http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
tar zxvf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
cd php-5.2.17/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc  --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
make ZEND_EXTRA_LIBS='-liconv';make install
cp php.ini-dist /usr/local/php/etc/php.ini
cd ../
nginx配置:vi /usr/local/nginx/conf/nginx.conf
        index index.php index.html index.htm;
        root /usr/local/nginx/html/;
        location ~ \.php$ {
            root           /user/local/nginx/html/;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;
            include        fastcgi_params;
        }
配置 Ganglia
cd /root/ganglia-3.1.7   # you should already be in this directory
mkdir -p /user/local/nginx/html/ganglia/  # make sure you have apache installed
cp -a web/* /user/local/nginx/html/ganglia/   # this is the web interface
cp gmetad/gmetad.init /etc/rc.d/init.d/gmetad  # startup script
cp gmond/gmond.init /etc/rc.d/init.d/gmond
mkdir /etc/ganglia  # where config files go
gmond -t | tee /etc/ganglia/gmond.conf  # generate initial gmond config
cp gmetad/gmetad.conf /etc/ganglia/  # initial gmetad configuration
mkdir -p /var/lib/ganglia/rrds  # place where RRDTool graphs will be stored
chown nobody:nobody /var/lib/ganglia/rrds  # make sure RRDTool can write here.
chkconfig --add gmetad  # make sure gmetad starts up at boot time
chkconfig --add gmond # make sure gmond starts up at boot time
现在基本安装已完成,需要设置几个配置项才能运行。执行以下步骤:
    处理命令行文件。
    修改 /etc/ganglia/gmond.conf。
    data_source "server6" localhost
    修改/etc/ganglia/gmond.conf
cluster {
  name = "server6"
  owner = "server6"
  latlong = "server6"
  url = "server6"
}
host {
  location = "server6"
}
广播地址
route add -host 239.2.11.71 dev eth1
启动:
service gmond start
service gmetad start
/usr/local/php/sbin/php-fpm start
/usr/local/nginx/sbin/nginx
访问地址:http://server6/ganglia
客户端安装:
方案一远程复制,用于与服务器同一版本操作系统:cp_node.sh 
PORT=7001
for i in `cat /tmp/mynodes`; do 
scp -P $PORT /usr/sbin/gmond $i:/usr/sbin/gmond
ssh -p $PORT $i mkdir -p /etc/ganglia/
scp -P $PORT /etc/ganglia/gmond.conf $i:/etc/ganglia/
scp -P $PORT /etc/init.d/gmond $i:/etc/init.d/
scp -P $PORT /usr/lib64/libganglia-3.1.7.so.0 $i:/usr/lib64/
scp -P $PORT /lib64/libexpat.so.0 $i:/lib64/
scp -P $PORT /usr/lib64/libconfuse.so.0 $i:/usr/lib64/
scp -P $PORT /usr/lib64/libapr-1.so.0 $i:/usr/lib64/
scp -P $PORT -r /usr/lib64/ganglia $i:/usr/lib64/
ssh -p $PORT $i service gmond start
done
方案二:客户端安装,用于服务器不同版本,自行编译客户端
wget [url=ftp://rpmfind.net/linux/dag/redhat/el4/en/i386/dag/RPMS/libconfuse-2.6-1.el4.rf.i386.rpm]ftp://rpmfind.net/linux/dag/redhat/el4/en/i386/dag/RPMS/libconfuse-2.6-1.el4.rf.i386.rpm[/url]
wget [url=ftp://rpmfind.net/linux/dag/redhat/el4/en/i386/dag/RPMS/libconfuse-devel-2.6-1.el4.rf.i386.rpm]ftp://rpmfind.net/linux/dag/redhat/el4/en/i386/dag/RPMS/libconfuse-devel-2.6-1.el4.rf.i386.rpm[/url]
rpm -ivh libconfuse-devel-2.6-1.el4.rf.i386.rpm libconfuse-2.6-1.el4.rf.i386.rpm 
./configure --sysconfdir=/etc/ganglia ;make ;make install
cd gmond
gmond -t > /etc/ganglia/gmond.conf
cp gmond.init /etc/rc.d/init.d/gmond
chkconfig --add gmond
chkconfig --list gmond
gmond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
/etc/rc.d/init.d/gmond start
广播地址
route add -host 239.2.11.71 dev eth1
测试:
telnet localhost 8649 
 
原文地址:https://www.cnblogs.com/langke93/p/2217382.html