OpenTSDB分布式集群安装

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 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值