hbase 簡介 : 資料格式與運作架構 

32
HBASE 簡簡 : 簡簡簡簡簡簡簡簡簡 Hubert 范范 - 范范范范 1

Upload: amber-trujillo

Post on 01-Jan-2016

186 views

Category:

Documents


3 download

DESCRIPTION

HBase 簡介 : 資料格式與運作架構 . Hubert 范姜 - 亦思科技. Agenda. Story of HBase Powered by HBase Features of HBase Infrastructure(Responsibility of Nodes) Architecture Take a Look !. Story of HBase. 2003 “ The Google File System ” 2004 “ MapReduce: Simplified Data Processing on Large Clusters ” - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: HBase  簡介  :  資料格式與運作架構 

HBASE 簡介 : 資料格式與運作架構 Hubert 范姜 -亦思科技1

Page 2: HBase  簡介  :  資料格式與運作架構 

2

AGENDA Story of HBase Powered by HBase Features of HBase Infrastructure(Responsibility of Nodes) Architecture Take a Look !

2

Page 3: HBase  簡介  :  資料格式與運作架構 

3

STORY OF HBASE 2003 “The Google File System” 2004 “

MapReduce: Simplified Data Processing on Large Clusters”

2006 “Bigtable: A Distributed Storage System for Structured Data”

3

Page 4: HBase  簡介  :  資料格式與運作架構 

4

FEATURES OF HBASE

Distributed 分散存放

Versioned 每一個 Cell 的資料都可以有多個版本存在

Key/Value Database Column-Oriented?

4

Page 5: HBase  簡介  :  資料格式與運作架構 

5

FEATURES OF HBASE

Non-Relational 沒有 Primary Key, Foreign Key 存在

Base on Hadoop 架設在 Hadoop 檔案系統之上可以有比較好的效果

"NoSQL" Database 不使用 SQL 存取資料,也不同於 SQL 存取資料庫的模式

Strictly Consistency

5

Page 6: HBase  簡介  :  資料格式與運作架構 

6

MEMBERS AND CONTRIBUTORS

Page 7: HBase  簡介  :  資料格式與運作架構 

7

POWERED BY HBASE

7

Page 8: HBase  簡介  :  資料格式與運作架構 

8

HBASE AT TWITTER Data in Twitter

HDFS Cassandra ( Created by Facebook ) HBase FlockDB ( Created by Twitter )

fault-tolerant graph database

Page 9: HBase  簡介  :  資料格式與運作架構 

9

Data in Facebook HDFS Cassandra ( Created by Facebook ) HBase

HBASE AT FACEBOOK

Page 10: HBase  簡介  :  資料格式與運作架構 

10

NOSQL DATABASE的選擇 CAP 理論 CA? AP?

Page 11: HBase  簡介  :  資料格式與運作架構 

11

RESPONSIBILITY OF NODES

11

Page 12: HBase  簡介  :  資料格式與運作架構 

12

RESPONSIBILITY OF NODES Client

HBase 的終端使用者,可以透過 HBase Shell 或HBase Client API 連接到 HBase Cluster 。

12

Page 13: HBase  簡介  :  資料格式與運作架構 

13

Master 分派 Region Server 必須管理的 Region 範圍。 負責 Region Server 的負載平衡( Load Balance )。 偵測故障的 Region Server 並重新分配其上的 Region

由其他 Region Server 接手管理。 HDFS 上的垃圾文件回收。 更新 Table Schema 。

RESPONSIBILITY OF NODES

13

Page 14: HBase  簡介  :  資料格式與運作架構 

14

RESPONSIBILITY OF NODES Region Server

Region Server 維護 Master 分配的 Region ,處理對所屬 Region 的 IO 請求。

Region Server 負責切分在運行過程中儲存空間超過門檻值的 Region 。

14

Page 15: HBase  簡介  :  資料格式與運作架構 

15

RESPONSIBILITY OF NODES Zookeeper :以 Google 的 Chubby 為藍本實現的

開源軟體,是一個分散式系統的協調工具。 選擇 Master 。 儲存 Region 的 Mapping 資料。 監控 Region Server 的狀態,即時通知 Region server

