1. 程式人生 > >MacOS安裝單機版HBase

MacOS安裝單機版HBase

開發十年,就只剩下這套架構體系了! >>>   

    MacOS安裝HBase,必然是用於測試了,從簡入手、從簡配置。

    直接通過brew安裝即可:

brew install hbase

    成功安裝後,驗證是否成功,如果不出意外的話,應該有如下輸出:

RippleMBP:~ username$ hbase
Usage: hbase [<options>] <command> [<args>]
Options:
  --config DIR    Configuration direction to use. Default: ./conf
  --hosts HOSTS   Override the list in 'regionservers' file
  --auth-as-server Authenticate to ZooKeeper using servers configuration

Commands:
Some commands take arguments. Pass no args or -h for usage.
  shell           Run the HBase shell
  hbck            Run the hbase 'fsck' tool
  snapshot        Create a new snapshot of a table
  snapshotinfo    Tool for dumping snapshot information
  wal             Write-ahead-log analyzer
  hfile           Store file analyzer
  zkcli           Run the ZooKeeper shell
  upgrade         Upgrade hbase
  master          Run an HBase HMaster node
  regionserver    Run an HBase HRegionServer node
  zookeeper       Run a Zookeeper server
  rest            Run an HBase REST server
  thrift          Run the HBase Thrift server
  thrift2         Run the HBase Thrift2 server
  clean           Run the HBase clean up script
  classpath       Dump hbase CLASSPATH
  mapredcp        Dump CLASSPATH entries required by mapreduce
  pe              Run PerformanceEvaluation
  ltt             Run LoadTestTool
  version         Print the version
  CLASSNAME       Run the class named CLASSNAME

    編輯配置檔案,如果不編輯,是無法成功執行的,通過如下命令判斷安裝路徑:

find / -name hbase

    我的安裝路徑是:/usr/local/Cellar/hbase/1.2.9,編輯如下檔案,將JAVA_HOME配置為自己的

vim /usr/local/Cellar/hbase/1.2.9/libexec/conf/hbase-env.sh
#配置JAVA_HOME
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home"

    編輯如下檔案,大部分保持了預設:

vim /usr/local/Cellar/hbase/1.2.9/libexec/conf/hbase-site.xml 

    編輯後的檔案內容如下(刪除了網路相關的配置資訊):

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///usr/local/var/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.clientPort</name>
    <value>2181</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/usr/local/var/zookeeper</value>
  </property>
</configuration>

啟動HBase:

/usr/local/Cellar/hbase/1.2.9/libexec/bin/start-hbase.sh

檢視HBase狀態,先進入hbase的shell:

hbase shell

然後執行:

hbase(main):001:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 2.0000 average load

hbase(main):002:0> 

至此,HBase單