ganglia的搭建以及添加被監控主機

一、Ganglia的簡介     

   Ganglia是UC Berkeley發起的一個開源集羣監視項目,設計用於測量數以千計的節點。Ganglia的核心包含gmond、gmetad以及一個Web前端。主要 是用來監控系統性能,如:cpu 、mem、硬盤利用率, I/O負載、網絡流量情況等,通過曲線很容易見到每個節點的工作狀態,對合理調整、分配系統資源,提高系統整體性能起到重要作用。

   Ganglia由gmond、gmetad和gweb三部分組成

   gmond(Ganglia Monitoring Daemon)是一種輕量級服務,安裝在每臺需要收集指標數據的節點主機上。gmond在每臺主機上完成實際意義上的指標數據收集工作,並通過偵聽/通告 協議和集羣內其他節點共享數據。使用gmond,你可以很容易收集很多系統指標數據,如CPU、內存、磁盤、網絡和活躍進程的數據等。
    gmetad(Ganglia Meta Daemon)是一種從其他gmetad或gmond源收集指標數據,並將其以RRD格式存儲至磁盤的服務。gmetad爲從主機組收集的特定指標信息提供了簡單的查詢機制,並支持分級授權,使得創建聯合監測域成爲可能。
    gweb(Ganglia Web)gweb是一種利用瀏覽器顯示gmetad所存儲數據的PHP前端。在Web界面中以圖表方式展現集羣的運行狀態下收集的多種不同指標數據。


二、ganglia的快速安裝

安裝前提:需要httpd、php服務

1.查看相關依賴包是否已經安裝上去

rpm -q gcc glibc glibc-common rrdtool rrdtool-devel apr  apr-devel expat expat-devel  pcre pcre-devel dejavu-lgc-sans-mono-fonts dejavu-sans-mono-fonts
沒有安裝的安裝上去

2.安裝相應的包

cd /home/rrdtool
rpm -ivh *.rpm
cd ..
cd ganglia
tar -zxvf expat-2.0.1.tar.gz
cd expat-2.0.1
./configure --prefix=/usr/local/expat
make
make install

cd ..
tar -zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --with-apr=/usr/local/apr --with-expat=/usr/local/expat
make
make install

cd ..
tar -zxvf confuse-2.6.tar.gz
cd confuse-2.6
./configure CFLAGS=-fPIC --disable-nls --prefix=/usr/local/confuse
make
make install
cd ..
tar -zxvf pcre-8.12.tar.gz
cd pcre-8.12
./configure
make
make install
cd ..

3.安裝gmetad(主節點)

tar zxvf ganglia-3.5..tar.gz
cd ganglia-3.1.7
./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-python=/usr/local/lib/python2.7  --with-gmetad --enable-gexec --enable-status --sysconfdir=/etc/ganglia
make
make install
mkdir -p /var/lib/ganglia/rrds
chown -R nobody:nobody /var/lib/ganglia/rrds
cp gmetad/gmetad.init /etc/init.d/gmetad
cp /usr/local/ganglia/sbin/gmetad /usr/sbin/
chkconfig --add gmetad
cd /home/ganglia-web
rpm -ivh *.rpm
#cp gmond/gmond.init /etc/init.d/gmond
#cp /usr/local/ganglia/sbin/gmond /usr/sbin/
#mkdir -p /etc/ganglia
#gmond --default_config>/etc/ganglia/gmond.conf
#chkconfig --add gmond

4.安裝gmontd(各個節點)

cd ./ganglia-gmond/ganglia_dep
rpm -ivh *.rpm
tar zxf confuse-2.7.tar.gz
cd confuse-2.7
./configure CFLAGS=-fPIC --disable-nls
make && make install
mkdir /usr/local/confuse/lib64
cd ..
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make && make install
cd ../../
tar zxvf ganglia-3.6.0.tar.gz
cd ganglia-3.6.0
./configure --prefix=/usr/local/ganglia --enable-gexec --with-python=/usr/local
make && make install
cp gmond/gmond.init /etc/init.d/gmond
cp /usr/local/ganglia/sbin/gmond /usr/sbin
mkdir -p /usr/local/ganglia/etc
./gmond/gmond -t > /usr/local/ganglia/etc/gmond.conf
cp -r ../conf.d /usr/local/ganglia/etc
cp -f ../gmond.conf /usr/local/ganglia/etc
chkconfig --add gmond
cd ..
cp modpython.so /usr/local/ganglia/lib64/ganglia
mkdir -p /usr/lib64/ganglia/python_modules
cp temp.py  /usr/lib64/ganglia/python_modules
cd psutil-0.6.1 && python setup.py install
service gmond start

5.配置httpd

添加如下代碼,並啓動httpd服務

[root@cjx conf]# vim httpd.conf
[root@cjx conf]# cd /etc/httpd/conf

# ganglia
Alias /ganglia "/export/home/ganglia/ganglia-web-3.5.10"
<Directory "/export/home/ganglia/ganglia-web-3.5.10">
     AuthType Basic
     Options None
     AllowOverride None
     Order allow,deny
     Allow from all
</Directory>

6.打開ganglia-web界面就可以看到監控界面

http://localhostIP/ganglia

7.添加監控主機

根據上面的gmond(客戶端)的安裝方法,安裝好gmond

在 gmetad配置文件添加需要監控的主機

wKioL1bUGobzZ38YAAA6AZx-M6k279.png

修改被監控主機配置

# cd /usr/local/ganglia/etc
# vim gmond.conf
cluster {  name = "my cluster"  owner = "nobody"  latlong = "unspecified"  url = "unspecified"}

wKiom1bUGtiBlOkNAAAs9jPqbag295.png

8.打開ganglia-web界面可以看到被添加的主機已經成功添加上去

wKiom1bUHN-BGZnKAALRZva7J_E819.png

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章