HBase单机standalone模式搭建(无需Hadoop)

hbase standalone模式可以快速在单机下搭建HBase环境,快速测试HBase应用程序逻辑是否正确,而无需维护分布式集群等其他不必要的工作。standalone的HBase拥有HBase系统所有的进程:Master、RegionServers、ZooKeeper,这些所有的进程都运行于同一个Java虚拟机进程,运行于本地文件系统上。

安装之前需要保证电脑已经安装了JDK。

首先下载HBase:

https://www.apache.org/dyn/closer.lua/hbase/

第一行有一个suggested site,从那里下载HBase,下载.tar.gz文件,不要下载。src.tar.gz。将压缩文件解压到指定目录。命令格式是:

tar xzvf 压缩文件名

进入解压后的目录,编辑conf/hbase-env.sh文件,找到包含JAVA_HOME的那一行,去掉注释符号,将JAVA_HOME设定成系统的JAVA_HOME值。可以通过命令

echo $JAVA_HOME

查看系统JAVA_HOME值。

编辑conf/hbase-site.xml文件,这个文件是hbase的配置文件,在这个文件里面,需要指定HBase和ZooKeeper的数据存储路径,一下是配置文件的一个示例:



<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///home/testuser/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/home/testuser/zookeeper</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>

file://表示存储于本地文件系统上,hbase数据存储在/home/testuser/hbase目录下,zookeeper数据存储在/home/testuser/zookeeper目录下。在安装了hadoop的前提下,可以将hbase.rootdir指定为HDFS文件系统。例如:hdfs://namenode.example.org:8020/hbase

运行bin/start-hbase.sh可以启动hbase,输入jps命令,可以如果当前有一个HMaster进程在运行,说明standalone的HBase已经启动了。

输入命令

./bin/hbase shell

即可进入hbase shell界面,通过命令行与hbase交互。

运行脚本./bin/stop-hbase.sh即可停止hbase

猜你喜欢

转载自blog.csdn.net/LOVETEDA/article/details/86487353