文章來源: http://blog.csdn.net/odailidong/article/details/50561257
nproc是操作系統級別對每個用戶創建的進程數的限制,在Linux下運行多線程時,每個線程的實現其實是一個輕量級的進程,對應的術語是:light weight process(LWP)。怎么知道一個用戶創建了多少個進程呢,默認的ps是不顯示全部進程的,需要‘-L' 才能看到所有的進程。
舉例1:查看所有用戶創建的進程數,使用命令:
ps h -Led -o user | sort | uniq -c | sort -n
舉例2:查看hfds用戶創建的進程數,使用命令:
ps -o nlwp,pid,lwp,args -u hdfs | sort -n
何時需要修改這個nproc呢
當日志出現以下情況中的一種時,需要考慮這個nproc:
1. Cannot create GC thread. Out of system resources 2. java.lang.OutOfMemoryError: unable to create new native thread
如何修改:
1.需要先看linux操作系統內核版本,通過uname -a查看內核版本,因為2.6版本的內核默認是在/etc/security/limits.d/90-nproc.conf里的配置會覆蓋/etc/security/limits.conf的配置
[root@hadoop219 ~]# uname -a Linux hadoop219 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
2.修改配置文件
vi /etc/security/limits.d/90-nproc.conf
注釋掉 * soft nproc 1024
3.修改limits.conf文件
vi /etc/security/limits.conf
添加
* soft nproc 655350
4. 在控制台執行(修改這個不需要重啟)
ulimit -u 655350
5.檢查下是否生效,在控制台切到該用戶下
ulimit -u