进入hbase

[root@bigdata01 conf]# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/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; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.6, rUnknown, Mon May 29 02:25:32 CDT 2017

查看hbase集群状态

hbase(main):001:0> status
1 active master, 0 backup masters, 3 servers, 0 dead, 1.0000 average load

put用法

put '表名','主键','列族:列名','值'

create用法

create '表名','列族名'

scan用法

查询表

scan '表名'

get用法

查询具体列族

get '表名','主键','列族名:列'

删除表步骤

禁用表

disable '表名'

删除表

drop '表名'

例子

//插入数据
hbase(main):002:0> put 'user' ,'001','info:name','dengzhiqiang'
0 row(s) in 0.2630 seconds

hbase(main):003:0> put 'user','001','info:age',20
0 row(s) in 0.0140 seconds


//扫描数据
hbase(main):005:0> scan 'user'
ROW                         COLUMN+CELL                                                                   
 001                        column=info:age, timestamp=1516449657830, value=20                            
 001                        column=info:name, timestamp=1516449634823, value=dengzhiqiang                 
1 row(s) in 0.0570 seconds
//通过rowkey获取数据
hbase(main):007:0> get 'user','001'
COLUMN                      CELL                                                                          
 info:age                   timestamp=1516449657830, value=20                                             
 info:name                  timestamp=1516449634823, value=dengzhiqiang                                   
2 row(s) in 0.0510 seconds
//查看用户
hbase(main):009:0> whoami
root (auth:SIMPLE)
    groups: root
//列出命名
hbase(main):010:0> list_namespace
NAMESPACE                                                                                                 
default                                                                                                   
hbase                                                                                                     
2 row(s) in 0.0440 seconds
//创建命名空间
hbase(main):012:0> create_namespace 'ns21'
0 row(s) in 0.0440 seconds

hbase(main):013:0> list
TABLE                                                                                                     
user                                                                                                      
1 row(s) in 0.0140 seconds

=> ["user"]
hbase(main):014:0> list_namespace
NAMESPACE                                                                                                 
default                                                                                                   
hbase                                                                                                     
ns21                                                                                                      
3 row(s) in 0.0130 seconds

//删除命名空间
hbase(main):015:0> drop_namespace 'ns21'
0 row(s) in 0.0370 seconds

hbase(main):016:0> list_namespace
NAMESPACE                                                                                                 
default                                                                                                   
hbase                                                                                                     
2 row(s) in 0.0150 seconds

hbase(main):017:0>