转:openTSDB 2.0 安装
OpenTSDB-2.0.0安裝布署??
2014-02-27 11:07:49|??分類:?大數(shù)據(jù)?|??標(biāo)簽:hadoop??|舉報|字號?訂閱
1、介紹
OpenTSDB是一個架構(gòu)在Hbase系統(tǒng)之上的實(shí)時監(jiān)控信息收集和展示平臺。它支持秒級數(shù)據(jù)采集所有metrics,支持永久存儲,可以做容量規(guī)劃,并很容易的接入到現(xiàn)有的報警系統(tǒng)里。OpenTSDB可以從大規(guī)模的集群(包括集群中的網(wǎng)絡(luò)設(shè)備、操作系統(tǒng)、應(yīng)用程序)中獲取相應(yīng)的metrics并進(jìn)行存儲、索引以及服務(wù),從而使得這些數(shù)據(jù)更容易讓人理解,如web化,圖形化等。
?
2、安裝
安裝Gnuplot
Gnuplot 是一個命令行的交互式繪圖工具(command-driven interactive function plotting program)。用戶通過輸入命令,可以逐步設(shè)置或修改繪圖環(huán)境,并以圖形描述數(shù)據(jù)或函數(shù),使我們可以借由圖形做更進(jìn)一步的分析。
yum install gnuplot
如果是下載壓縮包壓縮包的話,解壓后進(jìn)入目錄分別執(zhí)行 ./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
安裝完成后執(zhí)行g(shù)nuplot,確認(rèn)支持png :執(zhí)行set terminal可以查看
如果不支持則opentsdb在畫圖時會報錯
?
安裝完后可以驗(yàn)證是否可以正常畫出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支持,采用默認(rèn)顏色設(shè)定
set output "log.png" #指定輸出png圖片的文件名
set autoscale #軸向標(biāo)記自動控制
set xdata time #X軸數(shù)據(jù)格式為時間
set timefmt "%H:%M" #時間輸入格式為"小時:分鐘"
set style data lines #數(shù)據(jù)顯示方式為連線
set xlabel "time per day" #X軸標(biāo)題
set ylabel "Mbps" #Y軸標(biāo)題
set title "image.tuku.china.com flow" #圖片標(biāo)題
set grid #顯示網(wǎng)格
plot "test.log" using 1:2 title"access_flow" #從test.log文件中讀取第一列和第二列作為X軸和Y軸數(shù)據(jù),示例名"log_flow"
最后運(yùn)行catlog.conf | gnuplot命令,就生成了log.png文件,如下:
經(jīng)常運(yùn)行一些生物信息軟件的時候,提示:Could not find/open font when opening font “arial”, using internalnon-scalable font等信息。此時,表示CentOS系統(tǒng)缺乏相應(yīng)的字體文件。需要安裝,步驟如下:
1.widonws下載字體文件到Linux
windows的字體比較多,其字體文件位于 C:\WINDOWS\Fonts。從其中copy相應(yīng)的字體到Linux系統(tǒng)的 /usr/share/font/下的文件夾中。以arial字體為例:
# mkdir/usr/share/fonts/arial
# cp arial*.ttf/usr/share/fonts/arial/
2. 為剛加入的字體設(shè)置緩存使之有效
# cd/usr/share/font/arial
# mkfontscale
# mkfontdir
# fc-cache -fv
經(jīng)過這樣的設(shè)置后,即可在Gnome界面的系統(tǒng)——首選項——外觀——字體中進(jìn)行字體的選擇了。
3. 設(shè)置gunplot對arial的選擇路徑
本文首頁提示的錯誤是由于程序調(diào)用gunplot造成,必須讓gunplot識別arial字體所在的路徑才行。
$ exportGDFONTPATH=/usr/share/fonts/arial
$ exportGNUPLOT_DEFAULT_GDFONT="arial"
Autoconf是一個用于生成可以自動地配置軟件源代碼包以適應(yīng)多種Unix類系統(tǒng)的 shell腳本的工具。由Autoconf生成的配置腳本在運(yùn)行的時候與Autoconf是無關(guān)的, 就是說配置腳本的用戶并不需要擁有Autoconf。
yum install autoconf
安裝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
執(zhí)行過程報錯,錯誤信息如下
Can't exec "aclocal": No such file or directory at/usr/share/autoconf/Autom4te/FileUtils.pm line 326.
網(wǎng)上搜了一下,發(fā)現(xiàn)缺少automake工具
yum install automake
安裝完antomake后進(jìn)入opentsdb目錄再次執(zhí)行
./build.sh
3.設(shè)置&運(yùn)行
先啟動hadoop和hbase集群
配置環(huán)境變量,在shell中執(zhí)行如下命令:
env COMPRESSION=none HBASE_HOME=/usr/hadoop/bbase0941
?? ./opentsdb/src/create_table.sh
在hbase偽分布環(huán)境下貌似要修改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'}
./build/tsdb tsd --port=4242--staticroot=build/staticroot --cachedir=/tmp/tsdtmp –zkquorum=localhost
tsd服務(wù)運(yùn)行參數(shù)說明: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可運(yùn)行的命令
usage: tsdb <command> [args]
Valid commands: fsck, import, mkmetric, query, tsd, scan, uid
4.測試
保存標(biāo)簽
./build/tsdb mkmetric proc.loadavg.1mproc.loadavg.5m
編寫腳本并運(yùn)行
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服務(wù)的服務(wù)器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”,就能在圖表中看到監(jiān)控信息,如下圖
5.總結(jié)opentsdb的表設(shè)計特點(diǎn)可以滿足時間序列的數(shù)據(jù)存儲在hbase中并能秒級相應(yīng)。適合于以固定時間間隔的數(shù)據(jù)采集,例如系統(tǒng)軟件和硬件的監(jiān)控。結(jié)合logstash可以監(jiān)控應(yīng)用log日志信息。
?
附1:centos安裝opentsdb
官方網(wǎng)站: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.安裝opentsdbgit 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是編譯后的靜態(tài)文件的存放目錄;
QueryUi是QueryUi.gwt.xml的名字,必須放在src目錄下。
Eclipse的debug configuration中的classpath中必須包括src目錄,因?yàn)閏ompiler需要有源代碼。
QueryUi.gwt.xml的內(nèi)容如下:
<?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。
開發(fā)期Eclipse運(yùn)行:
MainClass:
net.opentsdb.tools.TSDMain
Arguments:
--port=4242
--staticroot=staticroot/QueryUi
--cachedir=cachedir
--zkquorum=192.168
轉(zhuǎn)載于:https://www.cnblogs.com/legendary/p/3822360.html
總結(jié)
以上是生活随笔為你收集整理的转:openTSDB 2.0 安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 解答网友shell问题一例2014070
- 下一篇: 数学图形(1.5)克莱线