HBase版本:我們使用1.2.4的版本
HBase安裝模式:
- 單機部署:單臺機器安裝员淫,相關(guān)服務(wù)進程運行在一個JVM
- 單機偽分布式部署:單臺機器安裝济瓢,但是相關(guān)服務(wù)進程運行在單獨的JVM
- 集群部署:多臺機器部署
HBase安裝:
下載安裝包
安裝包下載地址:http://archive.apache.org/dist/hbase/1.2.4/
選擇二進制版本安裝崎淳。
下載后拷貝到安裝目錄:/Users/****/apps安裝
解壓安裝包:
tar zxvf hbase-1.2.4-bin.tar.gz
- 修改/etc/hosts
這一步很重要,HBase會依據(jù)當(dāng)前機器名去解析IP,可能會解析到一個莫名其妙到的IP地址全封,可以參考這個鏈接的問題:http://grokbase.com/t/hbase/user/109eg6z2yq/hbase-standalone-cannot-start-master-cannot-assign-requested-address-at-port-60000
我的電腦名稱是pp_mac,在/etc/hosts文件里面添加一行配置解析到127.0.0.1,如下:
sudo vim /etc/hosts
hbase-2.png
- 修改配置文件
進入解壓的目錄
cd hbase-1.2.4
設(shè)置HBase Home:
vim ~/.bash_profile
hbase-1.png
使.bash_profile配置立即生效
source ~/.bash_profile
進入配置文件目錄:
cd conf
修改配置文件hbase-site.xml,配置如下內(nèi)容:
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:9000/hbase</value>
</property>
<property>
<name>hbase.master</name>
<value>localhost</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/Users/***/apps/data/hbase/zk-data</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>localhost</value>
</property>
- 啟動HBase
$HBASE_HOME/bin/start-hbase.sh &
jps檢查相關(guān)進程是否正常啟動:
jps -l
hbase-3.png
- 使用HBase
HBase的shell是入門HBase的最快方法:
hbase shell
hbase-4.png
分別執(zhí)行創(chuàng)建表刹悴、列出表行楞、添加一條記錄、掃描表和查詢表的一行記錄:
create 'test', 'cf'
list 'test'
put 'test', 'row1', 'cf:a', 'value1'
scan 'test'
get 'test', 'row1'
hbase-5.png
最后打開HBase Master管理頁面:http://localhost:16010/master-status
hbase-6.png