hbase 簡介 : 資料格式與運作架構
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 PresentationTRANSCRIPT
HBASE 簡介 : 資料格式與運作架構 Hubert 范姜 -亦思科技1
2
AGENDA Story of HBase Powered by HBase Features of HBase Infrastructure(Responsibility of Nodes) Architecture Take a Look !
2
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
4
FEATURES OF HBASE
Distributed 分散存放
Versioned 每一個 Cell 的資料都可以有多個版本存在
Key/Value Database Column-Oriented?
4
5
FEATURES OF HBASE
Non-Relational 沒有 Primary Key, Foreign Key 存在
Base on Hadoop 架設在 Hadoop 檔案系統之上可以有比較好的效果
"NoSQL" Database 不使用 SQL 存取資料,也不同於 SQL 存取資料庫的模式
Strictly Consistency
5
6
MEMBERS AND CONTRIBUTORS
7
POWERED BY HBASE
7
8
HBASE AT TWITTER Data in Twitter
HDFS Cassandra ( Created by Facebook ) HBase FlockDB ( Created by Twitter )
fault-tolerant graph database
9
Data in Facebook HDFS Cassandra ( Created by Facebook ) HBase
HBASE AT FACEBOOK
10
NOSQL DATABASE的選擇 CAP 理論 CA? AP?
11
RESPONSIBILITY OF NODES
11
12
RESPONSIBILITY OF NODES Client
HBase 的終端使用者,可以透過 HBase Shell 或HBase Client API 連接到 HBase Cluster 。
12
13
Master 分派 Region Server 必須管理的 Region 範圍。 負責 Region Server 的負載平衡( Load Balance )。 偵測故障的 Region Server 並重新分配其上的 Region
由其他 Region Server 接手管理。 HDFS 上的垃圾文件回收。 更新 Table Schema 。
RESPONSIBILITY OF NODES
13
14
RESPONSIBILITY OF NODES Region Server
Region Server 維護 Master 分配的 Region ,處理對所屬 Region 的 IO 請求。
Region Server 負責切分在運行過程中儲存空間超過門檻值的 Region 。
14
15
RESPONSIBILITY OF NODES Zookeeper :以 Google 的 Chubby 為藍本實現的
開源軟體,是一個分散式系統的協調工具。 選擇 Master 。 儲存 Region 的 Mapping 資料。 監控 Region Server 的狀態,即時通知 Region server
的啟動與斷線信息給 Master 。 儲存 HBase 的 Schema ,包括有哪些 Table ,每個
Table 有哪些 Column Family 。
15
16
ZooKeeperZooKeeper
MasterMaster
RESPONSIBILITY OF NODES
Master
Region Server
Region Server
Region Server
Region Server
…….
ZooKeeper
單數個
n個 ,n>=1
16
17
ARCHITECTURE - DATA STRUCTURE
17
18
DATA FORMAT
18
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
20
HBASE DATA FORMAT
20
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
22
REGIONRegion
22
23
MEMSTORE FLUSH Flushing the memstore to disk causes a HFile
23
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
25
hbase 中 hfile 的默認最大值(hbase.hregion.max.filesize) 是 256MB
HFILE
25
26
合併多個 HFile => one Hfile Two Types
Minor Compaction ( 部分文件合併 ) Major Compaction ( 完整文件合併 )
刪除過期 & 已刪除的 data 一個 store 只會有一個 storefile
COMPACTION
26
27
減少 Hfile 的個數 提高 Performance 刪除過期 & 已刪除的 data
COMPACTION的好處
27
28
hbase.hregion.max.filesize = ? File size 比較小時
易發生 Split (Split 會將 region offline) File size 比較大時
Split 發生機會低 Compaction 發生機會高 (io 成本比較高 )
PERFORMANCE NOTES
28
29
Table 中 CF 與 Qualifier 的差別 以讀來思考
All rows => CF ? All rows => Qualifier (one CF) ? CF 的優勢 => 同一個 CF 會存在同一個 Hfile 一次 scan 會取出同一個 rowkey 下整個 CF 的資料 (CF 可指
定 )
PERFORMANCE NOTES
29
30
Table 中 CF 與 Qualifier 的差別 以寫來思考
CF 不宜過多 => 易造成集體 Flush & Compaction(compaction storms)
Reference: http://hbase.apache.org/book/number.of.cfs.html
PERFORMANCE NOTES
30
31
PERFORMANCE OF KEYS
31
32
TAKE A LOOK! HBase Client