系统监控软件Ganglia的安装,监控软件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

相关内容