[Apache] Hbase 常用指令

Hbase 常用的指令筆記一下.

Login

hbase shell

help

Get the description to all command.

Version

hbase(main):002:0> version
2.1.6.3.1.5.95-1, rUnknown, Mon Aug 24 10:07:41 UTC 2020
Took 0.0012 seconds

whoami

hbase(main):003:0> whoami
grayyin@test.test (auth:KERBEROS)
Took 0.4917 seconds

create_namespace

hbase(main):006:0> create_namespace 'test_namespace'

list_namespace_tables

hbase(main):013:0> list_namespace_tables 'test_namespace'
TABLE
testtable1
1 row(s)

create 'table name', 'column family 1', 'column family 2', ...

hbase(main):033:0> create 'test_namespace:test_table1', 'columnfamily1'
Created table test_namespace:test_table1
Took 18.3644 seconds

describe

hbase(main):034:0> describe 'test_namespace:test_table1'
Table test_namespace:test_table1 is ENABLED
test_namespace:test_table1
COLUMN FAMILIES DESCRIPTION
{NAME => 'columnfamily1', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA
_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false
', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}
1 row(s)
Took 0.0209 seconds

list & list_namespace

hbase(main):010:0> list_namespace
NAMESPACE
default

get
get 'table name', 'row key', 'column family:qualifier'

put
put 'table name', 'row key', 'column family:qualifier', 'value'

scan
scan 'table name'

List the rowkey start with rowkeyInitXXXX
EX:

hbase(main):005:0> scan 'test_namespace:test_table1', FILTER => "PrefixFilter ('rowkeyInit')"

scan filter by {$keyword1} & {$keyword2}

EX:

hbase(main):006:0> scan "test_nampspace:test_table", { FILTER => "SingleColumnValueFilter('columnfamily1', 'column1', =,'binary:{$keyword1}') AND SingleColumnValueFilter('columnfamily1','column2',=,'binary:{$keyword2}')"}

Datetime filter

EX:

hbase(main):019:0* scan 'test_nampspace:test_table', FILTER => "SingleColumnValueFilter('columnfamily1', 'datetime_type_column' ,>, 'binary:2021-04-15 06:25:29.02') AND SingleColumnValueFilter('columnfamily1', 'datetime_type_column' ,>, 'binary:2021-04-15 07:25:29.02')"

 

delete
delete 'table name', 'row key', 'column family:qualifier'

drop table
disable 'table name'

drop 'table name'

hbase(main):031:0* disable 'test_namespace'
Took 6.2468 seconds
hbase(main):032:0> drop 'test_namespace'
Took 8.3564 seconds

deleteall
deleteall 'table name', 'row key'