hbase shell 基本操作
启动HBASE
[hadoop@master ~]$hbase shell
2019-01-24 13:53:59,990 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:/home/hadoop/hbase/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
Version 1.4.9, rd625b212e46d01cb17db9ac2e9e927fdb201afa1, Wed Dec 5 11:54:10 PST 2018
hbase(main):001:0>
hbase(main):024:0> whoami
hadoop (auth:SIMPLE)
groups: hadoop
#创建一个User表,并且有一个info列族
create 'User','info'
#查看所有表
hbase(main):028:0> list
TABLE
User
1 row(s) in 0.1620 seconds
=> ["User"]
#查看表详情
hbase(main):036:0> desc 'User'
Table User is ENABLED
User
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_SCOPE => '0'}
1 row(s) in 0.0650 seconds
hbase(main):037:0>
#删除指定的列族
alter 'User', 'delete' => 'info'
#插入数据
put 'user', 'row1', 'info:name', 'xiaoming'
put 'user', 'row2', 'info:age', '18'
put 'user', 'row3', 'info:sex', 'man'
#根据rowKey查询某个记录
get 'user', 'row2'
#查询所有记录
scan 'user'
#扫描前2条
scan 'user', {LIMIT => 2}
#范围查询
scan 'user', {STARTROW => 'row2'}
scan 'user', {STARTROW => 'row2', ENDROW => 'row2'}
#统计表记录数
count 'user'
#删除列
delete 'user', 'row1', 'info:age'
#删除行
deleteall 'user', 'row2'
#删除表中所有数据
truncate 'user'
#禁用表
disable 'user'
#启用表
enable 'user'
#测试表是否存在
exists 'User'
#删除表,删除前,必须先disable
disable 'user'
drop 'user'