以下是CentOS上优化HBase性能的关键策略,涵盖硬件、系统、配置及应用层面:
vm.swappiness=0
。blockdev --setra 32768 /dev/sda
。ulimit -n 65535
。hbase.regionserver.global.memstore.size
(默认0.4,可调整至0.5-0.6),减少刷写频率。hbase.regionserver.handler.count
(默认10,建议增至20-50),提升并发处理能力。hfile.block.cache.size
(默认0.4,读多写少场景可设为0.6-0.8),提升读取命中率。BucketCache
+LRUBlockCache
组合,减少内存碎片。hbase.hstore.compression=SNAPPY
,降低存储和传输开销。dfs.blocksize=256M
),减少小文件数量。hbase> create 'table', 'cf', {SPLITS => ['10','20','30']}
,避免数据倾斜。MD5(userId)
),防止热点问题。IN_MEMORY
属性。scan.setCaching(500)
增大缓存,减少RPC次数。getList
替代单条Get,降低网络开销。RegionServer
负载均衡:hbase.master.loadbalancer.class=org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer
。-XX:+UseG1GC -XX:MaxGCPauseMillis=200
,减少Full GC停顿。MemStore
使用率、RegionServer负载等指标,及时调整参数。hbase.hregion.bloom.block.type=ROW
,加速随机读过滤。hbase.regionserver.hlog.async=true
,提升写入吞吐量。注意:需根据实际业务场景(如读多写少/写密集)调整参数,建议先在测试环境验证后再应用到生产环境。
参考来源: