HBase Shell命令(1.2官方文档)参考博客https://blog.csdn.net/gk_kk/article/details/74216361
HBase Shell 是Apache HBase官方提供的SHell命令行操作接口,通过执行命令的方式操作HBase,如果已经配置HBase的环境变量,就可以在Linux的SHell命令行终端执行hbase shell 命令进入【HBase Shell 命令行终端】
[root@hadoop ~]# hbase shell
2020-01-19 10:07:20,147 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
2020-01-19 10:07:22,511 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase-1.2.0-cdh5.7.0/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop-2.6.0-cdh5.7.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.0-cdh5.7.0, rUnknown, Wed Mar 23 11:46:29 PDT 2016
hbase(main):001:0>
HBase Shell常用操作命令
(1) create命令在Hbase库创建一张新表
hbase(main):009:0> create 'students', 'info'
0 row(s) in 1.4030 seconds
=> Hbase::Table - students
说明:students是表名,info是列族名
(2) list命令查看HBase库中存在哪些表
hbase(main):011:0> list
TABLE
students
1 row(s) in 0.0240 seconds
=> ["students"]
(3) describe命令查看表属性
hbase(main):012:0> describe 'students'
Table studentsis ENABLED
students COLUMN FAMILIES DESCRIPTION
{NAME => 'info', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SC
OPE => '0'}
1 row(s) in 0.0680 seconds
说明:Name表示列族名称,后面的属性信息都是针对列族的
(4) alter命令修改表
a)为指定表增加一个新的列族
hbase(main):013:0> alter 'students', 'scores'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.3280 seconds
或执行等效命令:alter "students" , { NAME => 'scores'}
b)删除指定表的指定列族
hbase(main):032:0> alter "students" , { NAME => 'scores', METHOD => 'delete' }
c)修改指定表的列族属性
修改列族版本号为3:
hbase(main):032:0> alter 'students', { NAME => 'scores', VERSIONS => 3 }
修改压缩模式为GZ:
hbase(main):032:0> alter 'students', { NAME => 'scores', COMPRESSION => 'GZ'}
说明:执行alter命令后,再执行describe 'students'命令查看对students表的列族属性的修改
(5) put命令插入数据(单元格)
hbase(main):016:0> put 'students', 'row1', 'info:name', 'Jack'
0 row(s) in 0.2210 seconds
说明:向students表中插入一个单元格Cell,该单元格的行键RowKey值为row1,所属列族名family为info,所属列名column qualifier为name,单元格的数据值为Jack
hbase(main):006:0> put 'students', 'row1', 'scores:Math', '99'
0 row(s) in 0.1050 seconds
说明:向students表中插入一个单元格Cell,该单元格的行键RowKey值为row1,所属列族family为scores,单元格的列名column qualifier为Math,单元格的数据值为99
(6) get命令获取单元格数据值
a) 获取行键为row1的所有单元格数据值
hbase(main):008:0> get 'students', '001'
COLUMN CELL
info:name timestamp=1579401526017, value=Jack
scoresMath timestamp=1579402944774, value=99
2 row(s) in 0.0240 seconds
b)获