---
title: "HBASE遇到的java.lang.OutOfMemoryError: unable to create new native thread解决方法"
author: "primernd"
date: "2016-04-22T10:29:06Z"
tags: []
categories: ["数据库"]
slug: "hbase-java-lang-outofmemoryerror-unable-to-create-new-native-thread"
draft: false
lastmod: "2016-04-22T10:29:06Z"
id: 2293054
url: "https://primernd.iteye.com/blog/2293054"
---

简单分享一下，类似问题的解决方法

刚才在某机器上上xxx用户下压测时遇到这个问题，连xxx都进不去了

说明xxx用户下无法创建跟多的线程了（当然root用户没这个问题）

 

系统能够创建的最大线程数：(MaxProcessMemory - JVMMemory – 系统内存) / (ThreadStackSize) = Number of threads

有两种方式：

          减少xxx下的ThreadStackSize

          增加xxx下的nproc数量

修改

\[lsmpusr@wxlab28bin]$ ulimit -a

core filesize          (blocks, -c) 0

data segsize           (kbytes, -d)unlimited

schedulingpriority            (-e) 0

filesize              (blocks, -f) unlimited

pendingsignals                (-i) 256636

max lockedmemory       (kbytes, -l) 64

max memorysize         (kbytes, -m) unlimited

openfiles                     (-n) 65536

pipesize            (512bytes, -p) 8

POSIX messagequeues     (bytes, -q) 819200

real-timepriority             (-r) 0

stacksize             (kbytes, -s) 10240-----可以减小这个，建议在jvm –xss中减少

cputime              (seconds, -t) unlimited

max userprocesses             (-u) 1024-----可以增加这个到32000

virtualmemory          (kbytes, -v)unlimited

filelocks                     (-x) unlimited

修改/etc/security/limits.conf

*    soft    nofile    65536  
*    hard    nofile    65536  
xxx soft nproc  32000  
xxx hard nproc  32000  
xxx soft stack  1024  
xxx hard stack  1024

 

其中 xxx表示启动hbase的用户,如使用hadoop启动hbase,则配置如下:

hadoop           hard    nproc           32000

hadoop           soft    nproc           32000

hadoop           hard    stack           1024

hadoop           soft    stack           1024