免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 8943 | 回复: 19
打印 上一主题 下一主题

最大进程限制问题(在线等待) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-11-14 21:58 |只看该作者 |倒序浏览
LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch

Linux test 2.6.18-128.el5PAE #1 SMP Wed Dec 17 12:02:33 EST 2008 i686 i686 i386 GNU/Linux

[root@test test]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 77824
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 77824
virtual memory          (kbytes, -v) unlimited

LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch

Linux test 2.6.18-128.el5PAE #1 SMP Wed Dec 17 12:02:33 EST 2008 i686 i686 i386 GNU/Linux

[root@test test]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 77824
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 77824
virtual memory          (kbytes, -v) unlimited

top 内容:
top - 16:53:18 up 440 days, 23:37,  4 users,  load average: 0.19, 0.24, 0.23
Tasks: 8239 total,   1 running, 8237 sleeping,   0 stopped,   1 zombie
Cpu(s):  0.3%us,  1.3%sy,  0.0%ni, 98.3%id,  0.0%wa,  0.0%hi,  0.1%si,  0.0%st
Mem:   4140316k total,  3306248k used,   834068k free,   149400k buffers
Swap:  5406712k total,        4k used,  5406708k free,   613672k cached


问题:
我想开10000个进程,但是打开8239 个进程的时候,就再也不能创建进程了?
提示"fork: 资源暂时不可用"
max user processes 是77824啊? 还没到最大就不能创建了,这是什么问题,
请高手帮忙指点一下。谢谢!!

论坛徽章:
0
2 [报告]
发表于 2011-11-14 22:13 |只看该作者
回复 1# nflx


     nproc - max number of processes

论坛徽章:
0
3 [报告]
发表于 2011-11-14 22:16 |只看该作者
回复 1# nflx


    /etc/security/limits.conf  里添加试试

论坛徽章:
0
4 [报告]
发表于 2011-11-14 22:20 |只看该作者
本帖最后由 nflx 于 2011-11-14 22:26 编辑

楼主的意思是,要对最大进程数作出有效限制吗?
我的 /etc/security/limits.conf  为空。
我在root 用户下,开启进程也只能开启 8239个进程。 好象与limits.conf无关吧

论坛徽章:
0
5 [报告]
发表于 2011-11-14 22:57 |只看该作者
回复 4# nflx


    /etc/security/limits.conf    里面是空的?     这文件属于pam包里的啊 里面默认有内容的

类似下面

#@student        hard    nproc           20
#@faculty        soft    nproc           20

...........................等

论坛徽章:
0
6 [报告]
发表于 2011-11-14 23:09 |只看该作者
本帖最后由 nflx 于 2011-11-14 23:17 编辑

我是说limits.conf 全被 '#' 号注掉了。没有作用。
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - an user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open files
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to
#        - rtprio - max realtime priority
#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4


# End of file

论坛徽章:
0
7 [报告]
发表于 2011-11-14 23:11 |只看该作者
回复 6# nflx


    我的意思就是让你修改里面的参数试试

论坛徽章:
0
8 [报告]
发表于 2011-11-14 23:20 |只看该作者
本帖最后由 nflx 于 2011-11-14 23:28 编辑

明白,我修改了测试,故障依旧,如果我将nproc  改成 5000,  就创建不了5000个进程,如果改成20000,
但进程还是到8000多个的时候,不可再创那建了,提示 fork 资源不可用。

可能与测试的程序有关系,把程序里面的线程部分功能关掉,开15000个进程都没问题, 但我还是不明白
是不是线程的原因。

论坛徽章:
0
9 [报告]
发表于 2011-11-15 00:07 |只看该作者
回复 8# nflx

你的程序每个进程启动了7个线程,是不是?
linux的线程是使用与普通进程具有相同内核调度视图的轻量级进程实现的,这些线程也拥有独立的进程id。

所以根据8楼的描述,当你的测试程序开启线程功能时,每个进程开启了7个线程, 当启动了8000多进程时,PID耗尽了。

论坛徽章:
0
10 [报告]
发表于 2011-11-15 08:29 |只看该作者
本帖最后由 nflx 于 2011-11-15 14:33 编辑

谢谢大家的回复。
LINUX下的线程也占用进程ID,但是我一个进程里面只开了三个线程(pthread_create)创建, 哪就是说每打开一个这样的程序,要占用四个独立进程ID吧?  但我的max user processes              (-u) 77824   
4*8000 也才三万多个,还没达到上限吧。
还有,我在程序里面,减少线程数,比如只开一个线程, 就至少能打开15000个进程。
还有没有更好的理由?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP