How-to: resolve " java.lang.OutOfMemoryError: unable to create new native thread" for hbase thrift

Error:
Caused by: java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:714)
        at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:949)
        at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1360)
        at org.apache.hadoop.hbase.client.ResultBoundedCompletionService.submit(ResultBoundedCompletionService.java:142)
        at org.apache.hadoop.hbase.client.ScannerCallableWithReplicas.addCallsForCurrentReplica(ScannerCallableWithReplicas.java:276)
        at org.apache.hadoop.hbase.client.ScannerCallableWithReplicas.call(ScannerCallableWithReplicas.java:165)
        at org.apache.hadoop.hbase.client.ScannerCallableWithReplicas.call(ScannerCallableWithReplicas.java:57)
        at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithoutRetries(RpcRetryingCaller.java:200)

Resolution:
  • Add following in /etc/security/limits.conf to set the 100000 as the maximum number of processs in your system for user hadoop. 
    hadoop soft nproc 100000
    hadoop hard nproc 100000
    Reference: http://ww2.cs.fsu.edu/~czhang/errors.html
  • Configure hbase-env.sh(Optional: based on your use case):
    export HBASE_HEAPSIZE=8000(original is 20G)
    export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS -Xmx8g -Xms8g -Xmn4g -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=70 -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:$HBASE_LOG_DIR/gc--hbase.log"

  • Restart hbase and thrift(Without this, ulimit settings will not take effort)
    stop-hbase.sh
    start-hbase.sh
    hbase-daemon.sh stop thrift
    hbase-daemon.sh start thrift

你可能感兴趣的:(基础架构,hadoop,hbase,thrift)