错误1:

bash: fork: retry: Resource temporarily unavailable

解决方法:

[root@localhost ~]# vim /etc/security/limits.conf
*                soft    nofile          65535
*                hard    nofile          65535
www                soft    nproc           500
www                hard    nproc           500
注:退出secureCRT,重新登录即可

错误2:

-bash: redirection error: cannot duplicate fd: Invalid argument

解决方法:

[root@localhost ~]# vim /etc/security/limits.conf
*                soft    nofile          65535
*                hard    nofile          65535
www                soft    nofile          6000
www                hard    nofile          6000
注:退出secureCRT,重新登录即可

错误3:

su: cannot set user id: Resource temporarily unavailable

解决方法:

[root@localhost ~]# cat /proc/sys/fs/file-max      #<--指定了系统范围内所有进程可以打开的文件句柄的数量限制
6815744
[root@localhost ~]# cat /proc/sys/fs/file-nr       #<--整个系统目前使用的文件句柄数量,其中第一个值已经分配的文件句柄,第二值为已经分配但没有使用的文件句柄,在kernel2.6版本第二项值总为0,表示无一浪费都已经被使用,第三个值是句柄总数
22528   0       6815744
[root@localhost ~]# vim /etc/security/limits.conf
*                soft    nofile          65535
*                hard    nofile          65535
www                soft    nofile          6000
www                hard     nofile          6000
www                soft    nproc           500
www                hard    nproc           500
[root@localhost ~]# cd /etc/security/limits.d
[root@localhost ~]# cat 90-nproc.conf            #<--用于限制用户打开进程数
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*           soft    nproc     1024
root         soft    nproc     unlimited
[root@localhost ~]# vim 90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*           soft    nproc     65535
root         soft    nproc     unlimited
注:如果 90-nproc.conf与limits.conf存在相同条目的配置那么90-nproc覆盖 limits.conf 的配置
  如果 90-nproc.conf用的是*没有指定用户而 limits.conf指定用户那么90-nproc的限制不生效
  90-nproc.conf 除了限制nproc其他资源一样可以限制,生效原则与nproc一样
  在/etc/security/limit.d目录下你还可以创建其他任意名字的.conf文件,这些文件中首字母ACSII大的覆盖首字母ASCII小的(首字母一样大的比较第二个字母以此类推)

ulimit -a 命令

[root@localhost ~]# ulimit -a
core file size          (blocks, -c) 0                     #<--程序崩溃时产生的内存镜像文件大小,单位:kb,0表示不允许生成
data seg size           (kbytes, -d) unlimited                #<--进程的数据段可以任意大,单位:kb
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited                  #<--可打开文件的大小,单位:kb
pending signals                 (-i) 7685                    #<--待处理的信号
max locked memory         (kbytes, -l) 64                         #<--最大锁内存
max memory size         (kbytes, -m) unlimited                   #<--一个任务常驻物理内存的最大值
open files                      (-n) 65535                 #<--可打开文件数,单位:个
pipe size            (512 bytes, -p) 8                       #<--管道最大空间为4096字节
POSIX message queues     (bytes, -q) 819200                      #<--POSIX的消息队列的最大值为819200字节
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240                   #<--堆栈段大小
cpu time               (seconds, -t) unlimited                 #<--进程使用的CPU时间,单位:分钟
max user processes              (-u) 7685                    #<--当前用户同时打开的进程(包括线程)的最大个数                        
virtual memory          (kbytes, -v) unlimited                   #<--没有限制进程的最大地址空间
file locks                      (-x) unlimited              #<--所能锁住的文件最大个数