Ubuntu16.04 安装配置HBase详细步骤(单机版)

前题条件

(1)Ubuntu16.04 机子一台,最好可以联网

(2)已安装Hadoop,推荐安装2.7.7版本,因为它比较稳定,并且和Habse的兼容性最好。

Hadoop和HBase版本对照表

  •  √ = 完全可以兼容

  •  ?= 存在未知的兼容问题

  •   × = 不兼容

  HBase-1.2.x, HBase-1.3.x HBase-1.4.x HBase-2.0.x HBase-2.1.x

Hadoop-2.4.x

× × ×

Hadoop-2.5.x

× × ×

Hadoop-2.6.0

× × × ×

Hadoop-2.6.1+

× ×
Hadoop的2.7.0 × × × ×

Hadoop-2.7.1+

Hadoop-2.8.[0-1]

× × × ×

Hadoop-2.8.2

Hadoop-2.8.3+

Hadoop-2.9.0

× × × ×

Hadoop-2.9.1+

Hadoop-3.0.[0-2]

× × × ×

Hadoop-3.0.3+

× ×

Hadoop-3.1.0

× × × ×

Hadoop-3.1.1+

× ×

相信我,一定要严格按照版本对照表安装HBase,不然你会遇见很多的问题。 

下载HBase

本次安装的是HBase2.0.4版本,Hadoop为2.7.7版本。

清华镜像下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/2.0.4/hbase-2.0.4-bin.tar.gz

使用wget命令下载: 

root@master:/# mkdir HBase
root@master:/# cd HBase/
root@master:/HBase# wget https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/2.0.4/hbase-2.0.4-bin.tar.gz

解压:

root@master:/HBase# ls
hbase-2.0.4-bin.tar.gz
root@master:/HBase# tar -xzvf hbase-2.0.4-bin.tar.gz 

移动文件:

root@master:/HBase# ls
hbase-2.0.4  hbase-2.0.4-bin.tar.gz
root@master:/HBase# mv hbase-2.0.4/* ./

删除安装包:

root@master:/HBase# ls
bin  CHANGES.md  conf  docs  hbase-2.0.4  hbase-2.0.4-bin.tar.gz  hbase-webapps  LEGAL  lib  LICENSE.txt  NOTICE.txt  README.txt  RELEASENOTES.md
root@master:/HBase# rm -rf hbase-*

配置HBase

配置etc/profile,添加如下内容:

export HBASE_HOME=/HBase
export PATH=$PATH:$HBASE_HOME/bin

使配置文件生效

source /etc/profile

HBase的配置文件全在conf这个文件夹下,需要配置的有三个文件:

1.hbase-env.sh

2.hbase-site.xml

3.regionservers

配置hbase-env.sh

root@master:/HBase# cd conf/
root@master:/HBase/conf# ls
hadoop-metrics2-hbase.properties  hbase-env.cmd  hbase-env.sh  hbase-policy.xml  hbase-site.xml  log4j.properties  regionservers
root@master:/HBase/conf# vim hbase-env.sh 

添加如下内容

#true为单机版,false为集群版
export HBASE_MANAGES_ZK=true
#jdk目录
export JAVA_HOME=/Java/jdk1.8
#hadoop 目录
export HADOOP_HOME=/Hadoop
#hbase目录
export HBASE_HOME=/HBase

配置hbase-site.xml,修改为:


 
  
    hbase.rootdir
    hdfs://master:9000/hbase
  
  
  
     hbase.cluster.distributed
     true
  
  
  
      hbase.master
      master:60010
  
  
   
    hbase.zookeeper.property.dataDir
    /Zookeeper/temp
  
 
  
    hbase.zookeeper.quorum
    master
  
  
  
    hbase.zookeeper.property.clientPort
    2181
  

配置regionservers

添加

master

安装Zookeeper

zookeeper的作用主要是当集群中的master挂掉之后,它会重新选一位master,本次安装的是单机版的HBase,因此安装zookeeper可以省略。

下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz

使用wget下载zookeeper

root@master:/# mkdir Zookeeper
root@master:/# cd Zookeeper/
root@master:/Zookeeper# wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz

解压

root@master:/Zookeeper# ls
zookeeper-3.4.13.tar.gz
root@master:/Zookeeper# tar -xzvf zookeeper-3.4.13.tar.gz

删除安装包:

