關於Linux ulimit的設定問題__Linux

來源:互聯網
上載者:User

修改最大值 echo ""fs.file-max=65535" >> /etc/sysctl.conf sysctl -p

1)、使用ulimit -a命令可以查看ulimit設定,使用命令可以直接設定ulimit屬性, 但是如果需要設定永久生效,可以按照如下方式: 
vi /etc/security/limits.conf 
# 添加如下的行 
* soft noproc 11000 
* hard noproc 11000 
* soft nofile 4100 
* hard nofile 4100 
說明:
* 代錶針對所有使用者 
noproc 是代表最大進程數 
nofile 是代表最大檔案開啟數 
2)、讓 SSH 接受 Login 程式的登入,方便在 ssh 用戶端查看 ulimit -a 資源限制: 
a、vi /etc/ssh/sshd_config 把 UserLogin 的值改為 yes,並把 # 注釋去掉 
b、重啟 sshd 服務: /etc/init.d/sshd restart 
3)、修改所有 linux 使用者的環境變數檔案: 
vi /etc/profile 
ulimit -u 10000 
ulimit -n 4096 
ulimit -d unlimited 
ulimit -m unlimited 
ulimit -s unlimited 
ulimit -t unlimited 
ulimit -v unlimited
-------------------------------------
自己一開始修改非root使用者的ulimit -n,報錯:
-bash: ulimit: open files: cannot modify limit: Operation not permitted
用上述的第一步,2中的b,non-root使用者再登陸就可以了。
具體的處理步驟:
vi /etc/security/limits.conf 
# 添加如下的行 
* soft noproc 10241 

* soft nofile 10242 

* hard noproc 10243 
* hard nofile 10244
儲存後,service sshd restart
用non-root登陸,執行:ulimit -n ,結果是: 10242
應該是其中 “ * soft nofile 10242 ”起作用了
但是在同一個session中,如果用limit -n進行了一次設定後,再次進行limit -n進行設定,不能超
過上一次設定的值

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.