• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

Hbase-02-shell 命令

开发技术 开发技术 5小时前 1次浏览

1.创建表

hbase:003:0> create 'test','cf'
Created table test
Took 0.9345 seconds
=> Hbase::Table - test

2.查询表

hbase:004:0> list 'test'
TABLE
test
1 row(s)
Took 0.0187 seconds
=> ["test"]

3.查看表详情

hbase:006:0> describe 'test'
Table test is ENABLED
test
COLUMN FAMILIES DESCRIPTION
{NAME => 'cf', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', COMPRESSION => 'NONE', TTL => 'FOREVER', MIN_VERSIONS
 => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}

1 row(s)
Quota is disabled
Took 0.1167 seconds

4.insert

hbase:007:0> put 'test','row1','cf:a','value1'
Took 0.0781 seconds
hbase:008:0> put 'test','row2','cf:b','value2'
Took 0.0024 seconds
hbase:009:0> put 'test','row3','cf:c','value3'
Took 0.0028 seconds

5.一次性查询所有的数据

hbase:010:0> scan 'test'
ROW                                           COLUMN+CELL
 row1                                         column=cf:a, timestamp=2021-07-02T15:27:50.999, value=value1
 row2                                         column=cf:b, timestamp=2021-07-02T15:28:03.776, value=value2
 row3                                         column=cf:c, timestamp=2021-07-02T15:28:13.198, value=value3
3 row(s)
Took 0.0241 seconds

6.获取一行的数据

hbase:011:0> get 'test','row1'
COLUMN                                        CELL
 cf:a                                         timestamp=2021-07-02T15:27:50.999, value=value1
1 row(s)
Took 0.0107 seconds

7.启用、禁用表

hbase:012:0> disable 'test'
Took 0.3510 seconds
hbase:013:0> enable 'test'
Took 0.6492 seconds

8.删除表

drop 'test'

退出webshell

quit

9.合并表

  hbase> merge_region 'FULL_REGIONNAME', 'FULL_REGIONNAME'
  hbase> merge_region 'FULL_REGIONNAME', 'FULL_REGIONNAME', 'FULL_REGIONNAME', ...
  hbase> merge_region 'FULL_REGIONNAME', 'FULL_REGIONNAME', 'FULL_REGIONNAME', ..., true
  
  hbase> merge_region ['FULL_REGIONNAME', 'FULL_REGIONNAME']
  hbase> merge_region ['FULL_REGIONNAME', 'FULL_REGIONNAME', 'FULL_REGIONNAME', ...]
  hbase> merge_region ['FULL_REGIONNAME', 'FULL_REGIONNAME', 'FULL_REGIONNAME', ...], true
  
  hbase> merge_region 'ENCODED_REGIONNAME', 'ENCODED_REGIONNAME'
  hbase> merge_region 'ENCODED_REGIONNAME', 'ENCODED_REGIONNAME', 'ENCODED_REGIONNAME', ...
  hbase> merge_region 'ENCODED_REGIONNAME', 'ENCODED_REGIONNAME', 'ENCODED_REGIONNAME', ..., true
  
  hbase> merge_region ['ENCODED_REGIONNAME', 'ENCODED_REGIONNAME']
  hbase> merge_region ['ENCODED_REGIONNAME', 'ENCODED_REGIONNAME', 'ENCODED_REGIONNAME', ...]
  hbase> merge_region ['ENCODED_REGIONNAME', 'ENCODED_REGIONNAME', 'ENCODED_REGIONNAME', ...], true

10.scan

  hbase> scan 'hbase:meta'
  hbase> scan 'hbase:meta', {COLUMNS => 'info:regioninfo'}
  hbase> scan 'ns1:t1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, STARTROW => 'xyz'}
  hbase> scan 't1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, STARTROW => 'xyz'}
  hbase> scan 't1', {COLUMNS => 'c1', TIMERANGE => [1303668804000, 1303668904000]}
  hbase> scan 't1', {REVERSED => true}
  hbase> scan 't1', {ALL_METRICS => true}
  hbase> scan 't1', {METRICS => ['RPC_RETRIES', 'ROWS_FILTERED']}
  hbase> scan 't1', {ROWPREFIXFILTER => 'row2', FILTER => "
    (QualifierFilter (>=, 'binary:xyz')) AND (TimestampsFilter ( 123, 456))"}
  hbase> scan 't1', {FILTER =>
    org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(1, 0)}
  hbase> scan 't1', {CONSISTENCY => 'TIMELINE'}
  hbase> scan 't1', {ISOLATION_LEVEL => 'READ_UNCOMMITTED'}
  hbase> scan 't1', {MAX_RESULT_SIZE => 123456}
For setting the Operation Attributes
  hbase> scan 't1', { COLUMNS => ['c1', 'c2'], ATTRIBUTES => {'mykey' => 'myvalue'}}
  hbase> scan 't1', { COLUMNS => ['c1', 'c2'], AUTHORIZATIONS => ['PRIVATE','SECRET']}

11.major_compact

hbase:001:0> help 'major_compact'
Run major compaction on passed table or pass a region row
to major compact an individual region. To compact a single
column family within a region specify the region name
followed by the column family name.
Examples:
Compact all regions in a table:
hbase> major_compact 't1'
hbase> major_compact 'ns1:t1'
Compact an entire region:
hbase> major_compact 'r1'
Compact a single column family within a region:
hbase> major_compact 'r1', 'c1'
Compact a single column family within a table:
hbase> major_compact 't1', 'c1'
Compact table with type "MOB"
hbase> major_compact 't1', nil, 'MOB'
Compact a column family using "MOB" type within a table
hbase> major_compact 't1', 'c1', 'MOB'

程序员灯塔
转载请注明原文链接:Hbase-02-shell 命令
喜欢 (0)