当前位置:网站首页>HRegionServer的详解
HRegionServer的详解
2022-04-23 04:54:00 【黄佳俊、】
Point 1:
HRegionServer一般和DataNode在同一台机器上运行,实现数据的本地性。
Point 2:
HRegionServer包含多个HRegion,由WAL(HLog)、BlockCache、MemStore、HFile组成。
1.WAL即Write Ahead Log,在早期版本中称为HLog,它是HDFS上的一个文件,如其名字所表示的,所有写操作都会先保证将数据写入这个Log文件后,才会真正更新MemStore,最后写入HFile中。采用这种模式,可以保证HRegionServer宕机后,我们依然可以从该Log文件中读取数据,Replay所有的操作,而不至于数据丢失。这个Log文件会定期Roll出新的文件而删除旧的文件(那些已持久化到HFile中的Log可以删除)。WAL文件存储在/hbase/WALs/${HRegionServer_Name}的目录中(在0.94之前,存储在/hbase/.logs/目录中),一般一个HRegionServer只有一个WAL实例,也就是说一个HRegionServer的所有WAL写都是串行的(就像log4j的日志写也是串行的),这当然会引起性能问题,因而在HBase 1.0之后,通过HBASE-5699实现了多个WAL并行写(MultiWAL),该实现采用HDFS的多个管道写,以单个HRegion为单位。关于WAL可以参考Wikipedia的Write-Ahead Logging。顺便吐槽一句,英文版的维基百科竟然能毫无压力的正常访问了,这是某个GFW的疏忽还是以后的常态?
2.BlockCache是一个读缓存,即“引用局部性”原理(也应用于CPU,分空间局部性和时间局部性,空间局部性是指CPU在某一时刻需要某个数据,那么有很大的概率在一下时刻它需要的数据在其附近;时间局部性是指某个数据在被访问过一次后,它有很大的概率在不久的将来会被再次的访问),将数据预读取到内存中,以提升读的性能。HBase中提供两种BlockCache的实现:默认on-heap LruBlockCache和BucketCache(通常是off-heap)。通常BucketCache的性能要差于LruBlockCache,然而由于GC的影响,LruBlockCache的延迟会变的不稳定,而BucketCache由于是自己管理BlockCache,而不需要GC,因而它的延迟通常比较稳定,这也是有些时候需要选用BucketCache的原因。这篇文章BlockCache101对on-heap和off-heap的BlockCache做了详细的比较。
3.HRegion是一个Table中的一个Region在一个HRegionServer中的表达。一个Table可以有一个或多个Region,他们可以在一个相同的HRegionServer上,也可以分布在不同的HRegionServer上,一个HRegionServer可以有多个HRegion,他们分别属于不同的Table。HRegion由多个Store(HStore)构成,每个HStore对应了一个Table在这个HRegion中的一个Column Family,即每个Column Family就是一个集中的存储单元,因而最好将具有相近IO特性的Column存储在一个Column Family,以实现高效读取(数据局部性原理,可以提高缓存的命中率)。HStore是HBase中存储的核心,它实现了读写HDFS功能,一个HStore由一个MemStore 和0个或多个StoreFile组成。
● MemStore是一个写缓存(In Memory Sorted Buffer),所有数据的写在完成WAL日志写后,会 写入MemStore中,由MemStore根据一定的算法将数据Flush到地层HDFS文件中(HFile),通常每个HRegion中的每个 Column Family有一个自己的MemStore。
● HFile(StoreFile) 用于存储HBase的数据(Cell/KeyValue)。在HFile中的数据是按RowKey、Column Family、Column排序,对相同的Cell(即这三个值都一样),则按timestamp倒序排列。
Point 3:
HBase .94以前的架构
Point 4:HRegionServer写流程
当客户端发起一个Put请求时,首先它从hbase:meta表中查出该Put数据最终需要去的HRegionServer。然后客户端将Put请求发送给相应的HRegionServer,在HRegionServer中它首先会将该Put操作写入WAL日志文件中(Flush到磁盘中)。
写完WAL日志文件后,HRegionServer根据Put中的TableName和RowKey找到对应的HRegion,并根据Column Family找到对应的HStore,并将Put写入到该HStore的MemStore中。此时写成功,并返回通知客户端。
版权声明
本文为[黄佳俊、]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_48419914/article/details/124315635
边栏推荐
- Better way to read configuration files than properties
- Learning Android V from scratch - UI
- Leetcode002 -- inverts the numeric portion of a signed integer
- New terminal play method: script guidance independent of technology stack
- QPushbutton 槽函数被多次触发
- C language: spoof games
- AQS source code reading
- What's the difference between error and exception
- Leetcode001 -- returns the subscript of the array element whose sum is target
- The programmer starts the required application with one click of window bat
猜你喜欢

Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data

持续集成(CI)/持续交付(CD)如何彻底改变自动化测试
![解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].](/img/99/095063b72390adea6250f7b760d78c.png)
解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].
![[database] MySQL basic operation (basic operation ~)](/img/0c/a8d858fa74ffed2a266ca77c783c7f.png)
[database] MySQL basic operation (basic operation ~)

Wine (COM) - basic concept

View analysis of scenic spots in ArcGIS

Sword finger offer: the median in the data stream (priority queue large top heap small top heap leetcode 295)

深度学习笔记 —— 语义分割和数据集

AQS源码阅读

Repair of self calibration SPC failure of Tektronix oscilloscope dpo3054
随机推荐
Getprop property
MySQL time function query
The programmer starts the required application with one click of window bat
Leetcode004 -- Roman numeral to integer
Raspberry pie + opencv + opencv -- face detection ------- environment construction
Spark optimization
Painless upgrade of pixel series
JS détermine si la chaîne de nombres contient des caractères
【数据库】表的查看、修改和删除
What's the difference between error and exception
Gets all dates between two times
简单的拖拽物体到物品栏
Repair of self calibration SPC failure of Tektronix oscilloscope dpo3054
Innovation training (XI) airline ticket crawling company information
View, modify and delete [database] table
AQS source code reading
redis和mysql区别
负载均衡简介
Innovation training (VI) routing
Unity3D 实用技巧 - 理论知识库(一)