• 搜索
  • 夜间模式
    ©2015-2025  Ethan's Blog Theme by OneBlog
    搜索
    标签
    # Amule # Gargoyle # LUCI # VIM # Python # Nginx # 反代 # Ansible # Apache # LNMP
  • 首页>
  • Linux>
  • 正文
  • Ganglia分布式监控系统

    2018年04月16日 49 阅读 0 评论 6110 字

    Ganglia分布式监控系统由三个部分组成:gmond gmetad ganglia-web。

    • gmond->运行于需要监控的服务器上,用于收集数据,并传送给gmetad。gmond也可以收集其他gmond传送的数据。
    • gmetad->运行于监控服务器上,用于收集并分析由gmond反馈的数据,然后存储于RRD存储引擎中。gmetad除了可以收集gmond的数据,也可以收集其他gmetad的数据,在分布式服务器中,会有多台gmetad。
    • ganglia-web->web图形界面,与gmetad安装在同一台服务器上,用于从gmetad取数据,并读取RDD数据库,通过rrdtool生成图标以直观的形式表现出来。
      以下配置均在服务器selinux以及防火墙关闭状态下完成

    安装ganglia,需要epel-release支持

    yum -y install ganglia-gm{etad,ond}

    配置gmetad

    vim /etc/ganglia/gmetad.conf
    data_source “my cluster” localhost改为data_source “my cluster” 10 localhost #默认使用8649端口
    gridname “MyGrid”去掉#
    xml_port 8651 去掉#
    interactive_port 8652 去掉#
    rrd_rootdir “/some/other/place”改为默认值rrd_rootdir “/var/lib/ganglia/rrds”

    配置gmond

    vim /etc/ganglia/gmond.conf

    主要看globals这段

    globals {
      daemonize = yes
      setuid = yes
      user = ganglia
      debug_level = 0
      max_udp_msg_len = 1472
      mute = no
      deaf = no
      allow_extra_data = yes
      host_dmax = 86400 /*secs. Expires (removes from web interface) hosts in 1 day */
      host_tmax = 20 /*secs */
      cleanup_threshold = 300 /*secs */
      gexec = no
      # By default gmond will use reverse DNS resolution when displaying your hostname
      # Uncommeting following value will override that value.
      # override_hostname = "mywebserver.domain.com"
      # If you are not using multicast this value should be set to something other than 0.
      # Otherwise if you restart aggregator gmond you will get empty graphs. 60 seconds is reasonable
      send_metadata_interval = 0 /*secs */
     
    }
     
    cluster {
      name = "unspecified"
      owner = "unspecified"
      latlong = "unspecified"
      url = "unspecified"
    }
     
    /* The host section describes attributes of the host, like the location */
    host {
      location = "unspecified"
    }
     
    /* Feel free to specify as many udp_send_channels as you like.  Gmond
       used to only support having a single channel */
    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
    }
     
    /* You can specify as many udp_recv_channels as you like as well. */
    udp_recv_channel {
      mcast_join = 239.2.11.71
      port = 8649
      bind = 239.2.11.71
      retry_bind = true
      # Size of the UDP buffer. If you are handling lots of metrics you really
      # should bump it up to e.g. 10MB or even higher.
      # buffer = 10485760
    }
     
    /* You can specify as many tcp_accept_channels as you like to share
       an xml description of the state of the cluster */
    tcp_accept_channel {
      port = 8649
      # If you want to gzip XML output
      gzip_output = no
    }

    修改为

    globals {
      daemonize = yes #是否后台运行
      setuid = yes #设置运行用户
      user = ganglia #运行用户
      debug_level = 0 #日志等级0,不输出任何信息
      max_udp_msg_len = 1472 
      mute = no #是否发送监控数据到其他节点
      deaf = no #是否接受其他节点发过来的监控数据
      allow_extra_data = yes #是否发送拓展数据
      host_dmax = 0 /*secs. Expires (removes from web interface) hosts in 1 day */ #是否删除一个节点,0代表不删除
      host_tmax = 20 /*secs */ #
      cleanup_threshold = 300 /*secs */  #gmond清理过期数据时间
      gexec = no
      # By default gmond will use reverse DNS resolution when displaying your hostname
      # Uncommeting following value will override that value.
      # override_hostname = "mywebserver.domain.com"
      # If you are not using multicast this value should be set to something other than 0.
      # Otherwise if you restart aggregator gmond you will get empty graphs. 60 seconds is reasonable
      send_metadata_interval = 0 /*secs */
     
    }
     
    cluster {
      name = "my cluster"  #群集名称,要和gmetad中的data_source一致
      owner = "admin" #节点管理者
      latlong = "unspecified" #极点坐标
      url = "unspecified" #节点URL地址
    }
     
    /* The host section describes attributes of the host, like the location */
    host {
      location = "unspecified" #节点物理地址
    }
     
    /* Feel free to specify as many udp_send_channels as you like.  Gmond
       used to only support having a single channel */
    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
    }
     
    /* You can specify as many udp_recv_channels as you like as well. */
    udp_recv_channel {
      mcast_join = 239.2.11.71
      port = 8649
      bind = 239.2.11.71
      retry_bind = true
      # Size of the UDP buffer. If you are handling lots of metrics you really
      # should bump it up to e.g. 10MB or even higher.
      # buffer = 10485760
    }
     
    /* You can specify as many tcp_accept_channels as you like to share
       an xml description of the state of the cluster */
    tcp_accept_channel {
      port = 8649
      # If you want to gzip XML output
      gzip_output = no
    }

    要改的不多。

    web配置

    下载ganglia-web放置到nginx根目录即可,nginx配置不多赘述

    wget https://jaist.dl.sourceforge.net/project/ganglia/ganglia-web/3.7.2/ganglia-web-3.7.2.tar.gz
    cp conf_default.php conf.php

    需要修改的有:

    $conf['gweb_confdir'] = dirname(__FILE__); #ganglia-web的路径,改为PHP函数自动获取
    $conf['gmetad_root'] = "/usr/lib64/ganglia"; #gmetad的安装路径
    $conf['ganglia_ip'] = "127.0.0.1"; #gmetad服务器的地址
    创建相关目录:
    mkdir /usr/lib64/ganglia/rrds
    mkdir /var/www/html/dwoo/{compiled,cache}
    chown ganglia:ganglia -R /usr/lib64/ganglia/rrds
    chown apache:apache -R /var/www/html/dwoo/{compiled,cache}

    开启服务并访问测试

    systemctl enable gmetad
    systemctl start gmond
    systemctl enable gmond
    systemctl start gmond
    本文著作权归作者 [ Ethan ] 享有,未经作者书面授权,禁止转载,封面图片来源于 [ 互联网 ] ,本文仅供个人学习、研究和欣赏使用。如有异议,请联系博主及时处理。
    — END —
    Copyright©2015-2025  All Rights Reserved.  Load:0.006 s
    Theme by OneBlog V3.6.3
    夜间模式

    开源不易,请尊重作者版权,保留基本的版权信息。