root@master:/Zookeeper# ls
zookeeper-3.4.13  zookeeper-3.4.13.tar.gz
root@master:/Zookeeper# mv zookeeper-3.4.13/* ./
root@master:/Zookeeper# rm -rf zookeeper-3.4.13
root@master:/Zookeeper# rm -rf zookeeper-3.4.13.tar.gz 
root@master:/Zookeeper# ls
bin        contrib     ivysettings.xml  LICENSE.txt  README_packaging.txt  zookeeper-3.4.13.jar      zookeeper-3.4.13.jar.sha1
build.xml  dist-maven  ivy.xml          NOTICE.txt   recipes               zookeeper-3.4.13.jar.asc
conf       docs        lib              README.md    src                   zookeeper-3.4.13.jar.md5

配置Zookeeper

配置 /etc/peofile,添加如下内容:

export ZOOKEEPER_HOME=/Zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin

使配置文件生效:

source /etc/profile

Zookeeper的配置文件只有一个,在conf文件夹下,名为:zoo_sample.cfg(修改后需复制一份为zoo.cfg才行)

修改zoo_sample.cfg为:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/Zookeeper/data
dataLogDir=/Zookeeper/logs
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.0=master:2888:3888

复制一份:

root@master:/Zookeeper/conf# cp zoo_sample.cfg zoo.cfg

最后,还需在zookeeper的dataDir内新建一个myid文件,内容为zoo.cfg中server.后面的数字,这里为0

root@master:/Zookeeper/data# echo "0">>myid

启动zookeeper:

root@master:/Zookeeper/conf# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /Zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
root@master:/Zookeeper/conf# jps
22995 QuorumPeerMain
8309 NameNode
8421 DataNode
23014 Jps
8798 ResourceManager
8911 NodeManager

可以看到zookeeper的进程QuorumPeerMain启动成功了。

启动HBase

启动HBase的过程遇到了一些问题,下面一一指出:

root@master:/HBase/logs# jps
22995 QuorumPeerMain
8309 NameNode
8421 DataNode
23405 Jps
8798 ResourceManager
8911 NodeManager
root@master:/HBase/logs# start-hbase.sh 
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/HBase/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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]
running master, logging to /HBase/logs/hbase-root-master-master.out
root@master:/HBase/logs# jps
23536 HMaster
22995 QuorumPeerMain
8309 NameNode
8421 DataNode
23611 Jps
8798 ResourceManager
8911 NodeManager
root@master:/HBase/logs# jps
22995 QuorumPeerMain
8309 NameNode
8421 DataNode
23638 Jps
8798 ResourceManager
8911 NodeManager

问题1

Class path contains multiple SLF4J bindings警告。

解决办法

上面提示HBase的slf4j-log4j12-1.7.25.jar包和Hadoop的slf4j-log4j12-1.7.10.jar包起冲突了,因此只需删除其中的一个即可,为了防止误删,这里只是将slf4j-log4j12-1.7.25.jar更改了一下名称

mv /HBase/lib/slf4j-log4j12-1.7.25.jar /HBase/lib/slf4j-log4j12-1.7.25.jar_cp

之后再启动HBase就不会报警告啦。

问题2

HBase启动后HMaster进程过一会儿就消失了。

解决办法

查看HBase的日志文件,在/HBase/logs目录下,提示:

2019-03-14 18:15:05,156 ERROR [main] master.HMasterCommandLine: Master exiting
java.io.IOException: Could not start ZK at requested port of 2181.  ZK was started at port: 2182.  Aborting as clients (e.g. shell) will not be able to find this ZK quorum.
        at org.apache.hadoop.hbase.master.HMasterCommandLine.startMaster(HMasterCommandLine.java:217)
        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:3073)
2019-03-14 18:15:05,171 INFO  [Thread-2] server.NIOServerCnxn: Closed socket connection for client /127.0.0.1:38288 (no session established for client)

提示zookeeper启动的端口为2182,而不是2181,因此这里将/HBase/conf/hbase-site.xml内的zookeeper请求端口设置改为了:


    hbase.zookeeper.property.clientPort
    2182
  

启动HBase

root@master:/HBase/conf# start-hbase.sh 
running master, logging to /HBase/logs/hbase-root-master-master.out
root@master:/HBase/conf# jps
32995 Jps
32053 HQuorumPeer
29574 DataNode
29463 NameNode
29962 ResourceManager
32154 HMaster
30076 NodeManager
32268 HRegionServer

到此HBase就安装成功啦。 

你可能感兴趣的:(大数据)