CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb

一、前期准备

1、配置ip

进入文件编辑模式:

vim /etc/sysconfig/network-scripts/ifcfg-ens192 

 

原内容:

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens192
UUID=f384ed85-2e1e-4087-9f53-81afd746f459
DEVICE=ens192
ONBOOT=no

 修改后内容:

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens192
UUID=f384ed85-2e1e-4087-9f53-81afd746f459
DEVICE=ens192
ONBOOT=yes
IPADDR=192.168.0.214
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
DNS=183.***.***.100

重启网络使之生效

service network restart

用CRT进行登录

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第1张图片

2、修改hostname

# 查看
hostname
# 修改
hostnamectl set-hostname 'hbase3'

 

3、映射hostname

vi /etc/hosts

添加红框栏:

4、联网

方便yum下载安装包或者安装一些命令,就必须联网:

#检查是否联网: ping: www.baidu.com: Name or service not known说明未联网

#配置/etc/resolv.conf
vi /etc/resolv.conf
#添加以下内容: 这里的ip与第1步的DNS后面的ip相同
nameserver 183.***.***.100
#验证:PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data. 说明联网成功 ping www.baidu.com

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第2张图片

 

 

5、安装vim、rz、sz

yum install -y vim
yum install -y lrzsz

6、设置时区

注:操作系统有两个时间: 软件时间(date)和硬件时间(hwclock )

# 查看时间
date
# 设置时区
timedatectl set-timezone Asia/Shanghai

#检查时间
date
hwclock

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第3张图片

 

 

7、免密登录

#测试是否免密登录
ssh localhost

#进入路径
cd ~/.ssh/
#生成对钥
ssh-keygen -t rsa
#将公钥拷贝到 authorized_keys
cat id_rsa.pub >> authorized_keys

#验证
ssh localhost

 

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第4张图片

验证结果:

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第5张图片

 

8、下载准备安装包

注:1、hbase与hadoop的匹配表见http://hbase.apache.org/book.html#basic.prerequisites

  2、我在/opt/soft分别准备以下安装包:点击链接可以卡查看并下载最新版本

jdk:          jdk-8u191-linux-x64.tar.gz

hadoop:   hadoop-3.1.2.tar.gz

zookeeper:           zookeeper-3.4.13.tar.gz

hbase:     hbase-2.1.4-bin.tar.gz

opentsdb:opentsdb-2.4.0.tar.gz

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第6张图片

 

 

二、开始安装

1、安装jdk

注:由于要安装的hadoop、zookeeper、habse、opentsdb都是java语言开发的,故首先需要安装jdk。

#进入到安装包所在路径
cd /opt/soft/jdk
#解压安装包
tar -zxvf jdk-8u191-linux-x64.tar.gz 


#配置环境变量
vim /etc/profile
#在/etc/profile最后添加内容
export JAVA_HOME=/opt/soft/jdk/jdk1.8.0_191
export PATH=$PATH:$JAVA_HOME/bin

#使环境变量生效
source /etc/profile

#验证
java -version

验证时出现如截图内容则说明安装成功

2、安装hadoop

【1】解压安装

#进入到安装包所在路径
cd /opt/soft/hadoop
#解压安装包
 tar -zxvf hadoop-3.1.2.tar.gz


#配置环境变量
vim /etc/profile
#在/etc/profile添加JAVA_HOME的后面继续添加  綠色部分
export HADOOP_HOME=/opt/soft/hadoop/hadoop-3.1.2
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

  

  export HADOOP_MAPRED_HOME=$HADOOP_HOME
  export HADOOP_MAPRED_HOME=$HADOOP_HOME
  export HADOOP_COMMON_HOME=$HADOOP_HOME
  export HADOOP_HDFS_HOME=$HADOOP_HOME
  export YARN_HOME=$HADOOP_HOME
  export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
  export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib:$HADOOP_COMMON_LIB_NATIVE_DIR"

#使环境变量生效
source /etc/profile

