系統監控軟件Ganglia的安裝

1、實驗環境

    Centos6.4

2、安裝rrdtool(注rrdtool-1.5.3不支持3.6.1)

1
2
#安裝ganglia相關包
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 pcre pcre-devel
1
2
3
4
5
6
7
tar xzf rrdtool-1.4.9.tar.gz
cd rrdtool-1.4.9
./configure --prefix=/opt/rrdtool-1.4.9 --disable-perl
make
make install
ln -s /opt/rrdtool-1.4.9/include/rrd.h /usr/include/rrd.h
ln -s /opt/rrdtool-1.4.9/lib/librrd.a /usr/lib/librrd.a

3、server腳本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
#安裝confuse
tar zxf confuse-2.7.tar.gz
cd confuse-2.7
./configure CFLAGS=-fPIC --disable-nls ;make;make install 
cd ..
#安裝ganglia
tar zxf ganglia-3.6.1.tar.gz
cd ganglia-3.6.1
#server
./configure --prefix=/opt/modules/ganglia --with-static-modules --enable-gexec --enable-status --with-gmetad --with-python=/usr --with-librrd=/opt/rrdtool-1.4.9 --with-libexpat=/usr --with-libconfuse=/usr/local --with-libpcre=/usr/local
#client
#./configure --prefix=/opt/modules/ganglia --enable-gexec --enable-status --with-python=/usr --with-libconfuse=/usr/local --with-libexpat=/usr --with-libpcre=/usr
makemake install
cd gmetad
cp gmetad.conf /opt/modules/ganglia/etc/
cp gmetad.init /etc/init.d/gmetad
sed -i "s/^GMETAD=\/usr\/sbin\/gmetad/GMETAD=\/opt\/modules\/ganglia\/sbin\/gmetad/g" /etc/init.d/gmetad
chkconfig --add gmetad
#我的服務器有兩塊網卡,eth1使用公網地址,eth2使用局域網地址,監控服務器和被監控服務器之間的通信通過局域網地址實現以減少公網網卡的負載,使用以下命令:(此IP可以在/etc/ganglia/gmond.conf中修改)
ip route add 239.2.11.71 dev eth2
service gmetad start

組播方式一定要使用ip route add 239.2.11.71 dev eth2如果只有一個網卡就指定那一個網卡就好

查看service gmetad status

報錯gmetad dead but subsys locked

查看tail -f /var/log/messages發現需要增加目錄以及修改gmetad.conf文件

(1)mkdir -p /var/lib/ganglia/rrds  (此目錄是配置rrd數據保存文件的路徑,給web界面用的,這個是固定的,最好放在web文件夾下,並賦予正確的權限,默認即是這個路徑,可以自行在/opt/modules/ganglia/etc/gmetad.conf中修改rrd_rootdir變量的值)

    在安裝完成httpd之後會有apache此用戶,執行以下語句給rrds目錄相應權限

 chown -R apache:apache /var/lib/ganglia/rrds

(2)在gmetad.conf中修改setuid_username "apache" 這裏需要username和rrd數據目錄的owner一致

備註:

    gmetad.conf修改內容如下:

    data_source "MyCluster" 192.168.56.101:8649

    gridname "MyGrid"

    setuid_username "apache"

重新啓動

service gmetad restart

4、client腳本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
tar zxf confuse-2.7.tar.gz
cd confuse-2.7
./configure CFLAGS=-fPIC --disable-nls ;make;make install 
cd ..
tar zxf ganglia-3.6.1.tar.gz
cd ganglia-3.6.1
#server
#./configure --prefix=/opt/modules/ganglia --with-static-modules --enable-gexec --enable-status --with-gmetad --with-python=/usr --with-librrd=/opt/rrdtool-1.4.5 --with-libexpat=/usr --with-libconfuse=/usr/local --with-libpcre=/usr/local
#client不需要rrdtool
./configure --prefix=/opt/modules/ganglia --enable-gexec --enable-status --with-python=/usr --with-libconfuse=/usr/local --with-libexpat=/usr --with-libpcre=/usr
makemake install
cd gmond
./gmond -t > /opt/modules/ganglia/etc/gmond.conf
cp gmond.init /etc/init.d/gmond
sed -i "s/^GMOND=\/usr\/sbin\/gmond/GMOND=\/opt\/modules\/ganglia\/sbin\/gmond/g" /etc/init.d/gmond
chkconfig --add gmond
ip route add 239.2.11.71 dev eth2
service gmond start

備註:gmond.conf修改如下(與gmetad.conf文件修改相對應):

    

cluster {

  name = "MyCluster"

  owner = "unspecified"

  latlong = "unspecified"

  url = "unspecified"

}

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

  port = 8649

  ttl = 1

}

udp_recv_channel {

  mcast_join = 239.2.11.71

  port = 8649

  bind = 239.2.11.71

  retry_bind = true

}

tcp_accept_channel {

  port = 8649

  # If you want to gzip XML output

  gzip_output = no

}


以上都是組播方式的安裝,如果使用單播的方式,需要修改gmond.conf文件

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

  host = hostname

  port = 8649

  ttl = 1

}

udp_recv_channel {

  #mcast_join = 239.2.11.71

  port = 8649

  #bind = 239.2.11.71

  #retry_bind = true

}

5、ganglia-web安裝

yum -y install httpd php

1
2
tar xzf ganglia-web-3.6.2
cd ganglia-web-3.6.2

修改Makefile文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
##########################################################
# User configurables:
##########################################################
# Location where gweb should be installed to (excluding conf, dwoo dirs).
GDESTDIR = /var/www/html/ganglia
 
# Location where default apache configuration should be installed to.
GCONFDIR = /etc/ganglia-web
 
# Gweb statedir (where conf dir and Dwoo templates dir are stored)
GWEB_STATEDIR = /var/lib/ganglia-web
 
# Gmetad rootdir (parent location of rrd folder)
GMETAD_ROOTDIR = /var/lib/ganglia
 
APACHE_USER = apache
##########################################################

修改conf_defalut.php文件中rrdtool執行文件的路徑地址,此參數會影響頁面顯示監控的圖表

1
2
3
4
#
$conf['gmetad_root'= "/var/lib/ganglia";
$conf['rrds'= "${conf['gmetad_root']}/rrds";
$conf['rrdtool'= "/opt/rrdtool-1.4.9/bin/rrdtool";

make install

關閉SELINUX

/etc/selinux/config修改:SELINUX=disabled

關閉防火牆並啓動httpd

1
2
3
4
service iptables stop
chkconfig iptables off
service httpd start
chkconfig httpd on

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