Hbase shell常用操作

开启HBase Shell

进入hbase

[root@k3s-a-1 hbase-2.1.9]# ./bin/hbase shell
2020-05-20 02:59:54,378 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.1.9, rec4145ba5dc9cd30d4eb700bca2de2d08104207c, Tue Feb 11 03:49:57 UTC 2020
Took 0.0041 seconds                                                                                                                                                                                           
hbase(main):001:0> 

帮助

help #查看所有可操作的命令
help command #查看操作命令如何使用

常用操作

刷新写入磁盘

hbase(main):038:0> flush 'test'
Took 0.3084 seconds 

创建test表,至少要有一个组蔟

hbase(main):036:0> create 'test','f1'
Created table test
Took 1.3181 seconds                                                                                                                                                                                           
=> Hbase::Table - test

删除表,要先disable表在删除

hbase(main):030:0> list
TABLE                                                                                                                                                                                                         
t1                                                                                                                                                                                                            
test                                                                                                                                                                                                          
2 row(s)
Took 0.0283 seconds                                                                                                                                                                                           
=> ["t1", "test"]

hbase(main):033:0> disable 'test'
Took 0.0513 seconds 

hbase(main):034:0> drop 'test'
Took 0.8594 seconds 

hbase(main):035:0> list
TABLE                                                                                                                                                                                                         
t1                                                                                                                                                                                                            
1 row(s)
Took 0.0219 seconds                                                                                                                                                                                           
=> ["t1"]

插入数据,指定表中哪个列蔟,在定值。

hbase(main):026:0> put 't1','0001','f1:c1','value2'
Took 15.0419 seconds 

获取数据

hbase(main):014:0> get 't1','0001'
COLUMN                                               CELL                                                                                                                                                    
 f1:c1                                               timestamp=1589956865258, value=value1

通过目录解析hbase文件

[root@k3s-a-1 bin]# ./hbase hfile -p -f /tmp/hbase-root/hbase/data/default/t1/a8543d2f32eece1baafefde86456de89/f1/8a646f8361494048ba66ab4ac6956ccc
2020-05-20 03:11:17,356 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2020-05-20 03:11:18,051 INFO  [main] metrics.MetricRegistries: Loaded MetricRegistries class org.apache.hadoop.hbase.metrics.impl.MetricRegistriesImpl
K: 0001/f1:c1/1589957686560/Put/vlen=6/seqid=6 V: value3
Scanned kv count -> 1

你可能感兴趣的:(BigData)