#验证:不报-bash: hadoop: command not found则说明成功
hadoop fs -ls

 CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第7张图片

 

 CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第8张图片

【2】配置

core-site.xml

#进入到配置文件路径:
cd /opt/soft/hadoop/hadoop-3.1.2/etc/hadoop

#备份:
cp hadoop-env.sh hadoop-env.sh.bak

#进入配置文件:
vim hadoop-env.sh

#设置java 环境变量,虽然系统中定义了java_home,在hadoop中需要重新配置
export JAVA_HOME=/opt/soft/jdk/jdk1.8.0_191
#配置数据路径
export HADOOP_PID_DIR=/opt/data/hadoop/pids 

 CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第9张图片CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第10张图片

core-site.xml

#备份:
cp core-site.xml core-site.xml.bak

#进入配置文件:
vim core-site.xml




    
        fs.defaultFS
        hdfs://hbase3:9000
    

    
        hadoop.tmp.dir
         /opt/soft/hadoop/hadoop-3.1.2/data
    

 

hdfs-site.xml

#备份:
cp hdfs-site.xml hdfs-site.xml.bak

#进入配置文件:
vim hdfs-site.xml




    
        dfs.replication
        1
    
    
        dfs.namenode.name.dir
        /opt/soft/hadoop/hadoop-3.1.2/hdfs/name
    
    
        dfs.namenode.data.dir
        /opt/soft/hadoop/hadoop-3.1.2/hdfs/data,/opt/soft/hadoop/hadoop-3.1.2/hdfs/data_bak
    
     
        dfs.http.address
        hbase3:50070
     
     
      dfs.datanode.max.transfer.threads
      4096
     

mapred-site.xml

# 备份:
cp mapred-site.xml mapred-site.xml.bak

