colorful

zc qq:1337220912

 

too many files open

在ubuntu上开了服务端,在window上开了2000个连接去连server. 结果提示 too many files open错误:
解决方法是: ulimit -n 4096
{
  个人体会:注意,一定要在同一个terminal 下运行这个命令
   很容易找到这个解决方法,于是我打开了另一个terminal, 输入了这个命令,哈哈,结果当然还是不行,原来ulimit -n 4096只是改变当前terminal的  limit
   Note this has no much relation to system max files (/proc/sys/fs/file-max).
}

网上相关资料
-----------------------------------------------------------------------------------------------

I had similar problem. Quick solution is :

ulimit -n 4096

explanation is as follows - each server connection is a file descriptor. In CentOS, Redhat and Fedora, probably others, file user limit is 1024 - no idea why. It can be easily seen when you type: ulimit -n

Note this has no much relation to system max files (/proc/sys/fs/file-max).

In my case it was problem with Redis, so I did:

ulimit -n 4096 redis-server -c xxxx

in your case instead of redis, you need to start your server.

----------------------------------------------------------------------------------------------------

linux下Too many open files问题

2011-01-21 14:42:13
执行:ulimit -n
应该会显示默认值1024
执行:ulimit -n 8192
但是ulimit直接修改的数字,在系统重启后会重置,所以还要修改:
1、/etc/security/limits.conf,在里面加上:
* soft nofile 8192
* hard nofile 20480
2、/etc/pam.d/login,里面加上:
session required /lib/security/pam_limits.so

----------------------------------------------------------------------------------------------------
ps:这个有好多知识点可以学
分类: AIX


登陆数据库出现错误:ORA-12537: TNS:connection closed
于是登陆操作系统
[root@CCN-BJ-3-578 ~]# su - oracle
su: /bin/bash: Too many open files in system
[root@CCN-BJ-3-578 ~]#
检查报警日志没有发现任何错误。
[root@CCN-BJ-3-578 .ssh]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 1024
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
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 73728
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[root@CCN-BJ-3-578 .ssh]#
查看最大可以打开的文件数量
[root@CCN-BJ-3-578 fs]# cat /proc/sys/fs/file-max
65536
查看各个进程打开的文件数据量
[root@CCN-BJ-3-578 home]# lsof -n |awk '{print $2 " " $3}'|sort|uniq -c |sort -nr|more
  64387 18885 oracle
     56 2669 oracle
     53 2667 oracle
     50 2693 oracle
     。。。
18885 明显异常

[root@CCN-BJ-3-578 ~]# ps -ef|grep 18885
oracle   18885     1  0 Jan24 ?        00:00:19 ./linux
root     10241 10049  0 13:45 pts/2    00:00:00 grep 18885
发现oracle用户在执行一个linux文件
查找该文件
[root@CCN-BJ-3-578 home]# find / -name linux
/u01/app/oracle/product/10.2.0/db_1/jdk/include/linux
/u01/app/oracle/product/10.2.0/db_1/oui/lib/linux
/usr/java/jdk1.5.0_11/sample/jnlp/jreinstaller/build/linux
/usr/java/jdk1.5.0_11/include/linux
/usr/java/jdk1.5.0_11/demo/jvmti/hprof/src/linux
/usr/X11R6/lib/Server/include/linux
/usr/X11R6/lib/Server/modules/linux
/usr/X11R6/lib/Server/modules/drivers/linux
/usr/X11R6/lib/Server/modules/input/linux
/usr/X11R6/lib/modules/linux
/usr/X11R6/lib/modules/drivers/linux
/usr/X11R6/lib/modules/input/linux
/usr/share/terminfo/l/linux
/usr/share/doc/ntp-4.2.0.a.20040617/build/hints/linux
/usr/share/systemtap/runtime/relayfs/linux
/usr/include/linux
/usr/src/kernels/2.6.9-22.EL-hugemem-i686/include/linux
/usr/src/kernels/2.6.9-22.EL-hugemem-i686/include/config/logo/linux
/usr/src/kernels/2.6.9-22.EL-i686/include/linux
/usr/src/kernels/2.6.9-22.EL-i686/include/config/logo/linux
/usr/src/kernels/2.6.9-22.EL-smp-i686/include/linux
/usr/src/kernels/2.6.9-22.EL-smp-i686/include/config/logo/linux
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/linux
/usr/lib/bcc/include/linux
/usr/lib/dietlibc/include/linux
/home/oracle/.ssh/ /linux
由于其它都是root用户的,可以确定是/home/oracle/.ssh/ /linux正在执行
[root@CCN-BJ-3-578 ~]# cd /home/oracle/.ssh/
[root@CCN-BJ-3-578 .ssh]# cd " "
[root@CCN-BJ-3-578  ]# pwd
/home/oracle/.ssh/
[root@CCN-BJ-3-578  ]# ll
总用量 1572
-rwxr-xr-x  1 oracle dba    188  1月 24 22:46 2
-rwxr-xr-x  1 oracle dba    188  1月 24 22:46 3
-rwxr-xr-x  1 oracle dba    188  1月 24 22:46 4
-rwxr-xr-x  1 oracle dba   2467 2005-02-21  auto
-rwxr-xr-x  1 oracle dba    182  1月 24 22:46 born___.seen
-rwxr-xr-x  1 oracle dba    182  1月 24 22:46 born__.seen
-rwxr-xr-x  1 oracle dba     58  1月 24 22:46 born_.seen
-rwxr-xr-x  1 oracle dba 463188 2004-10-17  darwin
-rwxr-xr-x  1 oracle dba 582960  1月 24 22:46 freebsd
-rwxr-xr-x  1 oracle dba     34  1月 24 22:46 LinkEvents
-rwxr-xr-x  1 oracle dba 497561 2005-02-21  linux
-rwxr-xr-x  1 oracle dba      0  1月 25 13:00 mech.levels
-rwxr-xr-x  1 oracle dba      6  1月 24 22:46 mech.pid
-rw-r--r--  1 oracle dba      0  1月 25 13:00 mech.session
-rwxr-xr-x  1 oracle dba   3669  1月 19 13:23 mech.set
drwxr-xr-x  2 oracle dba   4096  1月 24 22:44 randfiles
-rwxr-xr-x  1 oracle dba      0  1月 19 13:10 TiGeR02.seen
-rwxr-xr-x  1 oracle dba      0  1月 19 13:10 TiGeR03.seen
[root@CCN-BJ-3-578  ]#

问题原因找到。


posted on 2012-05-11 14:15 多彩人生 阅读(802) 评论(0)  编辑 收藏 引用 所属分类: ubuntu


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理


导航

统计

常用链接

留言簿(3)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