OpenTSDB分布式集群安装

  • Post author:
  • Post category:其他



1  安装前提

确保安装了jdk

确 安装了hbase的集群

192.168.100.200   master  (zk、namenode、resourcemanager、HMaster、TSDMain)

192.168.100.201   slave1    (zk、datanode、nodemanager、HRegionServer、TSDMain)

192.168.100.202  slave2     (zk、datanode、nodemanager、HRegionServer、TSDMain)



说明:TSDMain即openTSDB的进程,openTSDB本身没有分布式的实现方案,而是借助于HBase的分布式集群方案



也就是说,master、slave1、slave2三个物理节点之上的openTSDB访问同一个HBase集群,返回相同的数据镜像


2 安装gnuplot

Opentsdb运行需要gnuplot 插件

rpm -ivh gnuplot-common-4.6.2-3.el7.x86_64.rpm

rpm -ivh gnuplot-4.6.2-3.el7.x86_64.rpm


3 验证gnuplot的安装以及png的安装成功


gnuplot

gnuplot> set terminal png


4 安装openTSDB


在三个节点上操作相同

rpm –ivh opentsdb-2.3.0.rpm

初始表

env COMPRESSION=NONE HBASE_HOME=/usr/local/hbase-1.3.0/ /usr/local/opentsdb/share/opentsdb/tools/create_table.sh

修改配置文件

vi /etc/opentsdb/opentsdb.conf

tsd.core.auto_create_metrics = true

tsd.storage.hbase.zk_quorum = master,slave1,slave2

启动

./tsdb tsd  –config=/usr/local/opentsdb/share/opentsdb/etc/opentsdb/opentsdb.conf

cd /usr/share/opentsdb/bin

chmod +x tsdb

./tsdb tsd &

http://192.168.100.200:4242/

http://192.168.100.201:4242/

http://192.168.100.202:4242/


5    基本使用


opentsdb的java客户端采用github上的开源项目https://github.com/OpenTSDB/opentsdb

在192.168.100.200节点存入数据

    @Test
    public void testPutData() {
        OpentsdbClient client = new OpentsdbClient("http://192.168.100.200:4242");
        try {
            Map<String, String> tagMap = new HashMap<String, String>();
            tagMap.put("host", "192.168.100.200");
 
            client.putData("anysense-alarm", DateUtils.String2Date("20160627 12:15", "yyyyMMdd HH:mm"), 210l, tagMap);
            
 
        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }

在192.168.100.201、192.168.100.202节点查询

    @Test
    public void testGetData() {
    	OpentsdbClient client = new OpentsdbClient("http://192.168.100.202:4242");
        try {
            Filter filter = new Filter();
            filter.setType("regexp");
            filter.setTagk("host");
            filter.setFilter("192.168.100.200");
            filter.setGroupBy(Boolean.TRUE);
            String resContent = client.getData("anysense-alarm", filter, Aggregator.avg.name(), "1h",
                    "2016-06-27 12:00:00", "2016-06-30 13:00:00");
            System.out.println(resContent);
 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


原文:https://blog.csdn.net/wyl6019/article/details/69948994