二、安裝教程(單機版)
1,下載二進值包
(1)首次我們訪問:https://archive.apache.org/dist/hbase,頁面打開后點擊 stable 鏈接(這里面為當前最穩定的版本)
(2)接着找到 hbase-2.2.4-bin.tar.gz 鏈接地址,然后在服務器上通過 wget 命令將其下載下來: 推薦使用hbase-2.2.4版本
wget https://archive.apache.org/dist/hbase/2.2.4/hbase-2.2.4-bin.tar.gz
(3)接着解壓下載的文件:
tar xzvf hbase-2.2.4-bin.tar.gz
(4)然后將解壓出來的文件夾移動到 /home 目錄下:
mv hbase-2.2.4 /home/
(5)最后進入這個 HBase 文件夾:
cd /home/hbase-2.2.4/
2,修改配置
vim conf/hbase-env.sh
(2)取消 #export JAVA_HOME= 開頭的注釋,然后將其設置為 Java 安裝路徑: 在hbase-env.sh
(3)接着執行如下命令編輯 conf/hbase-site.xml,這是主要的 HBase 配置文件。
vi conf/hbase-site.xml
(4)默認情況下 <configuration></configuration> 節點里面是空的,我們在里面添加如下配置指定 hbase 和 ZooKeeper 數據寫入的目錄:
提示:這兩個目錄地址可以根據需求自由設置。另外,這兩個文件夾無需事先創建,HBase 會自動創建好。也可以自己創建好
<!-- hbase存放數據目錄 --> <property> <name>hbase.rootdir</name> <value>file:///home/hbase-2.2.4/hbase</value> </property> <!-- ZooKeeper數據文件路徑 --> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/home/hbase-2.2.4/zookeeper</value> </property> <property> <name>hbase.master.ipc.address</name> <value>0.0.0.0</value> </property> <property> <name>hbase.regionserver.ipc.address</name> <value>0.0.0.0</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>
注意ZooKeeper數據文件路徑 要寫 百度上很多教程沒寫 自帶zookeeper沒啟動,報各種錯
3,啟動 HBase
./bin/start-hbase.sh
(2)執行如下命令停止 HBase:
./bin/stop-hbase.sh
4,查看是否啟動成功

(2)或者也可以使用瀏覽器訪問 HBase 的 Web UI,地址為 http://IP:16010
注意 這里雲服務器 安全組 最好把2181,16000,16010,16020端口和系統防火牆開放端口 因為訪問ui界面和java api調用不通報各種錯。
附:使用 HBase 命令行工具測試
1,啟動命令行工具
cd /home/hbase-2.2.4/
./bin/hbase shell
2,創建、查看表
create 'test', 'cf'
(2)使用 list 命令可以列出所有的表:
list
(3)使用 describe 命令查看詳細信息,包括配置默認值:
describe 'test'
3,插入、查詢數據
put 'test', 'row1', 'cf:a', 'value1' put 'test', 'row2', 'cf:b', 'value2' put 'test', 'row3', 'cf:c', 'value3'
(2)使用 scan 命令可以查看表中的所有數據:
scan 'test'
(3)使用 get 命令則可以獲取單行的數據:
get 'test', 'row1'
4,禁用、刪除表
(1)如果要刪除表或更改其設置,以及在某些其他情況下,則需要先使用 disable 命令禁用該表:disable 'test'
(2)如果表被禁用,可以使用 enable 命令重新啟用它:
enable 'test'
(3)將表禁用后,我們就可以使用 drop 命令刪除表:
drop 'test'
ZooKeeper數據文件路徑