Ganglia:分佈式監控系統

Ganglia:分佈式監控系統前端


Ganglia的核心包含gmond、gmetad以及一個Web前端。主要是用來監控系統性能,如:cpu 、mem、硬盤利用率, I/O負載、網絡流量狀況等,經過曲線很容易見到每一個節點的工做狀態,對合理調整、分配系統資源,提升系統總體性能起到重要做用python


Ganglia監控端安裝c++


一、安裝依賴的軟件包git

yum install ntp vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel  pam-devel python-devel perl perl-devel expat expat-devel pcre pcre-devel apr apr-devel cairo-devel和pango-devel

須要安裝rrdtool工具 最新版本的ganglia已能夠直接使用yum安裝rrdtool工具便可,github

二、安裝confuseweb

wget http://download.savannah.gnu.org/releases/confuse/confuse-2.7.tar.gz
tar zxf confuse-2.7.tar.gz
cd confuse-2.7
./configure CFLAGS=-fPIC --disable-nls ;make;make install 
cd ..

三、安裝gangliavim

 wget http://downloads.sourceforge.net/project/ganglia/ganglia%20monitoring%20core/3.3.1/ganglia-3.3.1.tar.gz
tar zxf ganglia-3.3.1.tar.gz
cd ganglia-3.3.1
#server 監控端
./configure --prefix=/usr/local/ganglia --with-static-modules --enable-gexec --enable-status --with-gmetad --with-python=/usr --with-librrd=/usr/local/rrdtool --with-libexpat=/usr --with-libconfuse=/usr/local --with-libpcre
make
make install
cd gmetad
cp gmetad.conf /opt/modules/ganglia/etc/
cp gmetad.init /etc/init.d/gmetad
vim /etc/init.d/gmetad

修改成GMETAD=/usr/local/ganglia/sbin/gmetad

ip route add 239.2.11.71 dev eth0  ##添加廣播路由

Ganglia:被監控端安裝:
bash


一、安裝依賴的軟件包服務器

yum install ntp vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel  pam-devel python-devel perl perl-devel expat expat-devel pcre pcre-devel apr apr-devel
wget http://download.savannah.gnu.org/releases/confuse/confuse-2.7.tar.gz
tar zxf confuse-2.7.tar.gz
cd confuse-2.7
./configure CFLAGS=-fPIC --disable-nls ;make;make install 
cd ..


二、安裝ganglia網絡

wget http://downloads.sourceforge.net/project/ganglia/ganglia%20monitoring%20core/3.3.1/ganglia-3.6.0.tar.gz
tar zxf ganglia-3.6.0.tar.gz
cd ganglia-3.6.0

./configure --prefix=/usr/local/ganglia --enable-gexec --enable-status --with-python=/usr --with-libapr --with-libconfuse=/usr/local --with-libexpat=/usr --with-libpcre
make
make install
cd gmond
./gmond -t > /usr/local/ganglia/etc/gmond.conf
cp gmetad.init /etc/init.d/gmond
vim /etc/init.d/gmond
修改成:
GMETAD=/usr/local/ganglia/sbin/gmond

mkdir /usr/local/ganglia/lib64/ganglia/python_modules
cp python_modules/*/*.py /usr/local/ganglia/lib64/ganglia/python_modules

ip route add 239.2.11.71 dev eth0

安裝已完成,過程簡單。


Web網頁頁面在https://github.com/ganglia/ganglia-web

自行下載配置使用便可。



下面來監控,使其能正常工做和使用。

ganglia是分佈式監控系統,也能夠不使用分佈來用。下面就分兩種方式來解說。

一、不使用分佈式來監控的方式

服務器配置文件
修改兩項:
data_source "test1" 192.168.107.2
data_source "test2" 172.16.1.4

##這裏分了兩個監控組

data_source是關鍵字,
「test1,test2」 是監控主機組的名字,全局要惟一。 後面跟着要監控的ip或主機名,若是有多個能夠用空格隔開就能夠了

gridname "Test"
這個是定義監控集的名字,

以下所示:


wKioL1P1loTAxuRsAAEyQGEffVM867.jpgwKioL1P1lpHhovNBAAEyQGEffVM518.jpg



如今ganglia尚未啓動,在啓動以前執行下面命令:

可使用命令查看是否是有配置錯誤的地方致使啓動不了

/usr/local/ganglia/sbin/gmetad -d 5

出錯的地方應該能夠修改配置文件gmetad.conf獲得修正、

service gmetad start 來啓動服務


好了,再看客戶端的配置吧

在客戶端配置

globals {
  daemonize = yes
  setuid = yes
  user = nobody
  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 = "test1"      ####須要修改與服務器端設定相同的名字 ###
  owner = "nobody"         ###修改成nobody
  latlong = "unspecified"
  url = "unspecified"
}

host {
  location = "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
  # 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
}

啓動客戶端

在客戶端也是可使用debug來調試配置是否是有錯

/usr/local/ganglia/sbin/gmond -d 5


service gmond start


下面來講第2種分佈式監控系統


二、分佈式監控


主gmetad    多個次gmetad    被監控點

|------ gmond

    _ gmetad---|------ gmond

    | |------ gmond

    | 

gmetad-------|_ gmetad---|-------gmond

      |     |         |------gmond

      |       |__ gmetad----|------gmond

      | |------gmond

      |_gmond

      |-gmond


從面能夠看到多個gmetad點和多個gmond點

主要是從次節點的配置:

下面對次節點配置以下
 gmetad.conf
 配置以下:
 data_source "test2" localhost ip/hostname


 gmond.conf配置文件以下:

 cluster {
  name = "test2"
  owner = "nobody"
  latlong = "unspecified"
  url = "unspecified"
}

host {
  location = "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 = 172.16.1.4 ####次節點的ip地址。也就次節點本身的ip地址
  port = 8649
  }

udp_recv_channel {
  port = 8649
  family = inet4
}

/* 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
}

次節點下的gmond節點配置與次節點gmond的配置同樣,直接copy一份到gmond上面就好。


關於Ganglia的主要配置到此爲止了。Ganglia的views功能還在研究當中,不過這個view添加很麻煩,我配置的很久也,只是在配置文件中添加,在頁面上沒有添加成功,由於頁面上沒有添加view的功能,,這個很不爽,網上查了不少資料,只是在官網上找到一點相關E文,,,,,,希路過的大牛能指點一二,多謝!

相關文章
相關標籤/搜索