搭建opentsdb 单机 centos7

搭建opentsdb 单机 centos7

搭建opentsdb环境,需要HBASE ,而HBASE依赖jdk,所以要安装jdk环境。

1.安装前的清理工作。如果以前安装过,给清理干净。

rpm -qa | grep jdk
rpm -qa | grep gcj

yum -y remove java-*

2.安装jdk环境

yum -y install java

3.查看java的版本

java -version

4.查看jdk的安装路径

which java 

结果是:/usr/bin/java

5.安装HBASE,可以去官网下载:

cd /opt
wget https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/2.2.4/hbase-2.2.4-bin.tar.gz

tar -xzvf hbase-2.2.4-bin.tar.gz
cd hbase-2.2.4

由于HBASE依赖JAVA_HOME环境变量,所以要导入JAVA环境变量,编辑conf/hbase-env.sh文件,并取消注释以#export JAVA_HOME =开头的行,然后将其设置为Java安装路径。

设置为:cd conf 
       vi hbase-env.sh
       export JAVA_HOME=/usr/

编辑conf/hbase-site.xml,这是主要的HBase配置文件。这时,您需要在本地文件系统上指定HBase和ZooKeeper写入数据的目录并确认一些风险。默认情况下,在/tmp下创建一个新目录。许多服务器配置为在重新引导时删除/ tmp的内容,因此您应该将数据存储在其他位置。

vi hbase-site.xml
<configuration>
<property>
    <name>hbase.rootdir</name>
    <value>file:///opt/hbase-2.2.4/</value>
  </property>
  <property>
    <name>hbase.master.info.port</name>
    <value>16010</value>
  </property>
  <property>
    <name>hbase.unsafe.stream.capability.enforce</name>
    <value>false</value>
    <description>
      Controls whether HBase will check for stream capabilities (hflush/hsync).
  
      Disable this if you intend to run on LocalFileSystem, denoted by a rootdir
      with the 'file://' scheme, but be mindful of the NOTE below.
  
      WARNING: Setting this to false blinds you to potential data loss and
      inconsistent system state in the event of process and/or node failures. If
      HBase is complaining of an inability to use hsync or hflush it's most
      likely not a false positive.
    </description>
  </property>
</configuration>

启动HBASE

cd bin
启动:./start-hbase.sh
停止:./stop-hbase.sh
启动后,进入hbase shell 创建表:
./hbase shell
# 这张表数据会很大,考虑到读写效率,我们注意到这张表就一个列族
create 'tsdb',{NAME => 't', VERSIONS => 1, BLOOMFILTER => 'ROW'}
# 这张表有id、name两个列族,可通过id找到name,也可以通过name找到id
create 'tsdb-uid',{NAME => 'id', BLOOMFILTER => 'ROW'},{NAME => 'name', BLOOMFILTER => 'ROW'}
# 下面两张表暂时可不必太关心,先创建出来就好
create 'tsdb-tree',{NAME => 't', VERSIONS => 1, BLOOMFILTER => 'ROW'}
create 'tsdb-meta',{NAME => 'name', BLOOMFILTER => 'ROW'}

退出:quit
6.安装opentsdb,可以去官网下载:

cd /opt
wget https://github.com/OpenTSDB/opentsdb/releases/download/v2.4.0/opentsdb-2.4.0.noarch.rpm
chmod +x opentsdb-2.4.0.noarch.rpm
yum -y localinstall opentsdb-2.4.0.noarch.rpm

创建opentsdb的服务文件:

vi /usr/lib/systemd/system/opentsdb.service
[Unit]
Description=OpenTSDB Service

[Service]
Type=forking
PrivateTmp=yes
ExecStart=/usr/share/opentsdb/etc/init.d/opentsdb start
ExecStop=/usr/share/opentsdb/etc/init.d/opentsdb stop
Restart=on-abort

systemctl status opentsdb 发现还没启动,dead状态
注意一下,默认opentsdb配置文件目录:/etc/opentsdb/opentsdb.conf,默认opentsdb日志目录:/var/log/opentsdb
修改配置 /etc/opentsdb/opentsdb.conf

tsd.network.port = 4242
tsd.http.staticroot = /usr/share/opentsdb/static/
tsd.http.cachedir = /tmp/opentsdb
tsd.core.auto_create_metrics = true
tsd.core.plugin_path = /usr/share/opentsdb/plugins

zookeeper的地址,即hbase依赖的zookeeper的地址,192.168.0.1:2181,192.168.0.2:2181,192.168.0.3:2181

tsd.storage.hbase.zk_quorum = localhost:2181
tsd.storage.fix_duplicates = true
tsd.http.request.enable_chunked = true
tsd.http.request.max_chunk = 4096000
tsd.storage.max_tags = 16

这里看到了我们上面在hbase中创建的4张表

tsd.storage.hbase.data_table = tsdb
tsd.storage.hbase.uid_table = tsdb-uid
tsd.storage.hbase.tree_table = tsdb-tree
tsd.storage.hbase.meta_table = tsdb-meta

下面几个配置项到部分源码解析的时候会有介绍,暂时可以先忽略

# tsd.query.skip_unresolved_tagvs = true
# hbase.rpc.timeout = 120000

启动opentsdb,systemctl start opentsdb,成功的话,就可以打开opentsdb的界面了http://localhost:4242/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

clarence.wei

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值