当前位置:网站首页>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
边栏推荐
- Thoughts on a small program
- 解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].
- Excel protects worksheets and workbooks from damage
- Set Chrome browser background to eye protection (eye escort / darkreader plug-in)
- Com alibaba. Common methods of fastjson
- Customize the navigation bar at the top of wechat applet (adaptive wechat capsule button, flex layout)
- Unity攝像頭跟隨鼠標旋轉
- Differences between redis and MySQL
- Wechat payment function
- Last day of 2017
猜你喜欢
Details related to fingerprint payment
Practice and exploration of knowledge map visualization technology in meituan
[database] MySQL basic operation (basic operation ~)
AQS源码阅读
Leetcode 1547: minimum cost of cutting sticks
CLion+OpenCV identify ID number - detect ID number
持续集成(CI)/持续交付(CD)如何彻底改变自动化测试
View, modify and delete [database] table
【数据库】MySQL单表查询
Pixel 5 5g unlocking tutorial (including unlocking BL, installing edxposed and root)
随机推荐
[database] MySQL multi table query (I)
[2021] Spatio-Temporal Graph Contrastive Learning
Practice and exploration of knowledge map visualization technology in meituan
Learning Android II from scratch - activity
Leetcode001 -- returns the subscript of the array element whose sum is target
List remove an element
C language: spoof games
MySQL -- execution process and principle of a statement
Leetcode 1547: minimum cost of cutting sticks
Agile practice | agile indicators to improve group predictability
Leetcode009 -- search the target value in the array with binary search
解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].
Other problems encountered in debugging fingerprints
leetcode——启发式搜索
Innovative practice of short video content understanding and generation technology in meituan
MySQL - index
DIY 一个 Excel 版的子网计算器
Special topic of data intensive application system design
Pixel mobile phone brick rescue tutorial
Raspberry pie + opencv + opencv -- face detection ------- environment construction