1 安装
1.1下载openTSDB,地址如右:https://github.com/OpenTSDB/opentsdb/releases 下载tar.gz包。1.2 解压缩:tar -zxvf opentsdb-2.3.0.tar.gz -C /usr/local1.3 开始编译opentsdb,./build.sh会报错:解决方法:
opentsdb目录下,mkdir build
cp -r third_party ./build ./build.sh 然后编译成功。【编译成功的标志是在openTSDB父目录下生成build文件夹,并且会生成一个jar包:tsdb-2.3.0.jar】
1.4 接着执行脚本,创建openTSDB所需要的表,这些命令均已写好,只需要执行相应脚本即可env COMPRESSION=NONE HBASE_HOME=xxxxx/hbase ./src/create_table.sh
1.5 mv opentsdb.conf src/opentsdb.conf配置内容如下【这里只列举出需要修改的配置项】:tsd.network.port =4242
tsd.http.staticroot = ./staticroot
tsd.http.cachedir =/xxxxx/opentsdb/tsdb_cache
tsd.core.auto_create_metrics = true tsd.storage.hbase.zk_quorum = master,node1,node2
1.6 运行openTSDB,执行命令: build/tsdb tsd --config=src/opentsdb.conf2 openTSDB效果展示
2.1 http://master:4242/
2.2 插入数据
url http://master:4242/api/put?details
post方式
json数据:
[
{
"metric": "sys.cpu.data",
"timestamp": "1599113250",
"value": "33",
"tags": {
"host": "web01"
}
},
{
"metric": "sys.cpu.data",
"timestamp": "1599113220",
"value": "29",
"tags": {
"host": "web02"
}}
]