学以致用

focus on Python , C++, and some interest in Go and R

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

在使用CentOS做server的时候有时会碰到server拒绝client连接的情况,client会受到connection reset by peer等错误,究其原因应该是server默认的file descriptor为1024,此时已经超过了1024,为安全起见server拒绝服务所导致的。
增加file descriptor的操作如下:
一、临时增加file descriptor
  ulimit -n 4096
二、永久增加file descriptor
  2.1 # vi /etc/sysctl.conf
  2.2 增加 fs.file-max = 100000
  2.3 重启或者执行 # sysctl -p
  2.4 # vi /etc/security/limits.conf
  2.5 增加 *       -       nofile  100000
  2.6 通过ulimit -n来校验file descriptor

参考资料:
  http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/
  http://sdb.open-xchange.com/node/35
  http://thedaneshproject.com/posts/how-to-increase-total-file-descriptors-count-on-linux/
  http://www.centos.org/docs/5/html/CDS/install/8.0/Installation_Guide-Support-Platforms.html
  
  

posted on 2011-11-24 16:34  Jerry.Kwan  阅读(902)  评论(0编辑  收藏  举报