修改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.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 (TableExistsException 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