的啟動與斷線信息給 Master 。 儲存 HBase 的 Schema ,包括有哪些 Table ,每個

Table 有哪些 Column Family 。

15

Page 16: HBase  簡介  :  資料格式與運作架構 

16

ZooKeeperZooKeeper

MasterMaster

RESPONSIBILITY OF NODES

Master

Region Server

Region Server

Region Server

Region Server

…….

ZooKeeper

單數個

n個 ,n>=1

16

Page 17: HBase  簡介  :  資料格式與運作架構 

17

ARCHITECTURE - DATA STRUCTURE

17

Page 18: HBase  簡介  :  資料格式與運作架構 

18

DATA FORMAT

18

Page 19: HBase  簡介  :  資料格式與運作架構 

19

RDB DATA FORMAT

Lot_ID Date Facility Operator

A000001.00 2012/06/15 BSET Andy

A000002.00 2012/06/15 DSET Mike

A000003.00 2012/06/15 BSET Hubert

19

Page 20: HBase  簡介  :  資料格式與運作架構 

20

HBASE DATA FORMAT

20

Page 21: HBase  簡介  :  資料格式與運作架構 

21

Table (HBase Table) Region (Regions for the Table)

Store (Store per ColumnFamily for each Region for the table) MemStore ( MemStore for each Store for each

Region for the table) StoreFile (StoreFiles for each Store for each Region

for the table) Block (Blocks within a StoreFile within a Store for each Region

for the table)

REGION

21

Page 22: HBase  簡介  :  資料格式與運作架構 

22

REGIONRegion

22

Page 23: HBase  簡介  :  資料格式與運作架構 

23

MEMSTORE FLUSH Flushing the memstore to disk causes a HFile

23

Page 24: HBase  簡介  :  資料格式與運作架構 

24

HTable

Region Region Region Region Region Region

Store

Store File

HFileStore File

HFileStore File

HFileStore File

HFile

Memstore

Store

Store File

HFileStore File

HFileStore File

HFileStore File

HFile

Memstore

Split/CompactionBlock

BlockBlock

Block

BlockBlock

BlockBlock

一個 CF 一個Store

一次 flush 產生一個 HFile

24

Page 25: HBase  簡介  :  資料格式與運作架構 

25

hbase 中 hfile 的默認最大值(hbase.hregion.max.filesize) 是 256MB

HFILE

25

Page 26: HBase  簡介  :  資料格式與運作架構 

26

合併多個 HFile => one Hfile Two Types

Minor Compaction ( 部分文件合併 ) Major Compaction ( 完整文件合併 )

刪除過期 & 已刪除的 data 一個 store 只會有一個 storefile

COMPACTION

26

Page 27: HBase  簡介  :  資料格式與運作架構 

27

減少 Hfile 的個數 提高 Performance 刪除過期 & 已刪除的 data

COMPACTION的好處

27

Page 28: HBase  簡介  :  資料格式與運作架構 

28

hbase.hregion.max.filesize = ? File size 比較小時

易發生 Split (Split 會將 region offline) File size 比較大時

Split 發生機會低 Compaction 發生機會高 (io 成本比較高 )

PERFORMANCE NOTES

28

Page 29: HBase  簡介  :  資料格式與運作架構 

29

Table 中 CF 與 Qualifier 的差別 以讀來思考

All rows => CF ? All rows => Qualifier (one CF) ? CF 的優勢 => 同一個 CF 會存在同一個 Hfile 一次 scan 會取出同一個 rowkey 下整個 CF 的資料 (CF 可指

定 )

PERFORMANCE NOTES

29

Page 30: HBase  簡介  :  資料格式與運作架構 

30

Table 中 CF 與 Qualifier 的差別 以寫來思考

CF 不宜過多 => 易造成集體 Flush & Compaction(compaction storms)

Reference: http://hbase.apache.org/book/number.of.cfs.html 

PERFORMANCE NOTES

30

Page 31: HBase  簡介  :  資料格式與運作架構 

31

PERFORMANCE OF KEYS

31

Page 32: HBase  簡介  :  資料格式與運作架構 

32

TAKE A LOOK! HBase Client