原帖地址: http://blog.csdn.net/nsrainbow/article/details/38758375
[root@localhost conf]# hbase shell 2014-08-22 16:10:47,662 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version 0.96.1.1-cdh5.0.1, rUnknown, Tue May 6 13:27:24 PDT 2014
hbase(main):001:0> create 'student', 'info' 0 row(s) in 4.3300 seconds => Hbase::Table - student
hbase(main):002:0> put 'student','row1','info:name','jack' 0 row(s) in 0.1990 seconds意思是往 student 的 name 列中插入一个值 jack
hbase(main):003:0> get 'student','row1','info:name' COLUMN CELL info:name timestamp=1408697225683, value=jack 1 row(s) in 0.0490 seconds查出来了。
hbase(main):004:0> put 'student','row1','info:sid','1' 0 row(s) in 0.0200 seconds hbase(main):005:0> put 'student','row1','info:age','22' 0 row(s) in 0.0210 seconds然后我们用scan命令查询一下整个表
hbase(main):006:0> scan 'student' ROW COLUMN+CELL row1 column=info:age, timestamp=1408697651322, value=22 row1 column=info:name, timestamp=1408697225683, value=jack row1 column=info:sid, timestamp=1408697640490, value=1 1 row(s) in 0.0580 seconds
hbase(main):005:0> scan 'student' ROW COLUMN+CELL row1 column=info:age, timestamp=1420817226790, value=22 row1 column=info:name, timestamp=1420817205836, value=jack row1 column=info:sid, timestamp=1420817219869, value=1 row2 column=info:age, timestamp=1420817278346, value=28 row2 column=info:name, timestamp=1420817252182, value=terry row2 column=info:sid, timestamp=1420817267780, value=2 row3 column=info:age, timestamp=1420817315351, value=18 row3 column=info:name, timestamp=1420817294342, value=billy row3 column=info:sid, timestamp=1420817304621, value=3 row4 column=info:name, timestamp=1420858768667, value=karry row4 column=info:sid, timestamp=1420858794556, value=4 4 row(s) in 1.0990 seconds
scan 'student',{'LIMIT'=>2}
hbase(main):006:0> scan 'student',{'LIMIT'=>2} ROW COLUMN+CELL row1 column=info:age, timestamp=1420817226790, value=22 row1 column=info:name, timestamp=1420817205836, value=jack row1 column=info:sid, timestamp=1420817219869, value=1 row2 column=info:age, timestamp=1420817278346, value=28 row2 column=info:name, timestamp=1420817252182, value=terry row2 column=info:sid, timestamp=1420817267780, value=2 2 row(s) in 0.8250 seconds
hbase(main):007:0> scan 'student',{'STARTROW'=>'row2'} ROW COLUMN+CELL row2 column=info:age, timestamp=1420817278346, value=28 row2 column=info:name, timestamp=1420817252182, value=terry row2 column=info:sid, timestamp=1420817267780, value=2 row3 column=info:age, timestamp=1420817315351, value=18 row3 column=info:name, timestamp=1420817294342, value=billy row3 column=info:sid, timestamp=1420817304621, value=3 row4 column=info:name, timestamp=1420858768667, value=karry row4 column=info:sid, timestamp=1420858794556, value=4
hbase(main):008:0> scan 'student',{'STARTROW'=>'row*'} ROW COLUMN+CELL row1 column=info:age, timestamp=1420817226790, value=22 row1 column=info:name, timestamp=1420817205836, value=jack row1 column=info:sid, timestamp=1420817219869, value=1 row2 column=info:age, timestamp=1420817278346, value=28 row2 column=info:name, timestamp=1420817252182, value=terry row2 column=info:sid, timestamp=1420817267780, value=2 row3 column=info:age, timestamp=1420817315351, value=18 row3 column=info:name, timestamp=1420817294342, value=billy row3 column=info:sid, timestamp=1420817304621, value=3 row4 column=info:name, timestamp=1420858768667, value=karry row4 column=info:sid, timestamp=1420858794556, value=4 4 row(s) in 0.2830 seconds
hbase(main):009:0> scan 'student',{'STARTROW'=>'row2','LIMIT'=>1} ROW COLUMN+CELL row2 column=info:age, timestamp=1420817278346, value=28 row2 column=info:name, timestamp=1420817252182, value=terry row2 column=info:sid, timestamp=1420817267780, value=2 1 row(s) in 0.1890 seconds
hbase(main):011:0> scan 'student',{'COLUMNS'=>['info:name','info:age'],LIMIT=>3} ROW COLUMN+CELL row1 column=info:age, timestamp=1420817226790, value=22 row1 column=info:name, timestamp=1420817205836, value=jack row2 column=info:age, timestamp=1420817278346, value=28 row2 column=info:name, timestamp=1420817252182, value=terry row3 column=info:age, timestamp=1420817315351, value=18 row3 column=info:name, timestamp=1420817294342, value=billy 3 row(s) in 0.4470 seconds
hbase(main):012:0> scan 'student',{'TIMESTAMP'=>1420817315351} ROW COLUMN+CELL row3 column=info:age, timestamp=1420817315351, value=18 1 row(s) in 0.1920 seconds
hbase(main):073:0> get 'student','row1' COLUMN CELL info:age timestamp=1420817226790, value=22 info:name timestamp=1420817205836, value=jack info:sid timestamp=1420817219869, value=1 3 row(s) in 0.1730 seconds
hbase(main):076:0> get 'student','row1',{COLUMN=>['info:name','info:sid']} COLUMN CELL info:name timestamp=1420817205836, value=jack info:sid timestamp=1420817219869, value=1 2 row(s) in 0.0490 seconds hbase(main):077:0> get 'student','row1',{COLUMN=>['info:name','info:sid'],TIMESTAMP=>1420817219869,VERSION=>1} COLUMN CELL info:sid timestamp=1420817219869, value=1 1 row(s) in 0.0740 seconds
hbase(main):013:0> describe 'student' DESCRIPTION ENABLED 'student', {NAME => 'info', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', true REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', I N_MEMORY => 'false', BLOCKCACHE => 'true'} 1 row(s) in 7.6720 seconds
alter 'student', {NAME => 'f2', VERSION => 2}
hbase(main):057:0> describe 'student' DESCRIPTION ENABLED 'student', {NAME => 'f2', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', R true EPLICATION_SCOPE => '0', COMPRESSION => 'NONE', VERSIONS => '1', TTL => 'FOREVER ', MIN_VERSIONS => '0', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_ MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'info', DATA_BLOCK_ENCODING = > 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPR ESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => ' false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} 1 row(s) in 0.6180 seconds
alter 'student', {NAME => 'f2', TTL => 20}
hbase(main):061:0> describe 'student' DESCRIPTION ENABLED 'student', {NAME => 'f2', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', R true EPLICATION_SCOPE => '0', COMPRESSION => 'NONE', VERSIONS => '1', TTL => '20 SECO NDS', MIN_VERSIONS => '0', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'info', DATA_BLOCK_ENCODIN G => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', CO MPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS = > 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} 1 row(s) in 0.1540 seconds
hbase(main):065:0> put 'student','row3','f2:grade','2' 0 row(s) in 0.0650 seconds hbase(main):066:0> scan 'student',{STARTROW=>'row3',LIMIT=>1} ROW COLUMN+CELL row3 column=f2:grade, timestamp=1420872179176, value=2 row3 column=info:age, timestamp=1420817315351, value=18 row3 column=info:name, timestamp=1420817294342, value=billy row3 column=info:sid, timestamp=1420817304621, value=3 1 row(s) in 0.0630 seconds hbase(main):067:0> scan 'student',{STARTROW=>'row3',LIMIT=>1} ROW COLUMN+CELL row3 column=info:age, timestamp=1420817315351, value=18 row3 column=info:name, timestamp=1420817294342, value=billy row3 column=info:sid, timestamp=1420817304621, value=3 1 row(s) in 0.1370 seconds
hbase(main):068:0> alter 'student', {NAME => 'f2', METHOD=>'delete'} Updating all regions with the new schema... 0/1 regions updated. 1/1 regions updated. Done. 0 row(s) in 3.9750 seconds hbase(main):069:0> describe 'student' DESCRIPTION ENABLED 'student', {NAME => 'info', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', true REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', I N_MEMORY => 'false', BLOCKCACHE => 'true'} 1 row(s) in 0.2210 seconds
hbase(main):082:0> count 'student' 4 row(s) in 0.6410 seconds => 4
hbase(main):083:0> count 'student',2 Current count: 2, row: row2 Current count: 4, row: row4 4 row(s) in 0.0480 seconds => 4 hbase(main):084:0> count 'student',1 Current count: 1, row: row1 Current count: 2, row: row2 Current count: 3, row: row3 Current count: 4, row: row4 4 row(s) in 0.0650 seconds => 4
hbase(main):079:0> list TABLE employee employee2 student 3 row(s) in 0.2020 seconds => ["employee", "employee2", "student"]
hbase(main):013:0> status 1 servers, 0 dead, 3.0000 average load
hbase(main):070:0> list TABLE employee employee2 student 3 row(s) in 0.6380 seconds => ["employee", "employee2", "student"]
hbase(main):014:0> whoami root (auth:SIMPLE)
hbase(main):086:0> truncate 'student' Truncating 'student' table (it may take a while): - Disabling table... - Dropping table... - Creating table... 0 row(s) in 4.6330 seconds