CentOS修改ulimit(最大程序數和最大檔案開啟數)
阿新 • • 發佈:2018-12-29
ulimit -n和-u可以檢視linux的最大程序數和最大檔案開啟數。
臨時方法:
為了優化linux效能,可能需要修改這個最大值。臨時修改的話ulimit -n 204800就可以了,重啟後失效。
永久生效的方法:
修改/etc/security/limits.conf檔案
在檔案末尾新增
* soft nofile 204800
* hard nofile 204800
* soft nproc 204800
* hard nproc 204800
* 代表針對所有使用者
noproc 是代表最大程序數
nofile 是代表最大檔案開啟數
網上都是說修改這一個檔案就行,但是我修改後重啟伺服器發現沒更改過來。
後來發現,還需要修改兩個檔案
1、/etc/security/limits.d/90-nproc.conf檔案尾新增
* soft nproc 204800
* hard nproc 204800
2、/etc/security/limits.d/def.conf檔案尾新增
* soft nofile 204800
* hard nofile 204800
這兩個檔案的設定將會覆蓋前面的設定。重啟後生效