1. 程式人生 > >centos7 mini 及ganglia3.7.2安裝

centos7 mini 及ganglia3.7.2安裝

 wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
 rpm -ivh epel-release-latest-7.noarch.rpm
 yum repolist      ##檢查是否已新增至源列表
檢查好已新增至源後就可以進行yum安裝了


yum install ganglia-gmond -y
yum install ganglia-gmetad -y
yum install httpd php
wget http://ncu.dl.sourceforge.net/project/ganglia/ganglia-web/3.7.2/ganglia-web-3.7.2.tar.gz
tar -zxvf ganglia-web-3.7.2.tar.gz -C /opt/soft/


service httpd status
service gmetad status
service gmond status


service httpd restart
service gmetad restart
service gmond restart


待續...
以下參考 :http://blog.csdn.net/lordk911/article/details/52299572

1 克隆一個有root使用者的mini純淨系統,配動態ip
2 檢視ip,上傳下載好的包:
mkdir /opt/soft
ganglia-web-3.7.2.tar.gz
ganglia-3.7.2.tar.gz

安裝CentOS 企業擴充套件YUM源


yum -y install --downloadonly --downloaddir=/opt/soft/epel-release epel-release
yum localinstall -y /opt/soft/epel-release/*.rpm
4 安裝ganglia依賴包
yum -y install gcc glibc glibc-common rrdtool rrdtool-devel apr apr-devel expat expat-devel  pcre pcre-devel dejavu-lgc-sans-mono-fonts dejavu-sans-mono-fonts zlib zlib-devel libconfuse libconfuse-devel --downloadonly --downloaddir=/opt/soft/ganglia_depend
yum localinstall -y /opt/soft/ganglia_depend/*.rpm
5 監控端安裝gmond及gmeta
cd /opt/soft
tar zxf ganglia-3.7.2.tar.gz
  cd ganglia-3.7.2
 ./configure --prefix=/usr/local/ganglia --with-gmetad --enable-gexec
  make && make install
6 安裝nginx
 yum install nginx -y --downloadonly --downloaddir=/opt/soft/nginx
 yum localinstall -y /opt/soft/nginx/*.rpm 
 chkconfig nginx on
 systemctl start nginx
 7 安裝php
 yum --enablerepo=remi,remi-php55 install php-fpm php-common php-devel php-mysqlnd php-mbstring php-mcrypt --downloadonly --downloaddir=/opt/soft/php
 yum localinstall -y /opt/soft/php/*.rpm
 chkconfig php-fpm on
 systemctl start php-fpm
 
 vi /etc/nginx/nginx.conf
 
  location / {
        }
下新增:
        location ~ \.php$ {
          root            /var/www;
          fastcgi_pass    127.0.0.1:9000;
          fastcgi_index   index.php;
          fastcgi_param   SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
          include         fastcgi_params;
        }


#重啟nginx
  systemctl restart nginx
  
  mkdir  /var/www
  cd /var/www
  vi test.php
<?php
phpinfo();
?>
setenforce 0
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
vi /etc/nginx/nginx.conf
user apache;
systemctl restart nginx


訪問:http//192.168.101.146/test.php,出現資訊介面即為除錯成功
或直接curl 192.168.101.146/test.php

配置gmeta
  mkdir -p /var/lib/ganglia/rrds
  chown nobody:nobody /var/lib/ganglia/rrds
  
  cd /opt/soft/ganglia-3.7.2
  cp ./gmetad/gmetad.init  /etc/init.d/gmetad
##修改gmetad
##具體值通過“find / -name 'gmetad' -print”查
# vi /etc/init.d/gmetad
  GMETAD=/usr/local/ganglia/sbin/gmetad
##修改gmetad.conf配置檔案
##如果檔案不存在:cp ./gmetad/gmetad.conf  /usr/local/ganglia/etc
 vi   /usr/local/ganglia/etc/gmetad.conf
    data_source "my cluster" 192.168.101.146
    xml_port  8651
    interactive_port  8652
    rrd_rootdir  "/var/lib/ganglia/rrds"
    case_sensitive_hostnames  0
  chkconfig --add gmetad
  
  mkdir /usr/local/ganglia/var/
  mkdir /usr/local/ganglia/var/run/
  service gmetad restart
# 可以通過日誌 tail -f /var/log/messages 檢視啟動情況


配置gmond
  cd /opt/soft/ganglia-3.7.2
  cp ./gmond/gmond.init  /etc/init.d/gmond
  ./gmond/gmond -t > /usr/local/ganglia/etc/gmond.conf


##修改gmond配置
  vi  /etc/init.d/gmond
    GMOND=/usr/local/ganglia/sbin/gmond


##修改gmond.conf配置
  vi  /usr/local/ganglia/etc/gmond.conf
    cluster {
      name = "my cluster" #要與gmated.conf中data_source的名稱相同
      owner = "nobody"
      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 = 192.168.101.146
      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
    }


    tcp_accept_channel {
      port = 8649
      # If you want to gzip XML output
      gzip_output = no
    }


 重啟gmond   
   service gmond restart


安裝Ganglia Web
cd /opt/soft
tar -zxvf ganglia-web-3.7.2.tar.gz
cd ganglia-web-3.7.2
vi Makefile
GDESTDIR = /var/www/ganglia
APACHE_USER = apache                    # 與 /etc/php-fpm.d/www.conf 中user保持一致

安裝rsync
 yum install nginx -y --downloadonly --downloaddir=/opt/soft/rsync rsync
 yum localinstall -y /opt/soft/rsync/*.rpm  
 make install


配置nginx訪問ganglia


Nginx新增ganglia檔案目錄訪問配置
 vi /etc/nginx/nginx.conf
location /ganglia {
   root   /var/www;
   index  index.html index.htm index.php;
}    

cd /var/www
chown -R apache:apache ganglia/


配置Ganglia Web

  cd /var/www/ganglia
  cp conf_default.php conf.php
  
 mkdir  /var/www/ganglia/dwoo/compiled
 mkdir /var/www/ganglia/dwoo/cache
  vi conf.php
##conf.php中有些預設配置和以上設定不一樣的需要進行修改:
============================================================================================
$conf['gweb_root'] = "/var/www/ganglia";
$conf['gweb_confdir'] = "/var/www/ganglia";


include_once $conf['gweb_root'] . "/version.php";

#
# 'readonly': No authentication is required.  All users may view all resources.  No edits are allowed.
#  'enabled': Guest users may view public clusters.  Login is required to make changes.  
#             An administrator must configure an authentication scheme and ACL rules.
# 'disabled': Guest users may perform any actions, including edits.  No authentication is required.
$conf['auth_system'] = 'readonly';

#
# The name of the directory in "./templates" which contains the
# templates that you want to use. Templates are like a skin for the
# site that can alter its look and feel.
#
$conf['template_name'] = "default";

#
# If you installed gmetad in a directory other than the default
# make sure you change it here.
#

# Where gmetad stores the rrd archives.
$conf['gmetad_root'] = "/var/lib/ganglia";
$conf['rrds'] = "${conf['gmetad_root']}/rrds";


# Where Dwoo (PHP templating engine) store compiled templates
$conf['dwoo_compiled_dir'] = "${conf['gweb_confdir']}/dwoo/compiled";  ##如果不存在可以手動建立並注意許可權
$conf['dwoo_cache_dir'] = "${conf['gweb_confdir']}/dwoo/cache";


# Where to store web-based configuration
$conf['views_dir'] = $conf['gweb_confdir'] . '/conf';
$conf['conf_dir'] = $conf['gweb_confdir'] . '/conf';


# Where to find filter configuration files, if not set filtering
# will be disabled
#$conf['filter_dir'] = "${conf['gweb_confdir']}/filters";


# Leave this alone if rrdtool is installed in $conf['gmetad_root'],
# otherwise, change it if it is installed elsewhere (like /usr/bin)
$conf['rrdtool'] = "/usr/bin/rrdtool"   


    service gmond restart
    service gmetad restart
    service php-fpm restart
    service nginx restart

     chmod +666 /usr/local/ganglia/var/run

    //要讓這個使用者可以寫入:apache 有寫許可權即可。
    chmod +666 /var/www/ganglia/dwoo/compiled
    chmod +666 /var/www/ganglia/dwoo/cache

注意 服務的啟動 start 與restart的區別。

其他需要監控的要裝:

       5 監控端安裝gmond及gmeta

cd /opt/soft
tar zxf ganglia-3.7.2.tar.gz
  cd ganglia-3.7.2
 ./configure --prefix=/usr/local/ganglia  --enable-gexec #這裡要去掉--with-gmetad,只啟用gmond
 make && make install

測試是否成功:

1 gmond :要用nc localhost 8649

2 gmetad:直接去看特定目錄下是否有即時生成的檔案 如預設位置:

/var/lib/ganglia/rrds/master