HBase伪分布式搭建

Spring Wu 211 2021-02-03

配置hbase-site.xml

在原有的hbase-site.xml配置的基础上增加以下配置,该配置指示HBase以分布式模式运行,每个HBase相关的进程都是单独的JVM实例:

<property>
  <name>hbase.cluster.distributed</name>
  <value>true</value>
</property>

然后需要设置hbase.unsafe.stream.capability.enforce为true,之前设置的false:

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>hdfs://localhost:9000/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/usr/hadoop/hbase/zookeeper</value>
  </property>
  <property>
    <name>hbase.unsafe.stream.capability.enforce</name>
    <value>true</value> <!--需要更改这个位置为true--> 
    <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>
  <!--表示以分布式模式运行--> 
  <property>
    <name>hbase.cluster.distributed</name>
    <value>true</value>
  </property>
</configuration>

HBase的进程

运行HBase

使用bin/start-hbase.sh命令运行HBase,运行成功后,使用jps命令查看到以下以H开头的JVM进场则代表HBase伪分布模式启动成功:

[root@VM_0_14_centos hbase-2.1.1]# jps
3034 NameNode
13093 HMaster
13168 HRegionServer
14668 Jps
3350 SecondaryNameNode
3152 DataNode
13030 HQuorumPeer

查看在HDFS中的HBase目录

[root@VM_0_14_centos hbase-2.1.1]# /usr/hadoop/hadoop-2.8.5/bin/hadoop fs -ls /hbase
Found 14 items
drwxr-xr-x   - root supergroup          0 2019-01-02 14:58 /hbase/.hbck
drwxr-xr-x   - root supergroup          0 2019-01-02 15:43 /hbase/.tmp
drwxr-xr-x   - root supergroup          0 2019-01-02 15:43 /hbase/MasterProcWALs
drwxr-xr-x   - root supergroup          0 2019-01-02 15:43 /hbase/WALs
drwxr-xr-x   - root supergroup          0 2019-01-02 15:51 /hbase/archive
drwxr-xr-x   - root supergroup          0 2019-01-02 14:58 /hbase/corrupt
drwxr-xr-x   - root supergroup          0 2019-01-02 14:58 /hbase/data
drwxr-xr-x   - root supergroup          0 2019-01-02 15:04 /hbase/default
drwxr-xr-x   - root supergroup          0 2019-01-02 14:58 /hbase/hbase
-rw-r--r--   3 root supergroup         42 2019-01-02 14:58 /hbase/hbase.id
-rw-r--r--   3 root supergroup          7 2019-01-02 14:58 /hbase/hbase.version
drwxr-xr-x   - root supergroup          0 2019-01-02 14:58 /hbase/mobdir
drwxr-xr-x   - root supergroup          0 2019-01-02 15:53 /hbase/oldWALs
drwx--x--x   - root supergroup          0 2019-01-02 14:58 /hbase/staging