OpenTSDB 安装
生活随笔
收集整理的這篇文章主要介紹了
OpenTSDB 安装
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
下載目錄
https://github.com/OpenTSDB/opentsdb/releases https://github.com/OpenTSDB/opentsdb/releases/download/v2.4.0/opentsdb-2.4.0.noarch.rpm安裝 GnuPlot
yum install gnuplot -y直接安裝OpenTSDB會報錯
[root@ecs-t-001-0001 openTSDB]# rpm -ivh opentsdb-2.4.0.noarch.rpmerror: Failed dependencies: gnuplot is needed by opentsdb-2.4.0-1.noarch?安裝OpenTSDB
[root@ecs opt]# rpm -ivh opentsdb-2.4.0.noarch.rpm Preparing... ################################# [100%] Updating / installing...1:opentsdb-2.4.0-1 ################################# [100%]默認配置目錄
/etc/opentsdb - Configuration files /tmp/opentsdb - Temporary cache files /usr/share/opentsdb - Application files /usr/share/opentsdb/bin - The "tsdb" startup script that launches a TSD or commandline tools /usr/share/opentsdb/lib - Java JAR library files /usr/share/opentsdb/plugins - Location for plugin files and dependencies /usr/share/opentsdb/static - Static files for the GUI /usr/share/opentsdb/tools - Scripts and other tools /var/log/opentsdb - Logs修改配置
進入目錄 /usr/share/opentsdb/etc/opentsdb 修改配置文件 opentsdb.conf
> vim opentsdb.conftsd.storage.hbase.zk_quorum = zk:2181 tsd.network.port = 10080 tsd.http.staticroot = /usr/share/opentsdb/static/ tsd.http.cachedir = /tmp/opentsdb tsd.core.plugin_path = /usr/share/opentsdb/plugins初始化OpenTSDB表
進入目錄/usr/share/opentsdb/tools,修改create_table.sh
我們加入的內容
HBASE_HOME=/opt/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/lib/hbase COMPRESSION=SNAPPY?全部內容
[root@ecs tools]# cat create_table.sh #!/bin/sh # Small script to setup the HBase tables used by OpenTSDB.HBASE_HOME=/opt/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/lib/hbase COMPRESSION=SNAPPYtest -n "$HBASE_HOME" || {echo >&2 'The environment variable HBASE_HOME must be set'exit 1 } test -d "$HBASE_HOME" || {echo >&2 "No such directory: HBASE_HOME=$HBASE_HOME"exit 1 }TSDB_TABLE=${TSDB_TABLE-'tsdb'} UID_TABLE=${UID_TABLE-'tsdb-uid'} TREE_TABLE=${TREE_TABLE-'tsdb-tree'} META_TABLE=${META_TABLE-'tsdb-meta'} BLOOMFILTER=${BLOOMFILTER-'ROW'} # LZO requires lzo2 64bit to be installed + the hadoop-gpl-compression jar. COMPRESSION=${COMPRESSION-'LZO'} # All compression codec names are upper case (NONE, LZO, SNAPPY, etc). COMPRESSION=`echo "$COMPRESSION" | tr a-z A-Z` # DIFF encoding is very useful for OpenTSDB's case that many small KVs and common prefix. # This can save a lot of storage space. DATA_BLOCK_ENCODING=${DATA_BLOCK_ENCODING-'DIFF'} DATA_BLOCK_ENCODING=`echo "$DATA_BLOCK_ENCODING" | tr a-z A-Z` TSDB_TTL=${TSDB_TTL-'FOREVER'}case $COMPRESSION in(NONE|LZO|GZIP|SNAPPY) :;; # Known good.(*)echo >&2 "warning: compression codec '$COMPRESSION' might not be supported.";; esaccase $DATA_BLOCK_ENCODING in(NONE|PREFIX|DIFF|FAST_DIFF|ROW_INDEX_V1) :;; # Know good(*)echo >&2 "warning: encoding '$DATA_BLOCK_ENCODING' might not be supported.";; esac# HBase scripts also use a variable named `HBASE_HOME', and having this # variable in the environment with a value somewhat different from what # they expect can confuse them in some cases. So rename the variable. hbh=$HBASE_HOME unset HBASE_HOME exec "$hbh/bin/hbase" shell <<EOF create '$UID_TABLE',{NAME => 'id', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'},{NAME => 'name', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'}create '$TSDB_TABLE',{NAME => 't', VERSIONS => 1, COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING', TTL => '$TSDB_TTL'}create '$TREE_TABLE',{NAME => 't', VERSIONS => 1, COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'}create '$META_TABLE',{NAME => 'name', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'} EOF創建成功
[root@ecs tools]# sh create_table.sh HBase Shell Use "help" to get list of supported commands. Use "exit" to quit this interactive shell. For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell Version 2.1.0-cdh6.3.2, rUnknown, Fri Nov 8 05:44:07 PST 2019 Took 0.0006 seconds create 'tsdb-uid',{NAME => 'id', COMPRESSION => 'SNAPPY', BLOOMFILTER => 'ROW', DATA_BLOCK_ENCODING => 'DIFF'},{NAME => 'name', COMPRESSION => 'SNAPPY', BLOOMFILTER => 'ROW', DATA_BLOCK_ENCODING => 'DIFF'} Created table tsdb-uid Took 1.0398 seconds Hbase::Table - tsdb-uidcreate 'tsdb',{NAME => 't', VERSIONS => 1, COMPRESSION => 'SNAPPY', BLOOMFILTER => 'ROW', DATA_BLOCK_ENCODING => 'DIFF', TTL => 'FOREVER'} Created table tsdb Took 0.7233 seconds Hbase::Table - tsdbcreate 'tsdb-tree',{NAME => 't', VERSIONS => 1, COMPRESSION => 'SNAPPY', BLOOMFILTER => 'ROW', DATA_BLOCK_ENCODING => 'DIFF'} Created table tsdb-tree Took 0.7198 seconds Hbase::Table - tsdb-treecreate 'tsdb-meta',{NAME => 'name', COMPRESSION => 'SNAPPY', BLOOMFILTER => 'ROW', DATA_BLOCK_ENCODING => 'DIFF'} Created table tsdb-meta Took 0.7197 seconds Hbase::Table - tsdb-meta啟動TSDB
nohup sh /usr/share/opentsdb/bin/tsdb tsd >tsdb-start.log &?訪問頁面
?
?
寫入數據
上面如果沒有設置 tsd.core.auto_create_metrics = true 參數時,需要手動創建 metric
tsdb mkmetric sys.cpu.user否則會提示異常如下
[root@ecs-t-001-0002 ~]# telnet ip port Escape character is '^]'. put sys.cpu.user 1588302377 42.5 host=webserver01 cpu=0 put: unknown metric: No such name for 'metrics': 'sys.cpu.user'?
加入兩條數據,我們使用 telnet 方式添加數據,
put sys.cpu.user 1588292377 45.5 host=webserver01 cpu=0 put sys.cpu.user 1588302377 41.5 host=webserver01 cpu=0?
再web頁面我們簡單查詢看一下數據,右下角的一根線就是我們剛剛插入的兩個點連成的線
這回我們插入四條數據,寫入兩個host
put sys.cpu.user 1588292377 45.5 host=webserver01 cpu=0 put sys.cpu.user 1588302377 41.5 host=webserver01 cpu=0 put sys.cpu.user 1588292377 12.5 host=webserver02 cpu=0 put sys.cpu.user 1588302377 80.5 host=webserver02 cpu=0我們再指定tags查詢看看效果,指定webserver02小時如下,結果是從12.5-80.5兩個點沒問題
看下webserver01,數據也沒問題
至此,服務安裝與初步使用介紹完成,下一步介紹下Api接口使用
?
?
?
總結
以上是生活随笔為你收集整理的OpenTSDB 安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Storm tick 功能
- 下一篇: Windows驱动程序运行时函数的调用