1. 介绍
2. 安装
进入官网下载最新版本:http:// hbase.apache.org/
下载
#直接下载安装: $ mkdir hbase-install $ cd hbase-install $ wget http://apache.claz.org/hbase/hbase-0.92.1/hbase-0.92.1.tar.gz $ tar xvfz hbase-0.92.1.tar.gz #####或手动安装 $ mkdir hbase-install $ mv hbase-0.94.20.tar.gz hbase-install/ $ cd hbase-install/ $ tar xvfz hbase-0.94.20.tar.gz x hbase-0.94.20/
配置及启动HBase服务器
$ export HBASE_HOME=`pwd`/hbase-0.94.20 $ $HBASE_HOME/bin/start-hbase.sh starting master, logging to /Users/klaus/Documents/study/java/bigdata/hbase-install/hbase-0.94.20/logs/hbase-klaus-master-klaus.local.out
启动后的管理页面截图
3. 简单使用
- 显示所有表 list
- 创建表 create 'table', 'column family'
- 往表里插入数据 put 'table name' , 'column' , 'key', 'value'
- 读取表数据 get 'table name', 'column'
- 读取表里所有数据 scan 'table name'
$ $HBASE_HOME/bin/hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.94.20, r09c60d770f2869ca315910ba0f9a5ee9797b1edc, Fri May 23 22:00:41 PDT 2014
hbase(main):001:0> list
TABLE
2014-07-04 00:10:13.517 java[699:1003] Unable to load realm info from SCDynamicStore
0 row(s) in 0.4350 seconds
hbase(main):002:0> creae 'mytable', 'cf'
NoMethodError: undefined method `creae' for #<Object:0xffc7b3a>
hbase(main):003:0> create 'mytable', 'cf'
0 row(s) in 5.1260 seconds
hbase(main):004:0> list
TABLE
mytable
1 row(s) in 0.0190 seconds
hbase(main):005:0> create 'mytable', 'cf'
ERROR: Table already exists: mytable!
Here is some help for this command:
Create table; pass table name, a dictionary of specifications per
column family, and optionally a dictionary of table configuration.
Dictionaries are described below in the GENERAL NOTES section.
Examples:
hbase> create 't1', {NAME => 'f1', VERSIONS => 5}
hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
hbase> # The above in shorthand would be the following:
hbase> create 't1', 'f1', 'f2', 'f3'
hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}
hbase> create 't1', 'f1', {SPLITS => ['10', '20', '30', '40']}
hbase> create 't1', 'f1', {SPLITS_FILE => 'splits.txt'}
hbase> # Optionally pre-split the table into NUMREGIONS, using
hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname)
hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'}
hbase(main):006:0> create 'hello', 'hello'
0 row(s) in 1.0600 seconds
hbase(main):007:0> list
TABLE
hello
mytable
2 row(s) in 0.0220 seconds
hbase(main):008:0> delete
delete delete_snapshot deleteall
hbase(main):008:0> delete hello
NameError: undefined local variable or method `hello' for #<Object:0xffc7b3a>
hbase(main):009:0> delete 'hello'
ERROR: wrong number of arguments (1 for 3)
Here is some help for this command:
Put a delete cell value at specified table/row/column and optionally
timestamp coordinates. Deletes must match the deleted cell's
coordinates exactly. When scanning, a delete cell suppresses older
versions. To delete a cell from 't1' at row 'r1' under column 'c1'
marked with the time 'ts1', do:
hbase> delete 't1', 'r1', 'c1', ts1
hbase(main):010:0> delete 'hello', 'hello'
ERROR: wrong number of arguments (2 for 3)
Here is some help for this command:
Put a delete cell value at specified table/row/column and optionally
timestamp coordinates. Deletes must match the deleted cell's
coordinates exactly. When scanning, a delete cell suppresses older
versions. To delete a cell from 't1' at row 'r1' under column 'c1'
marked with the time 'ts1', do:
hbase> delete 't1', 'r1', 'c1', ts1
hbase(main):011:0> put 'mytable', 'first', 'cf:message', 'hello HBase'
0 row(s) in 0.0730 seconds
hbase(main):012:0> put 'mytable', 'second', 'cf:foo', 0x0
0 row(s) in 0.0200 seconds
hbase(main):013:0> put 'mytable', 'third', 'cf:bar', 3.14159
0 row(s) in 0.0150 seconds
hbase(main):014:0> get 'mytable', 'hello'
COLUMN CELL
0 row(s) in 0.0210 seconds
hbase(main):015:0> get 'mytable', 'cf:foo'
COLUMN CELL
0 row(s) in 0.0040 seconds
hbase(main):016:0> get 'mytable', 'first'
COLUMN CELL
cf:message timestamp=1404404100808, value=hello HBase
1 row(s) in 0.0140 seconds
hbase(main):017:0> put 'mytable', 'first', 'cf:message', 'newvalue'
0 row(s) in 0.0160 seconds
hbase(main):018:0> get 'mytable', 'first'
COLUMN CELL
cf:message timestamp=1404404364748, value=newvalue
1 row(s) in 0.0170 seconds
hbase(main):019:0> scan 'mytable'
ROW COLUMN+CELL
first column=cf:message, timestamp=1404404364748, value=newvalue
second column=cf:foo, timestamp=1404404148293, value=0
third column=cf:bar, timestamp=1404404164447, value=3.14159
3 row(s) in 0.0340 seconds
hbase(main):020:0>