Hbase优化之六


修改noprc nofile

ubuntu

/etc/security/limits.conf

增加

username soft noproc 32000

username hard noproc 32000

username soft nofile 32768

username hard nofile 32768

在/etc/pam.d/common-session加入

session required pam-limits.so

redhat

/etc/security/limits.conf加入相同内容

在/etc/pam.d/system-auth中加入

session required pam-limits.so

重启机生效

jvm参数

避免jvm stop-the world

两种情况导致cms gc算法值过高,碎片导致

第一种情况,启动参数加入-XX:CMSInitiatingOccupancyFraction=n,n的值小一点,60-70,如果80-90,有太多的young generation被放入tenured generation中,导致 full gc 

第二种情况

hbase.hregion.memstore.mslab.enabled=true放入hbase-site.xml


hbase相关参数
zookeeper.session.timeout
指定master多长时间感知region server 宕机
hbase.regionserver.handler.count
regionserver处理请求的线程数
hbase.hregion.max.filesize
regionserver上region占用的最大存储空间,如果大于该值hbase会将其split成小的region,太小拆分过频繁,太大影响性能。
hfile.block.cache.size
指定storefile的block cache占用heap内存的百分比,影响读的性能
hbase.regionserver.global.memstore.upperLimit
如果memstore的总和达到heap的upperlimit将锁住所有更新,flush所有数据。
hbase.regionserver.global.memstore.lowLimit
如果memstore的总和达到heap的lowlimit,将不flush数据,将选择memstore最大的flush
hbase.hstore.blockingStoreFiles
当store中多于blockingstorefiles个hstorefile,将合并hstorefile,并阻塞update,直到hbase.hstore.blockingWaitTime
hbase.hregion.memstore.block.multiplier


如果memstore的总数是hbase.hregion.flush.size的mulitplier倍则flush数据,并block update

java api

hTable = new HTable(config, table);
//2 suggestions from http://ryantwopointoh.blogspot.com/2009/01/performance-of-hbase-importing.html
_hTable.setAutoFlush(false);
_hTable.setWriteBufferSize(1024*1024*12);

hbase预分配region

默认情况下Hbase创建Table会新建一个region。执行批量导入,意味着所有的client会写入这个region,直到这个region足够大,以至于分裂。一个有效的提高批量导入的性能的方式,是预创建空的region。最好稍保守一点,因为过多的region会实实在在的降低性能。下面是一个预创建region的例子。 (注意:这个例子里需要根据应用的key进行调整。):

public static boolean createTable(HBaseAdmin admin, HTableDescriptor table, byte[][] splits)
throws IOException {
try {
admin.createTable( table, splits );
return true;
} catch (TableExist***ception e) {
logger.info("table " + table.getNameAsString() + " already exists");
// the table already exists...
return false; 
}
}

public static byte[][] getHexSplits(String startKey, String endKey, int numRegions) {
byte[][] splits = new byte[numRegions-1][];
BigInteger lowestKey = new BigInteger(startKey, 16);
BigInteger highestKey = new BigInteger(endKey, 16);
BigInteger range = highestKey.subtract(lowestKey);
BigInteger regionIncrement = range.divide(BigInteger.valueOf(numRegions));
lowestKey = lowestKey.add(regionIncrement);
for(int i=0; i < numRegions-1;i++) {
BigInteger key = lowestKey.add(regionIncrement.multiply(BigInteger.valueOf(i)));
byte[] b = String.format("%016x", key).getBytes();
splits[i] = b;
}
return splits;
}
hbase regionserver监控http://regionIp:60030

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值