gweb & nginx configure

简介:
gweb是ganglia的组件之一, 前面我简单的写了一些gmond, gmetad的安装和配置.
简单来讲gmond用于采集监控数据, gmetad将采集到的监控数据写入rrd数据文件.  gweb则负责可视化工作.

要使用gweb, 首先要安装一个web容器, 这里我选择nginx. 当然你也可以选择apache, openresty等.
nginx的安装和配置参考 : 
因为gweb要访问rrd数据文件, 所以一般和gmetad部署在一个地方. 如果你使用了grid模式的话, 那么gweb部署在最顶层的gmetad主机一起. 

gweb是php写的, 需要安装php
首先要安装pcre
http://www.pcre.org/
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.bz2
# tar -jxvf pcre-8.35.tar.bz2
# cd pcre-8.35
# ./configure --prefix=/opt/pcre8.35 --enable-utf8 --enable-unicode-properties --enable-pcretest-libreadline --enable-shared --enable-static --enable-jit --enable-pcre16 --enable-pcre32
# make && make install

[root@dba ~]# /opt/pcre8.35/bin/pcretest -C
PCRE version 8.35 2014-04-04
Compiled with
  8-bit support
  UTF-8 support
  Unicode properties support
  No just-in-time compiler support
  Newline sequence is LF
  \R matches all Unicode newlines
  Internal link size = 2
  POSIX malloc threshold = 10
  Parentheses nest limit = 250
  Default match limit = 10000000
  Default recursion depth limit = 10000000
  Match recursion uses stack

# vi /etc/profile
export PATH=/opt/pcre8.35/bin:$PATH
export MANPATH=/opt/pcre8.35/share/man:$MANPATH

# vi /etc/ld.so.conf
/opt/pcre8.35/lib

# ldconfig


安装freetype
# wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.bz2
# tar -jxvf freetype-2.5.3.tar.bz2
# cd freetype-2.5.3
# ./configure --prefix=/opt/freetype2.5.3
# make && make install
# vi /etc/profile
export PATH=/opt/freetype2.5.3/bin:$PATH
export MANPATH=/opt/freetype2.5.3/share/man:$MANPATH
# vi /etc/ld.so.conf
/opt/freetype2.5.3/lib
# ldconfig


安装postgresql
# useradd postgres
# tar -jxvf postgresql-9.3.5.tar.bz2
# cd postgresql-9.3.5
# ./configure --prefix=/opt/pgsql9.3.5 --with-pgport=5432 --with-perl --with-tcl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safety
# gmake world && gmake install-world
# ln -s /opt/pgsql9.3.5 /opt/pgsql
# vi /etc/profile
export PATH=/opt/pgsql/bin:$PATH
export MANPATH=/opt/pgsql/share/man:$MANPATH

# vi /etc/ld.so.conf
/opt/pgsql/lib
# ldconfig

# mkdir -p /data03/pgdata/pg_root
# chown postgres:postgres /data03/pgdata/pg_root
# su - postgres
$ vi .bash_profile
export PS1="$USER@`/bin/hostname -s`-> "
export PGPORT=5432
export PGDATA=/data03/pgdata/pg_root
export LANG=en_US.utf8
export PGHOME=/opt/pgsql
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export DATE=`date +"%Y%m%d%H%M"`
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export PGUSER=postgres
export PGHOST=$PGDATA
alias rm='rm -i'
alias ll='ls -lh'
export PGDATABASE=postgres


安装php
# yum install -y libpng libpng-devel
# wget http://cn2.php.net/get/php-5.5.14.tar.bz2/from/this/mirror
# tar -jxvf php-5.5.14.tar.bz2
# cp /opt/pcre8.35/include/pcre.h /opt/pcre8.35/lib/
# cd php-5.5.14
# ./configure --prefix=/opt/php5.5.14 --with-pcre-regex=/opt/pcre8.35/lib --enable-fpm --enable-opcache --with-pdo-pgsql=/opt/pgsql/bin --with-pgsql=/opt/pgsql/bin --enable-bcmath --enable-mbstring --enable-sockets --with-gd --with-gettext --with-libdir=lib64 --with-jpeg-dir --with-png-dir --with-freetype-dir=/opt/freetype2.5.3
# make && make install

# vi /etc/profile
export PATH=/opt/php5.5.14/bin:/opt/php5.5.14/sbin:$PATH
export MANPATH=/opt/php5.5.14/php/man:$MANPATH


配置并启动php-fpm
[root@150 ~]# php --ini
Configuration File (php.ini) Path: /opt/php5.5.14/lib
Loaded Configuration File:         (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)


拷贝php和php-fpm的配置文件到对应的配置目录
# cp php-5.5.14/php.ini-production /opt/php5.5.14/lib/php.ini
# cp /opt/php5.5.14/etc/php-fpm.conf.default /opt/php5.5.14/etc/php-fpm.conf


配置php.ini
# vi /opt/php5.5.14/lib/php.ini
post_max_size = 16M
date.timezone = "Asia/Shanghai"
max_execution_time = 300
max_input_time = 300

启动php-fpm
[root@150 zabbix]# which php-fpm
/opt/php5.5.14/sbin/php-fpm
[root@150 zabbix]# php-fpm -R -c /opt/php5.5.14/etc
[root@150 zabbix]# netstat -anp|grep 9000
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      26627/php-fpm


下载gweb
http://sourceforge.net/projects/ganglia/files/ganglia-web/
# wget http://downloads.sourceforge.net/project/ganglia/ganglia-web/3.6.2/ganglia-web-3.6.2.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fganglia%2Ffiles%2Fganglia-web%2F3.6.2%2F&ts=1410420232&use_mirror=jaist
# tar -zxvf ganglia-web-3.6.2.tar.gz


