Ganglia安裝指南 (基于CentOS 5.6)
安裝依賴
rpm -ivh http://mirrors.sohu.com/centos/5/os/x86_64/CentOS/zlib-devel-1.2.3-3.x86_64.rpm
rpm -ivh http://mirrors.sohu.com/centos/5/os/x86_64/CentOS/freetype-devel-2.2.1-28.el5_5.1.x86_64.rpm
rpm -ivh http://mirrors.sohu.com/centos/5/os/x86_64/CentOS/libart_lgpl-devel-2.3.17-4.x86_64.rpm
rpm -ivh http://mirrors.sohu.com/centos/5/os/x86_64/CentOS/libpng-devel-1.2.10-7.1.el5_5.3.x86_64.rpm
如果上述安裝失敗,可能需要安裝以下庫依賴
yum install zlib freetype libart_lgpl libpng
安裝rrdtools
http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.27.tar.gz
tar zxvf rrdtool-1.2.27.tar
cd rrdtool-1.2.27
./configure --prefix=/usr/local/rrdtool
make
make install
執行下命令,看是否安裝成功
/usr/local/rrdtool/bin/rrdtool
安裝expat依賴
http://downloads.sourceforge.net/project/expat/expat/2.0.1/expat-2.0.1.tar.gz?use_mirror=cdnetworks-kr-2
tar zxvf expat-2.0.1.tar.gz
./configure --prefix=/usr/local/expat
make
make install
對于64位操作系統,需要手動的拷貝下動態鏈接庫到lib64下
mkdir /usr/local/expat/lib64
cp -a /usr/local/expat/lib/* /usr/local/expat/lib64/
安裝apr以及apr-util
http://labs.renren.com/apache-mirror/apr/apr-1.4.5.tar.gz
tar xvjf apr-1.3.2.tar.bz2
./configure --prefix=/usr/local/apr
make
make install
http://labs.renren.com/apache-mirror/apr/apr-util-1.3.12.tar.gz
tar xvjf apr-util-1.3.2.tar.bz2
./configure --with-apr=/usr/local/apr --with-expat=/usr/local/expat
make
make install
同樣64位機器需要拷貝動態鏈接庫
/bin/cp -f /usr/local/apr/include/apr-1/* /usr/local/apr/include/
mkdir -p /usr/local/apr/lib64
/bin/cp -a -f /usr/local/apr/lib/* /usr/local/apr/lib64/
安裝confuse
http://download.savannah.gnu.org/releases/confuse/confuse-2.7.tar.gz
tar zxvf confuse-2.6.tar.gz
./configure CFLAGS=-fPIC --disable-nls --prefix=/usr/local/confuse
make
make install
拷貝動態鏈接庫
mkdir -p /usr/local/confuse/lib64
/bin/cp -a -f /usr/local/confuse/lib/* /usr/local/confuse/lib64/
安裝ganglia
現在才是安裝ganglia的開始,如果提示需要pcre的話,安裝下 yum install pcre
下載ganglia-3.2.0,解壓,安裝
./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 --with-gmetad --enable-gexec --enable-status --sysconfdir=/etc/ganglia
make
make install
服務端配置
創建rrdtool數據目錄,看$ganglia-3.2.0/web/conf.php里面的gmetad_root變量,并根據apache的運行用戶創建權限,例如apache運行于apache用戶上 。
mkdir -p /var/lib/ganglia/rrds
mkdir -p /var/lib/ganglia/dwoo
chown -R apache;apache /var/lib/ganglia
配置一個數據源,修改/etc/ganglia/gmetad.conf文件,同時將運行用戶設置為rrdtool的目錄權限用戶,例如apache用戶
data_source "suc" localhost
setuid_username "apache"
其中suc是數據源的名稱,客戶端分組會依賴此名稱,后面會提到。 添加自啟動腳本
/bin/cp -f gmetad/gmetad.init /etc/init.d/gmetad
/bin/cp -f /usr/local/ganglia/sbin/gmetad /usr/sbin/gmetad
chkconfig -add gmetad
啟動gmetad服務
service gmetad start
看見Starting GANGLIA gmetad: [ OK ]就代表運行正常了。
客戶端配置(gmond節點)
本機安裝如下:
/bin/cp -f gmond/gmond.init /etc/init.d/gmond
/bin/cp -f /usr/local/ganglia/sbin/gmond/usr/sbin/gmond
chkconfig -add gmond
gmond --default_config > /etc/ganglia/gmond.conf
對于生成的默認配置文件需要做適當的修改
cluster {
name="suc"
owner="apache"
latlong="unspecified"
url="unspecified"
}
其中name是將要在服務端進行的分組,是服務端的數據源。接下來開啟服務
service gmond start
看見Starting GANGLIA gmetad: [ OK ]代表啟動成功。如果有失敗,可以講gmond.conf中的debug有0改為100,看更多的日志,然后進行排查。
globals {
daemonize = yes
setuid = yes
user = nobody
debug_level = 100
}
非本機客戶端配置需要安裝服務端安裝一樣進行配置,運行,非常麻煩,這里使用本機安裝好的文件進行安裝。 使用下面的腳本進行安裝deploy-ganglia.sh
i=$1
scp /usr/sbin/gmond $i:/usr/sbin/gmond
ssh $i mkdir -p /etc/ganglia/
ssh $i mkdir -p /usr/local/ganglia/lib64
ssh $i mkdir -p /usr/local/expat/lib
scp /etc/ganglia/gmond.conf $i:/etc/ganglia/
scp /etc/init.d/gmond $i:/etc/init.d/
scp -r /usr/local/ganglia/lib64/* $i:/usr/local/ganglia/lib64/
scp /usr/local/expat/lib/libexpat.so.1 $i:/usr/local/expat/lib/libexpat.so.1
scp /usr/lib64/libapr-1.so.0 $i:/usr/lib64/
實際上就是將本機安裝好(編譯好)的動態鏈接庫拷貝到其它機器上,使用如下命令拷貝即可
sh deploy-ganglia.sh 10.1.11.2
服務端的WEB配置
PHP程序需要依賴Apache來運行,因此需要安裝如下依賴
yum install php-common php-cli php php-gd httpd
安裝web程序,這里假定apache的root路徑在/var/www/html下面。
mkdir /var/www/html/ganglia
cp -a -f ganglia-3.2.0/web/* /var/www/html/ganglia
禁用SELinux setenforce 0
修改rrdtool的路徑,文件/var/www/html/ganglia/conf.php中的RRDTOOL
define("RRDTOOL", "/usr/local/rrdtool/bin/rrdtool");
重啟httpd服務器即可看到效果 service httpd restart