1. 程式人生 > >hbase shell 基本操作

hbase shell 基本操作

column mil memory none his logger trunc tin see

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‘

hbase shell 基本操作