hbase 數據寫入過程習知

一,客戶端client  

 1,  Htable API 調用put方法發送寫入請求,zookeeper查找系統表.ROOT.定位.mete.表存儲位置,

 2,  到定位的HRS(hregionserver)根據tablename以及rowkey直接定位region的HRS

 3, 定位了region的HRS,接着client 跟 hregionserver通信,處理region寫請求


二,服務端hregionserver

 1, 寫wal(write ahread log)(可以程序設置不寫),wal寫成功接着寫memorystore

 2, memorystore 超出配置 hbase.hregion.memstore.flush.size 的大小時,拷貝副本(副本拷貝時block寫入操作),副本add到flush隊列,等待flush線程進行flush到磁盤

 3,MemorystoreFlusherThread 監控hregionserver 的memorystore 總大小 超出hbase.regionserver.global.memstore.upperLimit/lowerLimit配置時(默認0.4/0.35 * HRegionServer 的 heap 堆內存大小/在hbase-env.sh 的 export HBASE_HEAPSIZE=10240 參數設置),block hregionserver的寫入操作,待flush部分到磁盤,重新wakeup寫入操作,一般hregionserver日誌中出現 

regionserver.MemStoreFlusher: Blocking updates on arch0973,60020,1393482371785: the global memstore size 4.0 G is >= than blocking 4.0 G size,意味着超出。

 4, 對應region下memorystore flush到磁盤的文件storefile數超出hbase.hstore.blockingStoreFiles時則block所有的寫請求進行compaction,以減少storefile數量(可優化配置)

 5, compaction(跟據數據標誌合併,過濾舊版本)所有的storefile得到一個大的storefile,當大的storefile filesize 大於hbase.hregion.max.filesize,region進行split,region拆分,下線,也相應block相應的寫入操作

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章