- 下载,解压缩包
http://www.apache.org/dyn/closer.cgi/hbase/
- 修改HBase配置文件
1、 hbase-env.sh
取消配置JDK的注释并做并如下修改(我的JDK安装路径):
export JAVA_HOME=/usr/java/jdk1.6.0_27/
2、 hbase-site.xml
因为是单机启动,所以只设定了HBase写入的本地路径,修改如下:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hbase.rootdir</name>
<value>/home/hbase</value>
</property>
</configuration>
- 启动
$bin/start-hbase.sh
- shell验证
$bin/hbase shell
- 建表操作演示
hbase(main):004:0> create 'table1','col1'
0 row(s) in 1.1070 seconds
hbase(main):005:0> list
TABLE
table1
test1
2 row(s) in 0.0210 seconds
hbase(main):006:0> put 'table1','row1','col1:a','value1'
0 row(s) in 0.2710 seconds
hbase(main):008:0> put 'table1','row2','col1:b','value2'
0 row(s) in 0.0090 seconds
hbase(main):009:0> put 'table1','row3','col1:c','value3'
0 row(s) in 0.0070 seconds
- 用scan查看表所有数据
hbase(main):010:0> scan 'table1'
ROW COLUMN+CELL
row1 column=col1:a, timestamp=1317180621803, value=value1
row2 column=col1:b, timestamp=1317180679999, value=value2
row3 column=col1:c, timestamp=1317180708854, value=value3
3 row(s) in 0.0570 seconds
- 用get查看单行数据
hbase(main):011:0> get 'table1','row1'
COLUMN CELL
col1:a timestamp=1317180621803, value=value1
1 row(s) in 0.0160 seconds
- 用disable和drop删除表
hbase(main):017:0> disable 'table1'
0 row(s) in 2.0470 seconds
hbase(main):018:0> drop 'table1'
0 row(s) in 0.0960 seconds
hbase(main):019:0> list
TABLE
1 row(s) in 0.0170 seconds
- 停止HBase
$ bin/stop-hbase.sh
stopping hbase.......
- 通过浏览器查看HBase信息