OpenTSDB安装

 

时序数据库

  • 时序数据库全称为时间序列数据库。主要用于处理带时间标签(按照时间的顺序变化,即时间序列化)的数据,带时间标签的数据也称为时间序列数据。时间序列数据主要由电力行业、化工行业、物联网行业等各类型实时监测、检查与分析设备所采集、产生的数据,这些数据的典型特点是:产生频率快(每一个监测点一秒钟内可产生多条数据)、严重依赖于采集时间(每一条数据均要求对应唯一的时间)、测点多信息量大(常规的实时监测系统均有成千上万的监测点,监测点每秒钟都产生数据,每天产生几十GB的数据量)。

  • 时序数据库最新排名(DB-Engines):

  

OpenTSDB介绍

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

  2. 底层使用Hbase作为其分布式存储引擎,采用的也是LSM tree。

安装

  • 安装依赖
jdk
hbase
  • Opentsdb依赖Gnuplot,它 是一个命令行的交互式绘图工具。用户通过输入命令,可以逐步设置或修改绘图环境,并以图形描述数据或函数,使我们可以借由图形做更进一步的分析。
yum install gnuplot
  • 下载源码包:
wget https://github.com/OpenTSDB/opentsdb/releases/download/v2.3.0/opentsdb-2.3.0.tar.gz
  • 解压:
tar zxvf opentsdb-2.3.0.tar.gz 
  • 进目录
cd opentsdb-2.3.0
  • 编译安装
./build.sh 
cd build
make install

配置OpenTSDB

# vim ./opentsdb.conf
# The TCP port TSD should use for communications
# *** REQUIRED ***
tsd.network.port = 4242
# The location of static files for the HTTP GUI interface.
# *** REQUIRED ***
tsd.http.staticroot =build/staticroot
# Where TSD should write it's cache files to
# *** REQUIRED ***
tsd.http.cachedir = /tmp/tsd
# Whether or not to automatically create UIDs for new metric types, default is False
tsd.core.auto_create_metrics = true
# A comma separated list of Zookeeper hosts to connect to
tsd.storage.hbase.zk_quorum = cdhmanager:2181
# Cover duplicates data
tsd.storage.fix_duplicates = true

配置参数优先级:命令行参数 > 配置文件 > 默认值

你可以在命令行中通过--config指定配置文件所在路径,如果没有指定,OpenTSDB会从以下路径寻找配置文件:

  • ./opentsdb.conf
  • /etc/opentsdb.conf
  • /etc/opentsdb/opentsdb.conf
  • /opt/opentsdb/opentsdb.conf
protected void loadConfig() throws IOException {
    if (config_location != null && !config_location.isEmpty()) {
      loadConfig(config_location);
      return;
    }

    final ArrayList<String> file_locations = new ArrayList<String>();

    // search locally first
    file_locations.add("opentsdb.conf");

    // add default locations based on OS
    if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")) {
      file_locations.add("C:\\Program Files\\opentsdb\\opentsdb.conf");
      file_locations.add("C:\\Program Files (x86)\\opentsdb\\opentsdb.conf");
    } else {
      file_locations.add("/etc/opentsdb.conf");
      file_locations.add("/etc/opentsdb/opentsdb.conf");
      file_locations.add("/opt/opentsdb/opentsdb.conf");
    }

    for (String file : file_locations) {
      try {
        FileInputStream file_stream = new FileInputStream(file);
        Properties props = new Properties();
        props.load(file_stream);
        
        // load the hash map
        loadHashMap(props);        
      } catch (Exception e) {
        // don't do anything, the file may be missing and that's fine
        LOG.debug("Unable to find or load " + file, e);
        continue;
      }

      // no exceptions thrown, so save the valid path and exit
      LOG.info("Successfully loaded configuration file: " + file);
      config_location = file;
      return;
    }

    LOG.info("No configuration found, will use defaults");
  }

创建表

env COMPRESSION=NONE HBASE_HOME=/usr ./src/create_table.sh
  • COMPRESSION=NONE,不使用压缩。如使用则需修改hadoop配置。

  • 脚本会在hbase中自动创建tsdb所用到的表

create 'tsdb-uid',
  {NAME => 'id', COMPRESSION => 'NONE', BLOOMFILTER => 'ROW'},
  {NAME => 'name', COMPRESSION => 'NONE', BLOOMFILTER => 'ROW'}
0 row(s) in 3.3470 seconds

Hbase::Table - tsdb-uid

create 'tsdb',
  {NAME => 't', VERSIONS => 1, COMPRESSION => 'NONE', BLOOMFILTER => 'ROW'}
0 row(s) in 0.3780 seconds

Hbase::Table - tsdb
  
create 'tsdb-tree',
  {NAME => 't', VERSIONS => 1, COMPRESSION => 'NONE', BLOOMFILTER => 'ROW'}
0 row(s) in 0.4340 seconds

Hbase::Table - tsdb-tree
  
create 'tsdb-meta',
  {NAME => 'name', COMPRESSION => 'NONE', BLOOMFILTER => 'ROW'}
0 row(s) in 0.3780 seconds

log

logback.xml 配置文件放入src目录中即可

start

nohup /opt/opentsdb-2.3.0/build/tsdb tsd --config=/opt/opentsdb-2.3.0/src/opentsdb.conf >/dev/null 2>&1  &

访问页面

http://127.0.0.1:4242

猜你喜欢

转载自blog.csdn.net/wangshuminjava/article/details/82319439