# 进入配置文件:
vim mapred-site.xml




    
        mapreduce.framework.name
        yarn
    
    
        mapreduce.application.classpath
        
            /opt/soft/hadoop/hadoop-3.1.2/etc/hadoop,
            /opt/soft/hadoop/hadoop-3.1.2/share/hadoop/common/*,
            /opt/soft/hadoop/hadoop-3.1.2/share/hadoop/common/lib/*,
            /opt/soft/hadoop/hadoop-3.1.2/share/hadoop/hdfs/*,
            /opt/soft/hadoop/hadoop-3.1.2/share/hadoop/hdfs/lib/*,
            /opt/soft/hadoop/hadoop-3.1.2/share/hadoop/mapreduce/*,
            /opt/soft/hadoop/hadoop-3.1.2/share/hadoop/mapreduce/lib/*,
            /opt/soft/hadoop/hadoop-3.1.2/share/hadoop/yarn/*,
            /opt/soft/hadoop/hadoop-3.1.2/share/hadoop/yarn/lib/*
        
    
  
      mapreduce.jobhistroy.address
      hbase3:10020
  
  
      mapreduce.jobhistroy.webapp.address
      hbase3:19888
  

yarn-site.xml

#备份:
cp yarn-site.xml yarn-site.xml.bak

#进入配置文件:
vim yarn-site.xml




    
        yarn.nodemanager.aux-services
        mapreduce_shuffle
    
    
        yarn.log-aggregation-enable
        true
    

    
        yarn.resourcemanager.hostname
        hbase3
    
    
        yarn.resourcemanager.address
        hbase3:8032
    
    
        yarn.resourcemanager.scheduler.address
         hbase3:8030
    
    
        yarn.resourcemanager.resource-tracker.address
         hbase3:8031
    
    
        yarn.resourcemanager.admin.address
        hbase3:8033
    
    
        yarn.resourcemanager.webapp.address
        hbase3:8088
      

注:以下配置是为了解决报错:no HDFS_NAMENODE_USER defined

start-dfs.sh、stop-dfs.sh

# 进入目录
cd /opt/soft/hadoop/hadoop-3.1.2/sbin
# 备份:
cp start-dfs.sh  start-dfs.sh.bak
cp stop-dfs.sh   stop-dfs.sh.bak

# 进入文件编辑模式:
vim start-dfs.sh
vim stop-dfs.sh


# 配置:添加以下内容(我是用root账户安装和启动HADOOP)

HDFS_DATANODE_USER=root
HDFS_DATANODE_SECURE_USER=hdfs
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root

start-yarn.sh、stop-yarn.sh

# 备份:
cp start-yarn.sh  start-yarn.sh.bak
cp stop-yarn.sh   stop-yarn.sh.bak

# 进入文件编辑模式:
vim start-yarn.sh
vim stop-yarn.sh


# 配置:添加以下内容

YARN_RESOURCEMANAGER_USER=root
HADOOP_SECURE_DN_USER=yarn
YARN_NODEMANAGER_USER=root

【3】启动

注:1、重新格式化HADOOP前需要清空所有DATA目录数据:包括dfs下的、保存缓存数据的、以及hadoop的、zookeeper的log日志文件;以及zookeeper的data下zookeeper_service.pid

        2、如果出现nativelib不能加载的情况,需要查看native包的版本是否为64位(file libhadoop.so.1.0.0 ),如果不匹配则需要用64位环境编译或者更换64位包。

start-dfs.sh、stop-dfs.sh

# 格式化hdfs
 hdfs  namenode -format
# 启动(start-all.sh 相当于start-dfs.sh+start-yarn.sh )
start-all.sh 
## 验证
# 1、端口验证
netstat -ano |grep 50070

# 2、web验证: 如上面验证正常,不能访问web,检查防火墙等
http://192.168.0.214:50070 

 

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第11张图片

 

 

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第12张图片

 

3、安装zookeeper

【1】解压安装

# 进入目录
cd /opt/soft/zookeeper

# 解压
tar -zxvf zookeeper-3.4.13.tar.gz 
# 修改用户权限
 chown -R root:root zookeeper-3.4.13

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第13张图片

 

【2】配置

zoo.cfg

# 进入目录
cd zookeeper-3.4.13/conf/
# 将zoo_sample.cfg复制给zoo.cfg
cp zoo_sample.cfg zoo.cfg 

# 修改zoo.cfg 
vim zoo.cfg 

# 配置:添加以下内容(注释掉dataDir=/tmp/zookeeper)

dataDir=/opt/soft/zookeeper/zookeeper-3.4.13/data
dataLogDir=/opt/soft/zookeeper/zookeeper-3.4.13/logs

server.1=127.0.0.1:2888:3888

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第14张图片

 

 环境变量  /etc/profile

# 进入环境变量
 
vim /etc/profile
# 继续添加 export ZOOKEEPER_HOME=/opt/soft/zookeeper/zookeeper-3.4.13/ :$ZOOKEEPER_HOME/bin

# 使环境变量生效
 source /etc/profile

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第15张图片

 

【3】启动

# 启动
zkServer.sh start # 验证
# 1、端口验证
netstat -ano | grep 2181
# 2、客户端验证
zkCli.sh -server

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第16张图片

 

 

4、安装hbase

【1】解压安装 

 注:hbase与hadoop的匹配表见http://hbase.apache.org/book.html#basic.prerequisites

# 进入目录
cd /opt/soft/hbase/

#解压
tar -zxvf hbase-2.1.4-bin.tar.gz 

【2】配置

zoo.cfg

# 将zookeeper下的zoo.cfg拷贝到hbase的conf下
cp /opt/soft/zookeeper/zookeeper-3.4.13/conf/zoo.cfg /opt/soft/hbase/hbase-2.1.4/conf/

hbase-env.sh

# 进入目录
/opt/soft/hbase/hbase-2.1.4/conf/

# 备份
cp hbase-env.sh hbase-env.sh.bak 

# 进入编辑模式
vim hbase-env.sh

# 配置:添加以下内容(注释掉:export HBASE_OPTS="$HBASE_OPTS -XX:+UseConcMarkSweepGC")
export JAVA_HOME=/opt/soft/jdk/jdk1.8.0_191
export HBASE_OPTS
="$HBASE_OPTS -Xmx8G -Xms8G -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=70" export HBASE_HOME=/opt/soft/hbase/hbase-2.1.4/ export HBASE_CLASSPATH=/opt/soft/hbase/hbase-2.1.4/conf export HBASE_LOG_DIR=/opt/soft/hbase/hbase-2.1.4/logs export HADOOP_HOME=/opt/soft/hadoop/hadoop-3.1.2 export HBASE_PID_DIR=/opt/data/hadoop/pids export HBASE_MANAGES_ZK=false

hbase-site.xml

# 备份:
cp hbase-site.xml hbase-site.xml.bak

# 进入编辑模式:
vim hbase-site.xml

# 配置:标签中添加

  
    hbase.rootdir
    hdfs://hbase3:9000/hbase
  
  
    hbase.cluster.distributed
    true
  
  
   hbase.master
   127.0.0.1:60000
  
  
    hbase.zookeeper.quorum
    127.0.0.1
 
 
    hbase.wal.provider
   filesystem
 
 
    hbase.unsafe.stream.capability.enforce
    false
 
 
     hbase.tmp.dir
     /opt/soft/hbase/hbase-2.1.4/tmpdata
  
  
      hfile.block.cache.size
      0.2
  
  
      hbase.snapshot.enabled
      true
  
  
      zookeeper.session.timeout
      180000
  

 

 环境变量  /etc/profile

 

# 进入环境变量
 
vim /etc/profile

# 继续添加
export HBASE_HOME=/opt/soft/hbase/hbase-2.1.4/
:$HBASE_HOME/bin

# 使环境变量生效
 source /etc/profile

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第17张图片

【3】启动

start-hbase.sh 

 

报错1:java.lang.NoClassDefFoundError: org/apache/htrace/SamplerBuilder

启动时显示:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/soft/hadoop/hadoop-3.1.2/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/soft/hbase/hbase-2.1.4/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

# 查看日志
 tailf hbase-root-master-hbase3.log -n 500

# 报错内容
2019-07-08 06:08:48,407 INFO  [main] ipc.NettyRpcServer: Bind to /192.168.0.214:16000
2019-07-08 06:08:48,554 INFO  [main] hfile.CacheConfig: Created cacheConfig: CacheConfig:disabled
2019-07-08 06:08:48,555 INFO  [main] hfile.CacheConfig: Created cacheConfig: CacheConfig:disabled
2019-07-08 06:08:49,105 ERROR [main] regionserver.HRegionServer: Failed construction RegionServer
java.lang.NoClassDefFoundError: org/apache/htrace/SamplerBuilder
        at org.apache.hadoop.hdfs.DFSClient.(DFSClient.java:644)
        at org.apache.hadoop.hdfs.DFSClient.(DFSClient.java:628) at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:149) at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2667) at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:93) at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2701) at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2683) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:372) at org.apache.hadoop.fs.Path.getFileSystem(Path.java:295) at org.apache.hadoop.hbase.util.CommonFSUtils.getRootDir(CommonFSUtils.java:362) at org.apache.hadoop.hbase.util.CommonFSUtils.isValidWALRootDir(CommonFSUtils.java:411) at org.apache.hadoop.hbase.util.CommonFSUtils.getWALRootDir(CommonFSUtils.java:387) at org.apache.hadoop.hbase.regionserver.HRegionServer.initializeFileSystem(HRegionServer.java:704) at org.apache.hadoop.hbase.regionserver.HRegionServer.(HRegionServer.java:613) at org.apache.hadoop.hbase.master.HMaster.(HMaster.java:489) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.apache.hadoop.hbase.master.HMaster.constructMaster(HMaster.java:3093) at org.apache.hadoop.hbase.master.HMasterCommandLine.startMaster(HMasterCommandLine.java:236) at org.apache.hadoop.hbase.master.HMasterCommandLine.run(HMasterCommandLine.java:140) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70) at org.apache.hadoop.hbase.util.ServerCommandLine.doMain(ServerCommandLine.java:149) at org.apache.hadoop.hbase.master.HMaster.main(HMaster.java:3111) Caused by: java.lang.ClassNotFoundException: org.apache.htrace.SamplerBuilder at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 25 more 2019-07-08 06:08:49,118 ERROR [main] master.HMasterCommandLine: Master exiting java.lang.RuntimeException: Failed construction of Master: class org.apache.hadoop.hbase.master.HMaster. at org.apache.hadoop.hbase.master.HMaster.constructMaster(HMaster.java:3100) at org.apache.hadoop.hbase.master.HMasterCommandLine.startMaster(HMasterCommandLine.java:236) at org.apache.hadoop.hbase.master.HMasterCommandLine.run(HMasterCommandLine.java:140) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70) at org.apache.hadoop.hbase.util.ServerCommandLine.doMain(ServerCommandLine.java:149) at org.apache.hadoop.hbase.master.HMaster.main(HMaster.java:3111) Caused by: java.lang.NoClassDefFoundError: org/apache/htrace/SamplerBuilder at org.apache.hadoop.hdfs.DFSClient.(DFSClient.java:644) at org.apache.hadoop.hdfs.DFSClient.(DFSClient.java:628) at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:149) at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2667) at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:93) at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2701) at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2683) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:372) at org.apache.hadoop.fs.Path.getFileSystem(Path.java:295) at org.apache.hadoop.hbase.util.CommonFSUtils.getRootDir(CommonFSUtils.java:362) at org.apache.hadoop.hbase.util.CommonFSUtils.isValidWALRootDir(CommonFSUtils.java:411) at org.apache.hadoop.hbase.util.CommonFSUtils.getWALRootDir(CommonFSUtils.java:387) at org.apache.hadoop.hbase.regionserver.HRegionServer.initializeFileSystem(HRegionServer.java:704) at org.apache.hadoop.hbase.regionserver.HRegionServer.(HRegionServer.java:613) at org.apache.hadoop.hbase.master.HMaster.(HMaster.java:489) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.apache.hadoop.hbase.master.HMaster.constructMaster(HMaster.java:3093) ... 5 more Caused by: java.lang.ClassNotFoundException: org.apache.htrace.SamplerBuilder at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 25 more
## 解决方案
# 找到 htrace-core 开头的jar

 find / -name 'htrace-core-*'
# 将 htrace-core 开头的jar 复制到 /opt/soft/hbase/hbase-2.1.4/lib/目录下

cp /opt/soft/hadoop/hadoop-3.1.2/share/hadoop/yarn/timelineservice/lib/htrace-core-3.1.0-incubating.jar /opt/soft/hbase/hbase-2.1.4/lib/

 

 

【4】验证

192.168.0.214:16010进入web页面

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第18张图片

 

 

5、安装opentsdb

【1】解压

 

# 进入目录
cd /opt/soft/opentsdb

# 解压
 tar -zxvf opentsdb-2.4.0.tar.gz 

# 修改用户权限
chown -R root:root opentsdb-2.4.0

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第19张图片

【2】编译

# 进入目录
cd opentsdb-2.4.0
# 编译:会生成一个build文件,但会报错
 ./build.sh
# 将third_party中的文件放入build文件夹中
cp -r third_party build
# 再次编译
./build.sh    

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第20张图片

【3】配置

opentsdb.conf

# 将/opt/soft/opentsdb/opentsdb-2.4.0/src/opentsdb.conf复制到/opt/soft/opentsdb/opentsdb-2.4.0/build目录下

cp /opt/soft/opentsdb/opentsdb-2.4.0/src/opentsdb.conf /opt/soft/opentsdb/opentsdb-2.4.0/build/ # 进入编辑模式
vim opentsdb.conf
# 分别配置以下内容

tsd.network.port =4242
tsd.http.staticroot =./staticroot
tsd.http.cachedir =/opt/soft/opentsdb/opentsdb-2.4.0/tsdtmp
tsd.core.auto_create_metrics = true
tsd.storage.hbase.zk_quorum = 127.0.0.1:2181
tsd.http.request.enable_chunked = true
tsd.core.auto_create_metrics = true
tsd.http.request.max_chunk = 1638400

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第21张图片CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第22张图片

【4】生成表

# 进入目录
cd  /opt/soft/opentsdb/opentsdb-2.4.0/src
# 在hbase中生成表
env COMPRESSION=NONE HBASE_HOME=/opt/soft/hbase/hbase-2.1.4 ./create_table.sh

## 验证
#1、hbase验证: 进入hbase的shell命令:更多habse shell命令参考https://www.cnblogs.com/i80386/p/4105423.html
hbase shell
# 查看所有表:opentsdb在hbase中会生成4个表(tsdb, tsdb-meta, tsdb-tree, tsdb-uid),其中tsdb这个表最重要,数据迁移时,备份还原此表即可
list
#2、zookeeper验证:进入zkCli.sh客户端,相关命令指南参考https://www.e-learn.cn/content/linux/835320 zkCli.sh -server # 查看hbase相关表 ls /hbase/table
#3、hadoop验证:hbas相关数据在 /hbase/default目录下,其他相关命令指南参考https://blog.csdn.net/m0_38003171/article/details/79086780 hdfs dfs -ls -R /hbase/default

 

 CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第23张图片

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第24张图片

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第25张图片

 CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第26张图片

【5】启动

# 进入目录
cd /opt/soft/opentsdb/opentsdb-2.4.0/build/ 
# 启动
sh tsdb tsd &
## 验证
# 1、端口验证
netstat -ano |grep 4242
# 2、进程验证
ps -ef | grep opentsdb

# 3、web验证:如上面验证都正常,web无法访问,检查防火墙等

http://192.168.0.211:4242/

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第27张图片

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第28张图片

【6】写数据

 

#启动写入数据程序: /opt/soft/tsdb/property-0.0.1-SNAPSHOT.jar 程序为写入数据的程序
java -jar /opt/soft/tsdb/property-0.0.1-SNAPSHOT.jar &

注:在web页面的Graph中,可以看到写入的指标(标签),则说明写入成功,如未写入成,可以在logs下看相关日志。想要看具体数据,可安装 grafana辅助查看。安装步骤参考下面。

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第29张图片

 

 

 

6、安装grafana

参考:https://grafana.com/grafana/download?platform=linux

【1】安装

方法一:

# 创建目录
mkdir /opt/soft/grafana/

# 进入目录
cd /opt/soft/grafana/

# 下载安装包
wget https://dl.grafana.com/oss/release/grafana-6.2.5.linux-amd64.tar.gz 

# 解压

tar -zxvf grafana-6.2.5.linux-amd64.tar.gz

 方法二:

yum install -y https://dl.grafana.com/oss/release/grafana-6.2.5-1.x86_64.rpm

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第30张图片

【2】启动

# 启动
service grafana-server start
## 验证

# 1、状态验证
systemctl status grafana-server

# 2、web验证:默认端口为3000
192.168.0.214:3000

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第31张图片

 

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第32张图片

 

【3】查看数据

1、修改密码:

账户密码默认:admin  admin,首次登陆要求修改密码,我这里改为Zxit@2018

 CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第33张图片

2、添加数据库

Add data source——》Data Sources——》OpenTSDB——》输入URL(http://localhost:4242)——》Save & Test——》back

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第34张图片

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第35张图片

 

 CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第36张图片

3、查看数据

 

Home——》New dashboard——》Add Query——》选择数据库——》选择指标CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第37张图片

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第38张图片

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第39张图片

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第40张图片

CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb_第41张图片

 

转载于:https://www.cnblogs.com/yybrhr/p/11128149.html

你可能感兴趣的:(CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb)