Hbase--02

3.客户端操作

shell客户端

3.1HBase数据模型概念:

hive表或者mysql表中说描述哪一个数据都是说的哪个库里面的哪张表里面的哪一行数据中的哪一列,才能定位到这个数据

但是在hbase中没有库的概念,说一个数据说的是哪一个名称空间下的那一张表下的哪一个行键的哪一个列族下面的哪一个列对应的是这个数据

namespacedoit

tableuser_info

Rowkey

Column Family1(列族)

Column Family2(列族)

id

Name

age

gender

phoneNum

address

job

code

rowkey_001

1

柳岩

18

88888888

北京....

演员

123

rowkey_002

2

唐嫣

38

66666666

上海....

演员

213

rowkey_003

3

大郎

8

44444444

南京....

销售

312

rowkey_004

4

金莲

33

99999999

东京....

销售

321

...

namespace:hbase中没有数据库的概念 , 是使用namespace来达到数据库分类别管理表的作用

table表,一个表包含多行数据

Row Key (行键):一行数据包含一个唯一标识rowkey、多个column以及对应的值。在HBase中,一张表中所有row都按照rowkey的字典序由小到大排序。

Column Family(列族):在建表的时候指定,不能够随意的删减,一个列族下面可以有多个列(类似于给列进行分组,相同属性的列是一个组,给这个组取个名字叫列族)

Column Qualifier ():列族下面的列,一个列必然是属于某一个列族的行

Cell:单元格,由(rowkey、column family、qualifier、type、timestamp,value)组成的结构,其中type表示Put/Delete操作类型,timestamp代表这个cell的版本。KV结构存储,其中rowkey、column family、qualifier、type以及timestamp是K,value字段对应KV结构的V。

Timestamp(时间戳):时间戳,每个cell在写入HBase的时候都会默认分配一个时间戳作为该cell的版本,用户也可以在写入的时候自带时间戳。HBase支持多版本特性,即同一rowkey、column下可以有多个value存在,这些value使用timestamp作为版本号,版本越大,表示数据越新。

3.2进入客户端命令:

Shell
如果配置了环境变量:在任意地方敲 hbase shell ,如果没有配置环境变量,需要在bin目录下./hbase shell
[root@linux01 conf]# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/app/hadoop-3.1.1/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/app/hbase-2.2.5/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.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.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.2.5, rf76a601273e834267b55c0cda12474590283fd4c, 2020
年 05月 21日 星期四 18:34:40 CST
Took 0.0026 seconds                                                                                                                                        
hbase(main):001:0>   
--代表成功进入了hbase的shell客户端

3.3命令大全

3.3.1通用命令       

status: 查看HBase的状态,例如,服务器的数量。

Shell
hbase(main):001:0> status
1 active master, 0 backup masters, 3 servers, 0 dead, 0.6667 average load
Took 0.3609 seconds 

version: 提供正在使用HBase版本。

Shell
hbase(main):002:0> version
2.2.5, rf76a601273e834267b55c0cda12474590283fd4c, 2020
年 05月 21日 星期四 18:34:40 CST
Took 0.0004 seconds

table_help: 表引用命令提供帮助。

Shell
关于表的一些命令参考
如:
To read the data out, you can scan the table:
  hbase> t.scan
which will read all the rows in table 't'.

whoami: 提供有关用户的信息。

Shell
hbase(main):004:0> whoami
root (auth:SIMPLE)
    groups: root
Took 0.0098 seconds 

3.3.2命名空间相关命令

list_namespace:列出所有的命名空间

Shell
hbase(main):005:0> list_namespace
NAMESPACE                                                                                                                                                                                              
default                                                                                                                                                                                                
hbase                                                                                                                                                                                                  
2 row(s)
Took 0.0403 seconds 

create_namespace:创建一个命名空间

Shell
hbase(main):002:0> create_namespace doit
NameError: undefined local variable or method `doit' for main:Object

hbase(main):003:0> create_namespace 'doit'
Took 0.2648 seconds 


注意哦:名称需要加上引号,不然会报错的

describe_namespace:描述一个命名空间

Shell
hbase(main):004:0> describe_namespace 'doit'
DESCRIPTION                                                                                      
{NAME => 'doit'}                                                                                 
Quota is disabled
Took 0.0710 seconds

drop_namespace:删除一个命名空间

Shell
注意 :只能删除空的命名空间,如果里面有表是删除不了的
hbase(main):005:0> drop_namespace 'doit'
Took 0.2461 seconds 

--
命名空间不为空的话 
hbase(main):035:0> drop_namespace 'doit'

ERROR: org.apache.hadoop.hbase.constraint.ConstraintException: Only empty namespaces can be removed. Namespace doit has 1 tables
        at org.apache.hadoop.hbase.master.procedure.DeleteNamespaceProcedure.prepareDelete(DeleteNamespaceProcedure.java:217)
        at org.ap

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值