1、Apache HBase
- Hbase簡介
1.1、HBase邏輯結構

1.2、HBase物理存盤結構

1)Name Space:命名空間,類似于關系型資料庫的database概念,每個命名空間下有多個表,HBase有兩個自帶的命名空間,分別是hbase和default,hbase中存放的是HBase內置的表,default表是用戶默認使用的命名空間;
2)Table:類似于關系型資料庫的表概念,不同的是,HBase定義表時只需要宣告列族即可,不需要宣告具體的列,這意味著,往HBase寫入資料時,欄位可以動態、按需指定,因此,和關系型資料庫相比,HBase能夠輕松應對欄位變更的場景;
3)Row:HBase表中的每行資料都由一個RowKey和多個Column(列)組成,資料是按照RowKey的字典順序存盤的,并且查詢資料時只能根據RowKey進行檢索,所以RowKey的設計十分重要;
4)Column:HBase中的每個列都由Column Family(列族)和Column Qualifier(列限定符)進行限定,例如info:name,info:age,建表時,只需指明列族,而列限定符無需預先定義;
5)Time Stamp:用于標識資料的不同版本(version),每條資料寫入時,系統會自動為其加上該欄位,其值為寫入HBase的時間;
6)Cell:由{rowkey, column Family, column Qualifier, time Stamp} 唯一確定的單元,cell中的資料全部是位元組碼形式存貯;
1.3、HBase基本架構

1)Region Server:Region Server為 Region的管理者,其實作類為HRegionServe;
2)Master:Master是所有Region Server的管理者,其實作類為HMaster,分配regions到每個RegionServer,監控每個RegionServer的狀態,負載均衡和故障轉移;
3)Zookeeper:HBase通過Zookeeper來做master的高可用、RegionServer的監控、元資料的入口以及集群配置的維護等作業;
4)HDFS:HDFS為Hbase提供最終的底層資料存盤服務,同時為HBase提供高可用的支持;
2、HBase安裝和使用
- HBase四種部署模式和基本操作
- Hadoop2.x與Hadoop3.x的默認埠變化
2022-02-03 17:21:01,104 ERROR [Thread-15] master.HMaster: Failed to become active master
java.net.ConnectException: Call From hadoop102/192.168.2.34 to hadoop102:8020 failed on connection exception: java.net.ConnectException: 拒絕連接; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused
The fs.defaultFS makes HDFS a file abstraction over a cluster, so that its root is not the same as the local system’s. You need to change the value in order to create the distributed file system.
注意:hadoop 3.X的HDFS檔案系統訪問埠號為9820,而不是8020
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://hadoop102:9820/hbase</value>
</property>
</configuration>
2.1、HBase的啟動與停止
# 單點啟動
[atguigu@hadoop102 hbase-2.0.5]$ bin/hbase-daemon.sh start master
[atguigu@hadoop102 hbase-2.0.5]$ bin/hbase-daemon.sh start regionserver
# 群起
[atguigu@hadoop102 hbase-2.0.5]$ bin/start-hbase.sh
[atguigu@hadoop102 hbase-2.0.5]$ bin/stop-hbase.sh
2.2、namespace的操作
# 進入HBase的shell
[atguigu@hadoop102 ~]$ hbase shell
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.0.5, rUnknown, Thu Jun 18 15:10:52 CST 2020
Took 0.0024 seconds
# 查看命名空間
hbase(main):025:0> list_namespace
NAMESPACE
default
hbase
2 row(s)
Took 0.0272 seconds
# 創建明明空間
hbase(main):031:0> create_namespace 'test'
Took 0.3161 seconds
# 查看命名空間
hbase(main):032:0> describe_namespace 'test'
DESCRIPTION
{NAME => 'test'}
Took 0.0077 seconds
=> 1
# 修改命名空間屬性
hbase(main):033:0> alter_namespace 'test',{METHOD => 'set','author' => 'jieky'}
Took 0.2959 seconds
hbase(main):034:0> describe_namespace 'test'
DESCRIPTION
{NAME => 'test', author => 'jieky'}
Took 0.0097 seconds
=> 1
hbase(main):035:0> alter_namespace 'test',{METHOD => 'set','like' => 'study'}
Took 0.2554 seconds
# 清楚命名空間屬性
hbase(main):039:0> alter_namespace 'test',{METHOD => 'unset',NAME => 'like'}
Took 0.2505 seconds
# 洗掉命名空間
hbase(main):041:0> drop_namespace 'test'
Took 0.3004 seconds
2.3、HBase Shell表操作
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/423358.html
標籤:其他
上一篇:【FXCG】今日市場分析
