HBase 伪分布式搭建(使用外部ZK)

环境说明:
(1).JDK 1.8
(2).ZooKeeper 3.4.9
(3).Hadoop 3
(4).HBase 1.3.1

以上一到三,笔者已经完成,HBase伪分布式安装配置如下

  • 配置环境变量
# HBase Environment Variable
export HBASE_HOME=/home/hadoop/software/hbase
export PATH=$HBASE_HOME/bin:$PATH

配置hbase-env.sh

# hbase 安装目录下创建logs目录
export HBASE_LOG_DIR=${HBASE_HOME}/logs
# hbase 安装目录下创建pids目录
export HBASE_PID_DIR=${HBASE_HOME}/pids
# 使用外部zk,true表示使用hbase自带的zk
export HBASE_MANAGES_ZK=false
# 指定hadoop 目录
export HADOOP_HOME=/home/hadoop/software/hadoop
  • 配置hbase-site.xml
<configuration>
    
    <property>
        <name>hbase.rootdirname>
        <value>hdfs://harvey:9000/hbasevalue>
    property>

    
    <property>
        <name>hbase.cluster.distributedname>
        <value>truevalue>
    property>

    
    <property>
        <name>hbase.tmp.dirname>
        <value>/home/hadoop/software/hbase/tmpvalue>
    property>

    
    <property>
        <name>hbase.zookeeper.property.dataDirname>
        <value>/home/hadoop/software/zookeeper/datavalue>
    property>

    
    <property>
        <name>zookeeper.session.timeoutname>
        <value>120000value>
    property>

    
    <property>
        <name>hbase.regionserver.restart.on.zk.expirename>
        <value>truevalue>
    property>

    
    <property>  
    <name>hbase.zookeeper.quorumname>  
    <value>localhostvalue>
    property>  
configuration>
  • 启动hbase
start-hbase.sh

查看进程

6160 HMaster
1780 SecondaryNameNode
2006 ResourceManager
2150 NodeManager
1449 NameNode
6954 Jps
1563 DataNode
2507 QuorumPeerMain
6319 HRegionServer
  • 访问HBase Web UI 界面(http:harvey:16010),harvey可替换为ip
    HBase 伪分布式搭建(使用外部ZK)_第1张图片

  • 访问Hadoop Web UI界面,可以看到多了一个hbase的目录
    HBase 伪分布式搭建(使用外部ZK)_第2张图片

错误记录及解决

  • HBase 启动不起来,启动失败

查看日志可以看到如下错误信息(HBase安装目录的log目录下)

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.

错误原因:已经启动ZK,但是HBase并没有使用外部的ZK,导致冲突

解决方法:
1).hbase-env.sh 将 export HBASE_MANAGES_ZK 属性设置为false
2).hbase-site.xml 将 hbase.cluster.distributed 设置为true

<property>
    <name>hbase.cluster.distributedname>
    <value>truevalue>
property>
  • HBase 访问HDFS拒绝连接

查看日志,错误信息如下
java.net.ConnectException: Call From harvey/192.168.191.65 to harvey:8020 failed on connection exception: java.net.ConnectException: 拒绝连接; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused

解决方法如下:hbase-site.xml 中 hbase.rootdir 配置错误,harvey可以替换为ip地址

错误:

<property>
    <name>hbase.rootdirname>
    <value>hdfs://harvey/hbasevalue>
property>

正确:

<property>
    <name>hbase.rootdirname>
    <value>hdfs://harvey:9000/hbasevalue>
property>

你可能感兴趣的:(HBase)