Hbase:RegionServer

RegionServer:

HRegionServer是RegionServer的实现,负责服务与管理regions。运行在DataNode
HRegionRegionInterface:对外提供了元数据和Region维护方法
    1.Data -- get put delete next 等
    2.Region -- SplitRegion compactRegion等,如Admin的majorCompact方法,这个方法将遍历
                这个表的所有Region,发起major compaction

RegionServer运行的进程如下:

进程名作用
CompactSplitThread检查文件拆分,镜像压缩
MajorCompactionChecker检查major Compaction
MemStoreFlusher定期把内存中的MemStore刷写至StoreFile
logRoller定期检查RegionServer的WAL

 

Coprocessor:

请参看Hbase:coprocessor

Block Cache

BlockCache用于缓存从HDFS读取的数据
类型cache数据方式
LruBlockCacheon-heap
BucketCacheoff-heap

LruBlockCache

LruBlockCache:是LRU缓存,对于scan-resistance和内存中的ColumnFamily有三个优先级别
* 单一访问级别:第一次加载HDFS,优先考虑被清除。scan的block是相比经常使用的block容易被清
           除
* 多次访问级别:当单一访问级别的block被再次访问时,变化多次访问级别。
* 内存访问级别: 被configure在内存中的block. 
              java :HColumnDescription.setInMemory(true);
              hbase:create 't',{NAME=>'f',IN_MEMORY => 'true'}

LruBlockCache使用
    1.对于所有用户表,默认采用LruBlockCache。一个重要的概念 working set size或者WSS,
    2.计算hbase的cache有多少可用内存
        regsionServers数 * heap Size * hfile.block.cache.size * 0.99
        默认情况下 block cache 是 可用heap的 1/4. 
        当block cache达到99%时,开始请除缓存。
        例:
        1 regionServer 1GB head  ==> 默认block cache 1G大小 可用block cache 405MB
        1 * 1  * 0.4 * 0.99 =  405MB
       20 regionServer 8GB head  ==> 默认block cache 1G大小 63.6个可用block cahche
        20 * 8 * 0.4 * 0.99 = 63.36
      100 regionServer 24GB head ==> block cache的1/2 有大约1.16TB block cache
        100 * 24 * 0.4 * 0.99 (这个不知道怎么算的,如果有人知道,请留言)

原文:
The default value for the block cache is 0.4 which represents 40% of the available
heap. The last value (99%) is the default acceptable loading factor in the LRU
cache after which eviction is started. The reason it is included in this equation 
is that it would be unrealistic to say that it is possible to use 100% of the
available memory since this would make the process blocking from the point where 
it loads new blocks. Here are some examples:

One region server with the heap size set to 1 GB and the default block cache size
will have 405 MB of block cache available.

20 region servers with the heap size set to 8 GB and a default block cache size
will have 63.3 of block cache.

100 region servers with the heap size set to 24 GB and a block cache size of 0.5
will have about 1.16 TB of block cache.


Catalog Tables : hbase:meta表,加载在内存中
HFiles Indexes : HFile是格式化的文件,存储在HDFS中。包含多层索引。索引大小受block影响,
                 默认64KB。

KEYS : 键值。被存储的键值的值仅是一半,因此每个值单独与
        键值(row key,family qulifier,timstapm)存储  如 familyColumn:qulifier
        (不知道理解对不不,原文
          The values that are stored are only half the picture, since each 
          value is stored along with its keys (row key, family qualifier, 
          and timestamp). 

Bloom Filters: 存储在LRU。可通过 region server web UI查看大小。
    案例:所有block cache 有40GB,但是你需要处理1TB数据。将引起大量的GC.
    用例一: 全量随机读取模式
    这种情况下,在短时间内,不访问相同的数据2次,因此不能在cache block找数据的概率接近0。设置
    这种表的block缓存,是浪费CPU和内存的,甚至产生大量的GC
    用例二: 表映射
    在MapReduce作业中,把一个表作为输入,每一行只读一次,这种情况也不需要放进block cache。可
    以通过Scan对象关闭缓存。如果需要快速访问,需要把caching打开。如统计row

缓存Meta block(Data 缓存在fscache)
    每一个column family 设置 BLOCKCACHE => 'false' 这个操作关闭data的缓存
 
off-heap block cache
    开启BucketCache
    常用的BucketCache是通过一个管理类,它设置两个缓存层:一个on-heap 通过LruBlockCache,
    另一个BucketCache。默认管理类是CombinedBlockCache。LruBlockCache保存meta blocks
    在on-heap,如 index、BlOOM,BucketCache层保存Data Blocks
    在Hbase-2.0.0前,配置BucketCache接收来自LruBlockCache的Data、index blocks
    java :HColumnDescriptor.setCacheDataInL1(true)
    hbase:creat 't',{NAME => 't',CONFIGURATION => {CACHE_DATA_IN_L1 => 'true'}}
    在Hbase-2.0.0后
    直接读取数据至off-heap中。Data加载至Bucketcache,index、bloom加载至LruBlockCache

Bucketcache有三种存在方式:off-heap、file、mmaped 文件模式
    设置方式:
    hbase.bucketcache.ioengine: 
                                offheap
                                file:PATH_TO_FILE
                                files:PATH_TO_FILE1,PATH_TO_FILE2,PATH_TO_FILE3
                                mmap:PATH_TO_FILE

    hbase.bucketcache.combinedcache.enabled : false 关闭 bucketcache

    Bucketcache配置案例:
    4GB bucketcache 
    1GB on-heap cache
    1、hbase.bucketcache.ioengine
    2、hbase.buchetcache.size > 0  -- 开启combinedBlockCache
    3、如果RegionServer运行配置:HBASE_HEAPSIZE=5g
        在hbase-env.sh HBASE_OFFHEAPSIZE=5g(除我们配置的4g+其他也需要off-heap,
        如DFSClient)
    4、在hbase-site.xml
        <property>
          <name>hbase.bucketcache.ioengine</name>
          <value>offheap</value>
        </property>
       <property>
          <name>hfile.block.cache.size</name>
          <value>0.2</value>
        </property>
        <property>
          <name>hbase.bucketcache.size</name>
          <value>4196,8096</value> -- 0.98以后可以配置多种
        </property>
    5、正常配置LruBlockCache
    6、重新hbase

 Compressed BlockCache默认情况下是关闭
    在hbase-site.xml中配置 hbase.block.data.cachecompressed 为 true

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值