需求: 採集多個節點中的負載情況,多個節點劃分爲多個集羣監控
ganglia的簡單角色劃分
ganglia-web :
web展示
ganglia-gmetad
數據收集處理
ganglib-gmond
數據採集發送
這裏不再詳細介紹:查看文末的參考博客
計劃的集羣分佈:
node1(監控節點)
web
gmetad
gmond(可以不安裝,如果不用監控node1信息,這裏不安裝)
cluster1(只安裝配置gmond)
node2
node3
cluster2(只安裝配置gmond)
node4
node5
node1 部署:
web
gmetad
gmond(可以不安裝,因爲我不需要監node1 信息)
yum install -y ganglia-web.x86_64
yum install -y ganglia-gmetad.x86_64
yum install -y nginx php-fpm
配置文件:
/etc/nginx/conf.d/default.conf(不存在則新建)
server {
listen 8081 default_server;
server_name _;
root /usr/share/ganglia;
index index.php;
include /etc/nginx/default.d/*.conf;
location / {
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
端口號什麼的根據自己的需要配置。
啓動服務:
service nginx start
service gmetad start
service gmond start (未安裝配置則不需要開啓)
根據centos版本: 可以使用systemctl restart gmetad ...
如果是內網配置,會發現頁面顯示異常,f12 調試發現,有一些js需要下載。
這裏看到 ganglia的web目錄是 /usr/share/ganglia
此時打開
/usr/share/ganglia
grep -rn xxx.js(加載不到的js文件名) --include=*.php
嘗試查找包含了需要外部下載的js,在conf_default.php 中發現這些js需要從外網下載, (下面文件爲已經修改過的版本)
所以手動下載,然後改爲本地路徑指向。
我打開了git bash 使用
curl www.xxxx.js > xxx.js
下載之後再傳到 /usr/share/ganglia/js
#By default we'll just download Jquery, Cubism and D3 required libraries from a CDN that offers
#that for free. If that is undesirable you can override this in conf.php by putting
#downloading the asset and putting relative path or absolute paths to it e.g.
#$conf['cubism_js_path'] = "js/cubism.v1.min.js";
$conf['jquery_js_path'] = "js/jquery.min.js";
$conf['jquerymobile_js_path'] = "js/jquery.mobile.min.js";
$conf['jqueryui_js_path'] = "js/jquery-ui.min.js";
$conf['rickshaw_js_path'] = "js/rickshaw.min.js";
$conf['cubism_js_path'] = "js/cubism.v1.min.js";
$conf['d3_js_path'] = "js/d3.min.js";
$conf['protovis_js_path'] = "js/protovis.min.js";
這裏的話,web顯示應已經可以了。
下一步添加監控節點集羣 。
首先需要在 node1 節點 配置
/etc/ganglia 目錄下
gmetad.conf
這裏貼一下更改的地方
data_source "cluster1" node2 node3
data_source "cluster2" node4:8650 node5:8650
#不填寫端口號的話,默認就是 8649 。這個端口號要與後面的gmond端配置一致,多個host只會從一個host獲取。獲取失敗,則會再找一個獲取。每一個host都包含了所有的信息。
其他節點部署gmond即可
yum install ganglia-gmond.x86_64 -y
配置 /etc/ganglia 下gmond.conf
cluster1 gmond 配置 node2 node3
cluster {
name = "cluster1"
#這個是node1上的datasource 配置
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
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
}
cluster2 gmond 配置 node2 node3節點上(要注意一下端口號)
cluster {
name = "cluster2"
#這個是node1上的datasource 配置
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 = 8650
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 = 8650
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 = 8650
#If you want to gzip XML output
gzip_output = no
}
問題:
yum install ganglia-gmond.x86_64 -y
如果報錯
"Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7"
解決:
打開epel倉庫參數更改爲: gpgcheck=0
參考 blog:
簡單介紹 : http://blog.sina.com.cn/s/blog_eb0636d10102v3gt.html
部署: https://www.cnblogs.com/marility/p/9444357.html