标签:des style blog http color io os 使用 ar
hbase提供了一个shell的终端给用户交互。使用命令hbase shell进入命令界面。通过执行 help可以看到命令的帮助信息。
以网上的一个学生成绩表的例子来演示hbase的用法。
name | grad | course | |
math | art | ||
Tom | 5 | 97 | 87 |
Jim | 4 | 89 | 80 |
这里grad对于表来说是一个只有它自己的列族,course对于表来说是一个有两个列的列族,这个列族由两个列组成math和art,当然我们可以根据我们的需要在course中建立更多的列族,如computer,physics等相应的列添加入course列族。
(1)建立一个表scores,有两个列族grad和courese
hbase(main):001:0> create ‘scores‘,‘grade‘, ‘course‘
put ‘scores‘,‘Tom‘,‘grade:‘,‘5′
put ‘scores‘,‘Tom‘,‘course:math‘,‘97′
put ‘scores‘,‘Tom‘,‘course:art‘,‘87′
put ‘scores‘,‘Jim‘,‘grade‘,‘4′
put ‘scores‘,‘Jim‘,‘course:‘,‘89′
put ‘scores‘,‘Jim‘,‘course:‘,‘80′
hbase> put ‘t1′, ‘r1′, ‘c1′, ‘value‘, ts1
get ‘scores‘,‘Jim‘
get ‘scores‘,‘Jim‘,‘grade‘
hbase> get ‘t1′, ‘r1′
hbase> get ‘t1′, ‘r1′, {TIMERANGE => [ts1, ts2]}
hbase> get ‘t1′, ‘r1′, {COLUMN => ‘c1′}
hbase> get ‘t1′, ‘r1′, {COLUMN => [‘c1‘, ‘c2‘, ‘c3‘]}
hbase> get ‘t1′, ‘r1′, {COLUMN => ‘c1′, TIMESTAMP => ts1}
hbase> get ‘t1′, ‘r1′, {COLUMN => ‘c1′, TIMERANGE => [ts1, ts2], VERSIONS => 4}
hbase> get ‘t1′, ‘r1′, {COLUMN => ‘c1′, TIMESTAMP => ts1, VERSIONS => 4}
hbase> get ‘t1′, ‘r1′, ‘c1′
hbase> get ‘t1′, ‘r1′, ‘c1′, ‘c2′
hbase> get ‘t1′, ‘r1′, [‘c1‘, ‘c2‘]
scan ‘scores‘
hbase> scan ‘.META.‘
hbase> scan ‘.META.‘, {COLUMNS => ‘info:regioninfo‘}
hbase> scan ‘t1′, {COLUMNS => [‘c1‘, ‘c2‘], LIMIT => 10, STARTROW => ‘xyz‘}
hbase> scan ‘t1′, {COLUMNS => ‘c1′, TIMERANGE => [1303668804, 1303668904]}
hbase> scan ‘t1′, {FILTER => “(PrefixFilter (‘row2′) AND (QualifierFilter (>=, ‘binary:xyz‘))) AND (TimestampsFilter ( 123, 456))”}
hbase> scan ‘t1′, {FILTER => org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(1, 0)}
delete ‘scores‘,‘Jim‘,‘grade‘
delete ‘scores‘,‘Jim‘
hbase> delete ‘t1′, ‘r1′, ‘c1′, ts1
disable ‘scores‘
alter ‘scores‘,NAME=>‘info‘
enable ‘scores‘
hbase> alter ‘t1′, NAME => ‘f1′, VERSIONS => 5
hbase> alter ‘t1′, NAME => ‘f1′, METHOD => ‘delete‘
hbase> alter ‘t1′, ‘delete‘ => ‘f1′
MEMSTORE_FLUSHSIZE, READONLY,和 DEFERRED_LOG_FLUSH:
hbase> alter ‘t1′, METHOD => ‘table_att‘, MAX_FILESIZE => ‘134217728′
hbase> alter ‘t1′, METHOD => ‘table_att‘, ‘coprocessor‘=> ‘hdfs:///foo.jar|com.foo.FooRegionObserver|1001|arg1=1,arg2=2′
[coprocessor jar file location] | class name | [priority] | [arguments]
hbase> alter ‘t1′, METHOD => ‘table_att_unset‘, NAME => ‘MAX_FILESIZE‘
hbase> alter ‘t1′, METHOD => ‘table_att_unset‘, NAME => ‘coprocessor$1′
hbase> alter ‘t1′, {NAME => ‘f1′}, {NAME => ‘f2′, METHOD => ‘delete‘}
hbase> count ‘t1′
hbase> count ‘t1′, INTERVAL => 100000
hbase> count ‘t1′, CACHE => 1000
hbase> count ‘t1′, INTERVAL => 10, CACHE => 1000
drop ‘t1′
COMMAND GROUPS:
Group name: general
Commands: status, version
Group name: ddl
Commands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all,
enable, enable_all, exists, is_disabled, is_enabled, list, show_filters
Group name: dml
Commands: count, delete, deleteall, get, get_counter, incr, put, scan, truncate
Group name: tools
Commands: assign, balance_switch, balancer, close_region, compact, flush, hlog_roll, major_compact,
move, split, unassign, zk_dump
Group name: replication
Commands: add_peer, disable_peer, enable_peer, list_peers, remove_peer, start_replication,
stop_replication
Group name: security
Commands: grant, revoke, user_permission
$ hbase shell test.hbaseshell
标签:des style blog http color io os 使用 ar
原文地址:http://www.cnblogs.com/codework/p/3997862.html