下载:http://mirror.bit.edu.cn/apache/hbase/stable/
官方指南:http://abloz.com/hbase/book.html
安装配置
解压:tar -xzvf hbase-0.96.0-hadoop1-bin.tar.gz,放到指定目录。
编辑配置文件:sudo gedit /etc/profile
## Setting HBase
export HBASE_HOME=/usr/local/software/hbase-1.3.1
export PATH=${PATH}:${HBASE_HOME}/bin
进入$hbase/lib下查看相关的hadoop包,看是哪个版本的hadoop。
配置参数,修改hbase-site.xml:
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:9000/hbase</value>
<description>The directory shared by RegionServers.</description>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
<description>The replication count for HLog and HFile storage. Should not be greater than HDFS datanode count.
</description>
</property>
</configuration>
伪分布式启动
伪分布式是基于HDFS的,所以需要先启动HDFS. 启动命令:start-all.sh
启动hbase: start-hbase.sh
HBase Shell
启动命令:hbase shell
HBase Shell练习
建表
hbase(main):006:0> create 'test','cf'
列出所有表
hbase(main):007:0> list
TABLE
test
1 row(s) in 0.0440 seconds
=> ["test"]
插入数据
hbase(main):008:0> put 'test','row1','cf:a','value1'
0 row(s) in 0.0750 seconds
hbase(main):009:0> put 'test','row2','cf:b','value2'
0 row(s) in 0.0080 seconds
hbase(main):010:0> put 'test','row3','cf:c','value3'
0 row(s) in 0.0060 seconds
检查插入情况
hbase(main):011:0> scan 'test'
ROW COLUMN+CELL
row1 column=cf:a, timestamp=1386389158263, value=value1
row2 column=cf:b, timestamp=1386389170821, value=value2
row3 column=cf:c, timestamp=1386389185954, value=value3
3 row(s) in 0.0450 seconds
get一行
hbase(main):012:0> get 'test','row2'
COLUMN CELL
cf:b timestamp=1386389170821, value=value2
1 row(s) in 0.0140 seconds
disable之后drop表
hbase(main):013:0> disable 'test'
0 row(s) in 1.4220 seconds
hbase(main):014:0> drop 'test'
0 row(s) in 0.2740 seconds
hbase(main):015:0> list
TABLE
0 row(s) in 0.0270 seconds
=> []