RHEL 7.1 编译安装Ganglia 3.7.1

RHEL 7.1 编译安装Ganglia 3.7.1

1.  安装依赖

yum groupinstall -y "Development tools" "Basic Web Server"

yum install pcre pcre-devel apr-devel apr-util-devel apr-util zlib-devel zlib rrdtool-devel rrdtool python-devel php

2.  添加用户

useradd ganglia

passwd ganglia
3.  从源代码编译安装,先安装confuse.

cd /usr/local/src

#install confuse
wget
tar zxvf confuse-2.7.tar.gz
cd confuse-2.7/
../configure CFLAGS=-fPIC -disable-nls
make && make install
然后编译安装ganglia

wget %20monitoring%20core/3.7.1/ganglia-3.7.1.tar.gz/download

mv download ganglia-3.7.1.tar.gz
tar zxvf ganglia-3.7.1.tar.gz
cd ganglia-3.7.1/
./configure --prefix=/usr/local/ganglia --with-gmetad --enable-gexec --sysconfdir=/etc/ganglia  --with-python=/usr/bin/python
make && make install
4. 配置gmetad 和gmond.

cp gmetad/gmetad.conf /etc/ganglia/

/usr/local/ganglia/sbin/gmond -t |tee /etc/ganglia/gmond.conf
首先配置gmetad.

vim /etc/ganglia/gmetad.conf

data_source "my cluster" YOUR_FQDN
# setuid_username "nobody"
setuid_username "ganglia"
然后配置gmond.

vim /etc/ganglia/gmond.conf

setuid = yes
#user = nobody
user =ganglia
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
查看gmond的python 扩展,确保modpython.so 被编译出来。

locate modpython.so

/usr/local/ganglia/lib64/ganglia/modpython.so
#create gmond python directory
mkdir -p /usr/local/ganglia/lib64/ganglia/python_modules
/usr/local/ganglia/sbin/gmond -d10
#应该能看到loaded module: python_module
#copy python module / py.conf
cp /usr/local/src/ganglia-3.7.1/gmond/python_modules/*/*.py  /usr/local/ganglia/lib64/ganglia/python_modules
cp /usr/local/src/ganglia-3.7.1/gmond/python_modules/conf.d/*.pyconf /etc/ganglia/conf.d
配置启动项:

cp gmetad/gmetad.init /etc/rc.d/init.d/gmetad

cp gmond/gmond.init /etc/rc.d/init.d/gmond
vim /etc/init.d/gemtad(edit these)
        #GMETAD=/usr/sbin/gmetad
        GMETAD=/usr/local/ganglia/sbin/gmetad
        #daemon $GMETAD
        daemon $GMETAD -c /etc/ganglia/gmetad.conf
vim /etc/init.d/gmond (edit these)
        #GMOND=/usr/sbin/gmond
        GMOND=/usr/local/ganglia/sbin/gmond
        #daemon $GMOND
        daemon $GMOND -c /etc/ganglia/gmond.conf
配置systemd服务

vim /usr/lib/systemd/system/gmetad.service(edit these lines)

[Service]
Type=forking
#PIDFile=/usr/local/ganglia/var/run/gmetad.pid
PIDFile=/var/run/gmetad.pid
#ExecStart=/usr/local/ganglia/sbin/gmetad --pid-file=/usr/local/ganglia/var/run/gmetad.pid
ExecStart=/usr/local/ganglia/sbin/gmetad -c /etc/ganglia/gmetad.conf --pid-file=/var/run/gmetad.pid
EnvironmentFile=-/etc/ganglia/default/gmetad

vim /usr/lib/systemd/system/gmond.service(edit these lines)

[Service]
Type=forking
#PIDFile=/usr/local/ganglia/var/run/gmond.pid
PIDFile=/var/run/gmond.pid
#ExecStart=/usr/local/ganglia/sbin/gmond --pid-file=/usr/local/ganglia/var/run/gmond.pid
ExecStart=/usr/local/ganglia/sbin/gmond -c /etc/ganglia/gmond.conf --pid-file=/var/run/gmond.pid
为rrdtool 创建目录:

mkdir -p /var/lib/ganglia/rrds

chown ganglia:ganglia /var/lib/ganglia/rrds
启动服务:

systemctl daemon-reload

systemctl start gmetad
systemctl start gmond
至此,netstat 可以看到端口监听,可以telnet localhost 8649, 能看到xml,ps -ef 证实 gmetad 和gmond 确实是以ganglia 用户在运行,"/var/lib/ganglia/rrds" 目录下有文件生成.

netstat -tnlp

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8649 0.0.0.0:* LISTEN 18465/gmond
tcp 0 0 0.0.0.0:8651 0.0.0.0:* LISTEN 17783/gmetad
tcp 0 0 0.0.0.0:8652 0.0.0.0:* LISTEN 17783/gmetad

5. 配置ganglia-web

wget

tar xzvf ganglia-web-3.7.1.tar.gz
vi Makefile(Edit these)
GDESTDIR = /var/www/html/ganglia
APACHE_USER = apache
ZZ
make install
6.从GUI 登陆.

下面关于Ganglia的文章您也可能喜欢,不妨参考下:

Ganglia 3.1.x下扩展Python模块(翻译自官方wiki)

使用Ganglia监控Hadoop集群

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/72dcb4e506fd37a9e2f00480085ca545.html