2016-09-15 104 views
8

從Ubuntu 14.04切換到16.04後,我一直在使用我們的新redis服務器。使用所有的指南打開的文件限制的配置說要改變在/etc/security/limits.conf以下設置有關ulimit的Ubuntu 16.04 systemd redis問題

* soft nofile 65535 
* hard nofile 65535 
root soft nofile 65535 
root hard nofile 65535 

而且還添加到/etc/pam.d/common-session和/etc/pam.d/common-session-noninteractive

session required pam_limits.so 

我已做了所有這些變化,但Redis的仍開始了4096的文件限制其下生產負荷,我們迅速達到最大連接數。

回答

21

經過多次搜索後,我終於發現systemd的標準限制爲4096,無論您在系統級別設置了什麼,系統級別始終優先。造成這種情況的解決方法是通過編輯/etc/systemd/system.conf和添加更改systemd打開文件限制以下設置

DefaultLimitNOFILE=65536 

似乎有在systemd很多的默認設置,其覆蓋系統因此必須在系統中設置設置

因此,如果任何人使用它們,這些都是我爲運行生產redis的Ubuntu 16.04服務器的最終設置。

編輯/etc/systemd/system.conf(須藤納米/etc/systemd/system.conf),並添加

DefaultLimitNOFILE=65536 

編輯/etc/security/limits.conf文件(須藤納米/等/安全/limits.conf),並添加

* soft nofile 64000 
* hard nofile 64000 
root soft nofile 64000 
root hard nofile 64000 

編輯/etc/pam.d/common-session(須藤納米/etc/pam.d/common-session),並添加

session required pam_limits.so 

編輯/等C/pam.d /共會話非交互(須藤納米/etc/pam.d/common-session-noninteractive),並添加

session required pam_limits.so 

編輯的/etc/rc.local(須藤納米/ etc/rc中。本地),並添加

sysctl -w net.core.somaxconn=65535 

編輯/etc/sysctl.conf(須藤納米/etc/sysctl.conf中),並添加

vm.overcommit_memory = 1 

編輯的/etc/rc.local(須藤納米/等/rc.local)並添加

echo never > /sys/kernel/mm/transparent_hugepage/enabled 
+0

很好的答案! DefaultLimitNOFILE是我失蹤 – redgeoff

+0

感謝Ollie。這解決了我面臨的所有問題。完善。 – user785717