增加CentOS File Descriptors

在使用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
  
  

原文地址:https://www.cnblogs.com/Jerryshome/p/2261947.html