1、配置
(1)编辑$HBASE_HOME/conf/ hbase-env.sh配置环境变量JAVA_HOME;
(2)编辑$HBASE_HOME/conf/hbase-site.xml, 增加如下配置(与Hadoop保持一致):
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:9000/hbase</value>
<description>The directory shared by region servers.
</description>
</property>
2、使用
#启动HBase
[root@yy1 hbase-0.20.5]# bin/start-hbase.sh
localhost: starting zookeeper, logging to /root/hadoop/hbase-0.20.5/bin/../logs/hbase-root-zookeeper-yy1.out
starting master, logging to /root/hadoop/hbase-0.20.5/bin/../logs/hbase-root-master-yy1.out
localhost: starting regionserver, logging to /root/hadoop/hbase-0.20.5/bin/../logs/hbase-root-regionserver-yy1.out
[root@yy1 hbase-0.20.5]# bin/hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Version: 0.20.5, r956266, Sat Jun 19 12:25:12 PDT 2010
hbase(main):001:0>
#创建表test
hbase(main):003:0> create "test","data"
0 row(s) in 1.3560 seconds
hbase(main):004:0> describe "test"
DESCRIPTION ENABLED
{NAME => 'test', FAMILIES => [{NAME => 'data', COMPRESSION => 'NONE', true
VERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY
=> 'false', BLOCKCACHE => 'true'}]}
1 row(s) in 0.0610 seconds
#插入数据
hbase(main):005:0> put "test","row1","data:1","value1"
0 row(s) in 0.0060 seconds
hbase(main):006:0> put "test","row2","data:2","value2"
0 row(s) in 0.0100 seconds
hbase(main):007:0> scan "test"
ROW COLUMN+CELL
row1 column=data:1, timestamp=1277968472718, value=value1
row2 column=data:2, timestamp=1277968487913, value=value2
2 row(s) in 0.0350 seconds
hbase(main):009:0> get "test", "row1"
COLUMN CELL
data:1 timestamp=1277968472718, value=value1
1 row(s) in 0.0100 seconds
#停止HBase
[root@yy1 hbase-0.20.5]# bin/stop-hbase.sh
stopping master..............................
localhost: stopping zookeeper.
#HBase创建的文件
[root@yy1 hadoop-0.20.2]# bin/hadoop fs -ls /hbase
Found 5 items
drwxr-xr-x - root supergroup 0 2010-07-01 14:51 /hbase/-ROOT-
drwxr-xr-x - root supergroup 0 2010-07-01 14:51 /hbase/.META.
drwxr-xr-x - root supergroup 0 2010-07-01 15:18 /hbase/.logs
-rw-r--r-- 3 root supergroup 3 2010-07-01 14:51 /hbase/hbase.version
drwxr-xr-x - root supergroup 0 2010-07-01 15:12 /hbase/test
[root@yy1 hadoop-0.20.2]# bin/hadoop fs -ls /hbase/test
Found 1 items
drwxr-xr-x - root supergroup 0 2010-07-01 15:18 /hbase/test/1886847087