柚子快報(bào)邀請(qǐng)碼778899分享:sql Hbase--02
3.客戶端操作
shell客戶端
3.1HBase數(shù)據(jù)模型概念:
在hive表或者mysql表中說描述哪一個(gè)數(shù)據(jù)都是說的哪個(gè)庫(kù)里面的哪張表里面的哪一行數(shù)據(jù)中的哪一列,才能定位到這個(gè)數(shù)據(jù) 但是在hbase中沒有庫(kù)的概念,說一個(gè)數(shù)據(jù)說的是哪一個(gè)名稱空間下的那一張表下的哪一個(gè)行鍵的哪一個(gè)列族下面的哪一個(gè)列對(duì)應(yīng)的是這個(gè)數(shù)據(jù)
namespace:doit
table:user_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中沒有數(shù)據(jù)庫(kù)的概念 , 是使用namespace來達(dá)到數(shù)據(jù)庫(kù)分類別管理表的作用
table:表,一個(gè)表包含多行數(shù)據(jù)
Row Key (行鍵):一行數(shù)據(jù)包含一個(gè)唯一標(biāo)識(shí)rowkey、多個(gè)column以及對(duì)應(yīng)的值。在HBase中,一張表中所有row都按照rowkey的字典序由小到大排序。
Column Family(列族):在建表的時(shí)候指定,不能夠隨意的刪減,一個(gè)列族下面可以有多個(gè)列(類似于給列進(jìn)行分組,相同屬性的列是一個(gè)組,給這個(gè)組取個(gè)名字叫列族)
Column Qualifier (列):列族下面的列,一個(gè)列必然是屬于某一個(gè)列族的行
Cell:單元格,由(rowkey、column family、qualifier、type、timestamp,value)組成的結(jié)構(gòu),其中type表示Put/Delete操作類型,timestamp代表這個(gè)cell的版本。KV結(jié)構(gòu)存儲(chǔ),其中rowkey、column family、qualifier、type以及timestamp是K,value字段對(duì)應(yīng)KV結(jié)構(gòu)的V。
Timestamp(時(shí)間戳):時(shí)間戳,每個(gè)cell在寫入HBase的時(shí)候都會(huì)默認(rèn)分配一個(gè)時(shí)間戳作為該cell的版本,用戶也可以在寫入的時(shí)候自帶時(shí)間戳。HBase支持多版本特性,即同一rowkey、column下可以有多個(gè)value存在,這些value使用timestamp作為版本號(hào),版本越大,表示數(shù)據(jù)越新。
3.2進(jìn)入客戶端命令:
Shell如果配置了環(huán)境變量:在任意地方敲 hbase shell ,如果沒有配置環(huán)境變量,需要在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>??? --代表成功進(jìn)入了hbase的shell客戶端
3.3命令大全
3.3.1通用命令???????
status: 查看HBase的狀態(tài),例如,服務(wù)器的數(shù)量。
Shellhbase(main):001:0> status 1 active master, 0 backup masters, 3 servers, 0 dead, 0.6667 average load Took 0.3609 seconds?
version: 提供正在使用HBase版本。
Shellhbase(main):002:0> version 2.2.5, rf76a601273e834267b55c0cda12474590283fd4c, 2020年 05月 21日 星期四 18:34:40 CST Took 0.0004 seconds
table_help: 表引用命令提供幫助。
Shell關(guān)于表的一些命令參考 如: To read the data out, you can scan the table: ? hbase> t.scan which will read all the rows in table 't'.
whoami: 提供有關(guān)用戶的信息。
Shellhbase(main):004:0> whoami root (auth:SIMPLE) ??? groups: root Took 0.0098 seconds?
3.3.2命名空間相關(guān)命令
list_namespace:列出所有的命名空間
Shellhbase(main):005:0> list_namespace NAMESPACE??????????????????????????????????? ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? default????????????????????????????????????????????????????????????????????????????????????????????? ?????????????????????????????????????????????????????????????????????????????????????????????????? hbase??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?????????????????????????????????????????? 2 row(s) Took 0.0403 seconds?
create_namespace:創(chuàng)建一個(gè)命名空間
Shellhbase(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? 注意哦:名稱需要加上引號(hào),不然會(huì)報(bào)錯(cuò)的
describe_namespace:描述一個(gè)命名空間
Shellhbase(main):004:0> describe_namespace 'doit' DESCRIPTION?????????????????????????????????????????????????????????????????????????????????????? {NAME => 'doit'}????????????????????????????????????????????????????????????????????????????????? Quota is disabled Took 0.0710 seconds
drop_namespace:刪除一個(gè)命名空間
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
柚子快報(bào)邀請(qǐng)碼778899分享:sql Hbase--02
文章來源
本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場(chǎng)。
轉(zhuǎn)載請(qǐng)注明,如有侵權(quán),聯(lián)系刪除。