zoukankan      html  css  js  c++  java
  • 转:openTSDB 2.0 安装

    OpenTSDB-2.0.0安装布署  

    2014-02-27 11:07:49|  分类: 大数据 |  标签:hadoop  |举报|字号 订阅

     
     

    1、介绍
    OpenTSDB是一个架构在Hbase系统之上的实时监控信息收集和展示平台。它支持秒级数据采集所有metrics,支持永久存储,可以做容量规划,并很容易的接入到现有的报警系统里。OpenTSDB可以从大规模的集群(包括集群中的网络设备、操作系统、应用程序)中获取相应的metrics并进行存储、索引以及服务,从而使得这些数据更容易让人理解,如web化,图形化等。

    2、安装
    安装Gnuplot
    Gnuplot 是一个命令行的交互式绘图工具(command-driven interactive function plotting program)。用户通过输入命令,可以逐步设置或修改绘图环境,并以图形描述数据或函数,使我们可以借由图形做更进一步的分析。
    yum install gnuplot

    如果是下载压缩包压缩包的话,解压后进入目录分别执行 ./configure; make; make check; make install

    下载压缩包安装过程如下:
    # based on a minimal installation, you need some packages in order to compile, I suggest
    yum install gcc gcc-c++ make libX11 xauth
    yum install cairo-devel pango-devel freetype-devel gd-devel

    cd /usr/local/src/
    wget http://sourceforge.net/projects/gnuplot/files/gnuplot/4.4.2/gnuplot-4.4.2.tar.gz/download
    tar xzf gnuplot-4.4.2.tar.gz
    cd gnuplot-4.4.2
    less INSTALL

    # start compiling. I usually install self-compiled stuff at /opt/[PKG-NAME]
    ./configure --prefix=/opt/gnuplot442
    make
    # make sure the shipped version of gnuplot is removed (this is probably not necessary but prevents version mix-up)
    yum remove gnuplot
    make install

    # you might want to add a symlink
    ln -s /opt/gnuplot442/bin/gnuplot /usr/bin/gnuplot

    安装完成后执行gnuplot,确认支持png :执行set terminal可以查看
    如果不支持则opentsdb在画图时会报错

    安装完后可以验证是否可以正常画出png图片,画png图片示例如下:

    [root@centos]#vim test.log
    23:14 506.877
    23:19 501.068
    23:24 493.254
    23:29 469.184
    23:34 460.161
    23:39 426.065
    23:44 429.734
    23:49 409.255
    23:54 423.512
    23:59 390.676
    然后编写gnuplot的配置文件如下:
    [root@centos]#vim log.conf
    set terminal png truecolor size 550,250 #指定输出成png图片,且图片大小为550×250,需要ligpng支持,采用默认颜色设定
    set output "log.png" #指定输出png图片的文件名
    set autoscale #轴向标记自动控制
    set xdata time #X轴数据格式为时间
    set timefmt "%H:%M" #时间输入格式为"小时:分钟"
    set style data lines #数据显示方式为连线
    set xlabel "time per day" #X轴标题
    set ylabel "Mbps" #Y轴标题
    set title "image.tuku.china.com flow" #图片标题
    set grid #显示网格
    plot "test.log" using 1:2 title"access_flow" #从test.log文件中读取第一列和第二列作为X轴和Y轴数据,示例名"log_flow"
    最后运行catlog.conf | gnuplot命令,就生成了log.png文件,如下:

    OpenTSDB-2.0.0安装布署 - 任老石 - 任老石的博客
    画png图需要有arial字体支持,centos中arial字体安装方法如下:

    经常运行一些生物信息软件的时候,提示:Could not find/open font when opening font arial”, using internalnon-scalable font等信息。此时,表示CentOS系统缺乏相应的字体文件。需要安装,步骤如下:
    1.widonws下载字体文件到Linux
    windows的字体比较多,其字体文件位于 C:WINDOWSFonts。从其中copy相应的字体到Linux系统的 /usr/share/font/下的文件夹中。以arial字体为例:
    # mkdir/usr/share/fonts/arial
    # cp arial*.ttf/usr/share/fonts/arial/
    2. 为刚加入的字体设置缓存使之有效
    # cd/usr/share/font/arial
    # mkfontscale
    # mkfontdir
    # fc-cache -fv
    经过这样的设置后,即可在Gnome界面的系统——首选项——外观——字体中进行字体的选择了。
    3. 设置gunplotarial的选择路径
    本文首页提示的错误是由于程序调用gunplot造成,必须让gunplot识别arial字体所在的路径才行。
    $ exportGDFONTPATH=/usr/share/fonts/arial
    $ exportGNUPLOT_DEFAULT_GDFONT="arial"

    gnuplot画图技巧

    安装git
    yum -y install zlib-devel openssl-devel perl cpio expat-devel gettext-devel
    yum install git


    下载opentsdb2.0.0源码
    //git clone git://github.com/stumbleupon/opentsdb.git

    https://github.com/OpenTSDB/opentsdb/releases/tag/v2.0.0RC1
    cd opentsdb
    ./build.sh

    执行过程报错,错误信息如下
    Can't exec "aclocal": No such file or directory at/usr/share/autoconf/Autom4te/FileUtils.pm line 326.

    网上搜了一下,发现缺少automake工具
    yum install automake
    安装完antomake后进入opentsdb目录再次执行
    ./build.sh

    3.设置&运行
    先启动hadoop和hbase集群
    配置环境变量,在shell中执行如下命令:
    env COMPRESSION=none HBASE_HOME=/usr/hadoop/bbase0941

       ./opentsdb/src/create_table.sh
    在hbase伪分布环境下貌似要修改create_table.sh,否则建表会卡住:

    exec"$hbh/bin/hbase" shell <<EOF
    create'$UID_TABLE','id', 'name'
    # {NAME => 'id', COMPRESSION =>'$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'},
    # {NAME => 'name', COMPRESSION =>'$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}

    create'$TSDB_TABLE','t'
    # {NAME => 't', VERSIONS => 1,COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}

    create'$TREE_TABLE','t'
    # {NAME => 't', VERSIONS => 1,COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}

    create'$META_TABLE','name'
    # {NAME => 'name', COMPRESSION =>'$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}

    启动tsd服务

    ./build/tsdb tsd --port=4242--staticroot=build/staticroot --cachedir=/tmp/tsdtmp zkquorum=localhost

    tsd服务运行参数说明:
    Usage: tsd --port=PORT --staticroot=PATH --cachedir=PATH
    Starts the TSD, the Time Series Daemon
      --async-io=true|false Use async NIO (default true) or traditionalblocking io
      --auto-metric        Automatically add metrics to tsdb as they are inserted.  Warning:this may cause unexpected metrics to be tracked
      --cachedir=PATH       Directory underwhich to cache result of requests.
      --flush-interval=MSEC Maximum time for which a new data point canbe buffered (default: 1000).
      --port=NUM            TCPport to listen on.
      --staticroot=PATH     Web root from which toserve static files (/s URLs).
      --table=TABLE         Nameof the HBase table where to store the time series (default: tsdb).
      --uidtable=TABLE      Name of theHBase table to use for Unique IDs (default: tsdb-uid).
      --worker-threads=NUM  Number for async io workers(default: cpu * 2).
      --zkbasedir=PATH      Path underwhich is the znode for the -ROOT- region (default: /hbase).
      --zkquorum=SPEC       Specificationof the ZooKeeper quorum to use (default: localhost).


    以下是tsdb可运行的命令
    usage: tsdb <command> [args]
    Valid commands: fsck, import, mkmetric, query, tsd, scan, uid

    4.测试

    保存标签

    ./build/tsdb mkmetric proc.loadavg.1mproc.loadavg.5m


    编写脚本并运行
    cat >loadavg-collector.sh <<EOF
    #!/bin/bash
    set -e
    while true; do
      awk -v now=`date +%s` -v host=`hostname`
      '{ print "put proc.loadavg.1m " now " " $1" host=" host;
         print "put proc.loadavg.5m " now "" $2 " host=" host }' /proc/loadavg
      sleep 15
    done | nc -w 30 192.168.145.1294242
    EOF
    chmod +x loadavg-collector.sh
    nohup ./loadavg-collector.sh &
    红字部分换成启动tsd服务的服务器IP和端口

    vimnohup.out 可能显示-bash nc: not command found需要安装nc

    yuminstall nc


    每隔15秒会输出如下信息到tsd
    put proc.loadavg.1m 1288946927 0.36 host=foo
    put proc.loadavg.5m 1288946927 0.62 host=foo
    put proc.loadavg.1m 1288946942 0.43 host=foo
    put proc.loadavg.5m 1288946942 0.62 host=foo

    使用浏览器登陆 192.168.145.129:4242,在from、to中选择好时间范围,在metrics里输入 “proc.loadavg.1m”,就能在图表中看到监控信息,如下图OpenTSDB-2.0.0安装布署 - 任老石 - 任老石的博客

    5.总结opentsdb的表设计特点可以满足时间序列的数据存储在hbase中并能秒级相应。适合于以固定时间间隔的数据采集,例如系统软件和硬件的监控。结合logstash可以监控应用log日志信息。

    附1:centos安装opentsdb

       官方网站:http://opentsdb.net/getting-started.html(更新autoconf,automake到最新版)

    1.安装gnuplot-4.4.6:http://www.gnuplot.info/

     

         wget  http://nchc.dl.sourceforge.net/project/gnuplot/gnuplot/4.6.0/gnuplot-4.6.0.tar.gz

       cd gnuplot-4.4.6

       ./configure

       make

       make install

    2.安装git:http://my.oschina.net/lgc/blog/5370

      yum -y install zlib-devel openssl-devel perlcpio expat-devel gettext-devel 

      wgethttp://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz 

      tar xzvf git-latest.tar.gz 

      cd git-{date} 

      autoconf 

      ./configure --with-curl=/usr/local 

      make & make install 

    3.安装opentsdb

    git clonegit://github.com/stumbleupon/opentsdb.git

      cd opentsdb

      ./build.sh

      env COMPRESSION=noneHBASE_HOME=path/to/hbase-0.92.X  ./src/create_table.sh

    修改/usr/local/opentsdb/build/tsdb

    vi /usr/local/opentsdb/build/tsdb

    abs_srcdir=

    abs_builddir=

    修改为如下

    abs_srcdir='/usr/local/opentsdb/build/..'(opentsdb安装位置)

    abs_builddir='/usr/local/opentsdb/build'(opentsdb安装位置)

     

      tsdtmp=${TMPDIR-'/tmp'}/tsd    # Forbest performance, make sure

      mkdir -p "$tsdtmp"            # your temporary directory uses tmpfs

      ./build/tsdb tsd --port=4242--staticroot=build/staticroot --cachedir="$tsdtmp"--zkquorum=10.96.80.156,10.96.80.152

    zkquorum表示zookeeper的位置
     

    附2:OpenTsdb的eclipse配置

    编译期:
    MainClass:com.google.gwt.dev.Compiler
    Arguments:-war staticroot  QueryUi,其中staticroot是编译后的静态文件的存放目录;
    QueryUi是QueryUi.gwt.xml的名字,必须放在src目录下。

    Eclipse的debug configuration中的classpath中必须包括src目录,因为compiler需要有源代码。


    QueryUi.gwt.xml的内容如下:
    <?xml version="1.0" encoding="UTF-8"?>
    <module>
      <inherits name="com.google.gwt.user.User"/>
      <inheritsname="com.google.gwt.user.theme.standard.Standard"/>
      <inherits name="com.google.gwt.http.HTTP"/>
      <inherits name="com.google.gwt.json.JSON"/>
      <entry-point class="tsd.client.QueryUi"/>
      <source path="tsd"/>
    </module>
    其中,tsd.client.QueryUi是类全名。类全名中必须有client。




    开发期Eclipse运行:
    MainClass:
    net.opentsdb.tools.TSDMain
    Arguments:
    --port=4242
    --staticroot=staticroot/QueryUi
    --cachedir=cachedir
    --zkquorum=192.168
  • 相关阅读:
    Oracle JET Model 数据获取与使用
    Windows 10 安装MySQL 8.0.11
    Windows安装JDK9
    Centos安装JDK
    Centos7下安装php-redis扩展及简单使用
    XAMPP开启虚拟目录
    centos7.2 环境下配置 Apache2.4 +PHP5.6+Redis+Supervisord
    CentOS 7 开放3306端口访问
    编译Apache时,如何enable所有组件
    LINUX创建www的用户组和用户,并且不允许登录权限:
  • 原文地址:https://www.cnblogs.com/legendary/p/3822360.html
Copyright © 2011-2022 走看看