您的位置:首页 > 运维架构

openTSDB的分布式集群的安装和使用

2017-04-14 14:54 288 查看
1  安装提前

            确保安装了jdk

            确保安装了hadoop集群

            确保安装了hbase的集群

    本次在centos7上测试成功

    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 插件

          [root@localhost local]# rpm -ivh gnuplot-common-4.6.2-3.el7.x86_64.rpm

          [root@localhost local]# rpm -ivh gnuplot-4.6.2-3.el7.x86_64.rpm    

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

          [root@localhost bin]# gnuplot

          gnuplot> set terminal png

4 安装openTSDB

         在三个节点上操作相同

         [root@localhost local]# rpm –ivh opentsdb-2.3.0.rpm

         初始表

         [root@localhost opentsdb-2.3.0]# env COMPRESSION=NONE HBASE_HOME=/usr/local/hbase-1.3.0/ /usr/local/opentsdb/share/opentsdb/tools/create_table.sh

         修改配置文件

        [root@master home]# vi /etc/opentsdb/opentsdb.conf 

        tsd.core.auto_create_metrics = true

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

        启动

        [root@localhost bin]# ./tsdb tsd  --config=/usr/local/opentsdb/share/opentsdb/etc/opentsdb/opentsdb.conf

        [root@master bin]# cd /usr/share/opentsdb/bin

        [root@master bin]# chmod +x tsdb

        [root@master bin]# ./tsdb tsd &

 

        http://192.168.100.200:4242/
        http://192.168.100.200:4242/
        http://192.168.100.200: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();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: