1.下载安装介质
我这里下载的是opentsdb-2.3.2.noarch.rpm
2.安装GnuPlot
yum install gnuplot
3.安装
[root@localhost soft]# rpm -ivh opentsdb-2.3.2.noarch.rpm
opentsdb会安装到 /usr/share/ 下
4.配置
$ cd /usr/share/opentsdb
$ vim /usr/share/opentsdb/etc/opentsdb/opentsdb.conf
tsd.network.port = 4242
tsd.network.bind = 0.0.0.0
tsd.network.worker_threads = 8
tsd.http.staticroot = build/staticroot
tsd.http.cachedir = /tmp/opentsdb
tsd.core.auto_create_metrics = true
tsd.storage.hbase.zk_quorum = localhost:2181
5.在Hbase中创建表
$ cd /usr/share/opentsdb
$ env COMPRESSION=NONE HBASE_HOME=/opt/hbase-1.2.1 ./tools/create_table.sh
我这里的hbase是1.2.1的,直接脚本的时候发现tsdb表报错误
create 'tsdb',
{NAME => 't', VERSIONS => 1, COMPRESSION => 'NONE', BLOOMFILTER => 'ROW', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER'}
ERROR: For input string: "FOREVER"
我将TTL => 'FOREVER'去掉后单独执行成功
6.启动
$ cd /usr/share/opentsdb
$ bash bin/tsdb tsd &
[1] 251022
7.登陆
8.如何使用
创建metric
使用如下命令
tsdb mkmetric sys.cpu.user
写入数据
作为测试,我们可以使用telnet接口写入两条数据:
# telnet localhost 4242
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
put sys.cpu.user 1356998400 42.5 host=webserver01 cpu=0
put sys.cpu.user 1356999400 42.7 host=webserver01 cpu=0
读取数据
可以使用命令行读取刚才写入的两条数据:
# tsdb query 1356998400 1356999400 sum sys.cpu.user
sys.cpu.user 1356998400000 42.500000 {host=webserver01, cpu=0}
sys.cpu.user 1356999400000 42.700001 {host=webserver01, cpu=0}
api方式查询
/api/query?
{
"start": 1356998400,
"end": 1356999400,
"queries": [{
"aggregator": "none",
"metric": "sys.cpu.user"
}]
}
阅读(5577) | 评论(0) | 转发(0) |