创建一个web目录, 放gweb目录, 并修改目录权限
# mkdir /data01/web
# mv /opt/soft_bak/ganglia-web-3.6.2 /data01/web/ganglia-web
修改权限
# chown -R nobody /data01/web/ganglia-web


配置nginx.conf
# vi /opt/nginx1.6.0/conf/nginx.conf
user  nobody;
worker_processes  3;
error_log  logs/error.log;
pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;
        root   /data01/web/ganglia-web;
        location / {
            root   /data01/web/ganglia-web;
            index  index.html index.htm index.php;
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        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;
        }
    }
}


启动nginx
# nginx -c /opt/nginx1.6.0/conf/nginx.conf

配置gweb conf.php
# cd /data01/web/ganglia-web/
# cp conf_default.php conf.php
可能需要修改的地方如下 : 
# vi conf.php
$conf['gweb_confdir'] = "/data01/web/ganglia-web";
# Where gmetad stores the rrd archives.
$conf['gmetad_root'] = "/opt/ganglia-core-3.6.0";
$conf['rrds'] = "/data01/rrd";
#
# If you want to grab data from a different ganglia source specify it here.
# Although, it would be strange to alter the IP since the Round-Robin
# databases need to be local to be read.
#
$conf['ganglia_ip'] = "127.0.0.1";
$conf['ganglia_port'] = 8652;
# Leave this alone if rrdtool is installed in $conf['gmetad_root'],
# otherwise, change it if it is installed elsewhere (like /usr/bin)
$conf['rrdtool'] = "/opt/rrdtool1.4.8/bin/rrdtool";

打开WEB页面
http://172.16.3.221
gweb  nginx configure - 德哥@Digoal - PostgreSQL research

gweb视图 : 
gweb  nginx configure - 德哥@Digoal - PostgreSQL research
注意左下角的热度视图 :  
gweb  nginx configure - 德哥@Digoal - PostgreSQL research
物理视图
gweb  nginx configure - 德哥@Digoal - PostgreSQL research
主机视图
gweb  nginx configure - 德哥@Digoal - PostgreSQL research
节点视图, 包括节点位置rack rank plane
主机硬件, 软件, LOAD, CPU等场景信息.
gweb  nginx configure - 德哥@Digoal - PostgreSQL research

WEB页面错误解决办法 : 
错误1 : 

Fatal error: 
Errors were detected in your configuration.
?DWOO compiled templates directory '/data01/web/ganglia-web/dwoo/compiled' is not writeable.
Please adjust $conf['dwoo_compiled_dir'].
?DWOO cache directory '/data01/web/ganglia-web/dwoo/cache' is not writeable.
Please adjust $conf['dwoo_cache_dir'].
in /data01/web/ganglia-web/eval_conf.php on line 126
解决办法 : 
[root@db-172-16-3-221 ganglia-web]# mkdir -p /data01/web/ganglia-web/dwoo/compiled
[root@db-172-16-3-221 ganglia-web]# mkdir -p /data01/web/ganglia-web/dwoo/cache
[root@db-172-16-3-221 ganglia-web]# chown -R nobody /data01/web/ganglia-web


错误2 : 
图片无法显示
解决办法 : 
配置正确的rrdtool路径. 例如:
# vi conf.php
$conf['rrdtool'] = "/opt/rrdtool1.4.8/bin/rrdtool";


[参考]
相关文章
|
应用服务中间件 nginx
nginx安装报错/configure: error: the HTTP gzip module requires the zlib library.
反向代理服务器的工作原理 反向代理服务器通常有两种模型,它可以作为内容服务器的替身,也可以作为内容服务器集群的负载均衡器。 1,作内容服务器的替身 如果您的内容服务器具有必须保持安全的敏感信息,如信用卡号数据库,可在防火墙外部设置一个代理服务器作为内容服务器的替身。
3669 0
|
JavaScript Unix 应用服务中间件
《深入理解Nginx:模块开发与架构解析》一1.5 configure详解
本节书摘来自华章出版社《深入理解Nginx:模块开发与架构解析》一书中的第1章,第1.5节,作者 陶辉,更多章节内容可以访问云栖社区“华章计算机”公众号查看
2172 0
|
应用服务中间件 nginx
nginx configure fastdfs + SSL
./configure \ --prefix=/usr/local/nginx \ --with-http_stub_status_module \ --with-http_ssl_module \ --pid-path=/var/run/nginx/nginx.
1114 0
|
应用服务中间件 PHP 数据安全/隐私保护
|
缓存 应用服务中间件 Linux
centos下编译安装nginx|configure参数对照列表
4.Nginx的configure脚本支持的选项。(可以通过  ./configure  --help命令查看Nginx可选择的编译选项,以下仅列出本人比较常用的选项) --prefix=   ——Nginx安装路径,如果没有指定,默认为  /usr/local/nginx   --sbin-path=  ——Nginx可执行文件安装路径。
874 0
|
22天前
|
运维 前端开发 应用服务中间件
LNMP详解(八)——Nginx动静分离实战配置
LNMP详解(八)——Nginx动静分离实战配置
24 0
|
1月前
|
应用服务中间件 nginx
Nginx中如何配置中文域名?
Nginx中如何配置中文域名?
40 0
|
21天前
|
前端开发 应用服务中间件 nginx
Nginx配置详解Docker部署Nginx使用Nginx部署vue前端项目
Nginx配置详解Docker部署Nginx使用Nginx部署vue前端项目
83 0