Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux "too many open files" 解決方案

編輯:Linux 教學

問題成因

系統限制單一程序可開啟的檔案描述符數量。執行 ulimit -a 可查看,預設 open files 通常為 1024。

臨時調整(當前 Shell 有效)

ulimit -n 2048

視需求增大,直到錯誤消失。

永久調整

修改 /etc/security/limits.conf

* - nofile 65535
* - nproc 65535

說明:

  • * 針對所有用戶
  • - 同時設定 soft 與 hard 限制
  • nofile 最大開啟檔案數,nproc 最大程序數
注意:soft limit 不能超過 hard limit;一般用戶只能降低 hard limit,唯有 root 能提高。建議按倍數遞增(1024 → 2048 → 4096…)。

若重新登入仍不生效,追加至 /etc/profile 與 /etc/rc.local

ulimit -SHn 51200

並確認 /etc/profile 現有 ulimit -S -c 0 > /dev/null 2>&1 不衝突。

驗證

重新登入後執行 ulimit -a 確認 open files 已更新。

Copyright © Windows教程網 All Rights Reserved