现在的位置: 首页 > 综合 > 正文

opentsdb的安装与配置(centos6.2)

2018年04月09日 ⁄ 综合 ⁄ 共 2996字 ⁄ 字号 评论关闭

1.介绍

开源监控系统OpenTSDB,用hbase存储所有的时序(无须 采样)来构建一个分布式、可伸缩的时间序列数据库。它支持秒级数据采集所有metrics,支持永久存储,可以做容量规划,并很容易的接入到现有的报警系统里。OpenTSDB可以从大规模的集群(包括集群中的网络设备、操作系统、应用程序)中获取相应的metrics并进行存储、索引以及服务,从而使得这些数据更容易让人理解,如web化,图形化等。

2.安装

  • 安装autoconf

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

yum install gnuplot

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

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

  • 安装autoconf
Autoconf是一个用于生成可以自动地配置软件源代码包以适应多种Unix类系统的 shell脚本的工具。由Autoconf生成的配置脚本在运行的时候与Autoconf是无关的, 就是说配置脚本的用户并不需要拥有Autoconf。

yum install autoconf

  • 安装git

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

  • 下载opentsdb源码

git clone git://github.com/stumbleupon/opentsdb.git
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=/opt/hbase/hbase-0.94.3.jar /opt/opentsdb/src/create_table.sh

启动tsd服务
./build/tsdb tsd --port=4242 --staticroot=build/staticroot --cachedir="/tmp/tsdtmp" --zkquorum 192.168.1.11

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 traditional blocking io
  --auto-metric         Automatically add metrics to tsdb as they are inserted.  Warning: this may cause unexpected metrics to be tracked
  --cachedir=PATH       Directory under which to cache result of requests.
  --flush-interval=MSEC Maximum time for which a new data point can be buffered (default: 1000).
  --port=NUM            TCP port to listen on.
  --staticroot=PATH     Web root from which to serve static files (/s URLs).
  --table=TABLE         Name of the HBase table where to store the time series (default: tsdb).
  --uidtable=TABLE      Name of the HBase table to use for Unique IDs (default: tsdb-uid).
  --worker-threads=NUM  Number for async io workers (default: cpu * 2).
  --zkbasedir=PATH      Path under which is the znode for the -ROOT- region (default: /hbase).
  --zkquorum=SPEC       Specification of the ZooKeeper quorum to use (default: localhost).

以下是tsdb可运行的命令

usage: tsdb <command> [args]
Valid commands: fsck, import, mkmetric, query, tsd, scan, uid

4.测试

编写脚本并运行

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 host.name.of.tsd PORT
EOF
chmod +x loadavg-collector.sh
nohup ./loadavg-collector.sh &

红字部分换成启动tsd服务的服务器IP和端口

每隔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

使用浏览器登陆 TSD IP:端口,在metrics里分别添加“proc.loadavg.1m”和“proc.loadavg.5m”,就能在图表中看到监控信息了

5.总结

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

http://blog.csdn.net/wufg2002adai/article/details/8493545

http://1054383.blog.51cto.com/1044383/965987

http://opentsdb.net/getting-started.html

抱歉!评论已关闭.