Ubuntu 16.04 Systemd Redis与ulimit问题 [英] Ubuntu 16.04 systemd redis issues with ulimit

查看:278
本文介绍了Ubuntu 16.04 Systemd Redis与ulimit问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Ubuntu 14.04切换到16.04后,我的新Redis服务器出现了问题.使用所有指南配置打开文件的限制,请使用以下设置更改/etc/security/limits.conf

I have been having issues with our new redis server after swapping from Ubuntu 14.04 to 16.04. The configuration of the open files limit using all the guides says to change the /etc/security/limits.conf with the following settings

*    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

And also to add to /etc/pam.d/common-session and /etc/pam.d/common-session-noninteractive

session required pam_limits.so

我已经进行了所有这些更改,但是redis仍以文件限制4096启动,在生产负载下,我们很快就达到了最大连接数.

I have made all of these changes but redis is still starting up with a file limit of 4096 which under production load we quickly reach max connections.

推荐答案

经过大量搜索,我最终发现systemd的标准限制为4096,无论您在系统级别设置什么,都将始终优先使用systemd级别.解决方法是通过编辑/etc/systemd/system.conf并添加以下设置来更改systemd打开文件的限制

After much searching I finally found that systemd has a standard limit of 4096 and regardless of what you set at the system level the systemd level will always take precedence. The fix for this is to change the systemd open file limit by editing /etc/systemd/system.conf and adding the following setting

DefaultLimitNOFILE=65536

似乎systemd中有很多默认设置会覆盖系统设置,因此必须在systemd中设置

It seems that there are a lot of default settings in systemd which override the system settings so have to be set in systemd

因此,如果对人有用,那么这些是我对运行生产Redis的Ubuntu 16.04服务器的最终设置.

So if its any use for people these are my final settings for a Ubuntu 16.04 server for running production redis.

编辑/etc/systemd/system.conf(sudo nano/etc/systemd/system.conf)并添加

Edit /etc/systemd/system.conf (sudo nano /etc/systemd/system.conf) and add

DefaultLimitNOFILE=65536

编辑/etc/security/limits.conf(sudo nano/etc/security/limits.conf)并添加

Edit /etc/security/limits.conf (sudo nano /etc/security/limits.conf) and add

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

编辑/etc/pam.d/common-session(sudo nano/etc/pam.d/common-session)并添加

Edit /etc/pam.d/common-session (sudo nano /etc/pam.d/common-session) and add

session required pam_limits.so

编辑/etc/pam.d/common-session-noninteractive(sudo nano/etc/pam.d/common-session-noninteractive)并添加

Edit /etc/pam.d/common-session-noninteractive (sudo nano /etc/pam.d/common-session-noninteractive) and add

session required pam_limits.so

编辑/etc/rc.local(sudo nano/etc/rc.local)并添加

Edit /etc/rc.local (sudo nano /etc/rc.local) and add

sysctl -w net.core.somaxconn=65535

编辑/etc/sysctl.conf(sudo nano/etc/sysctl.conf)并添加

Edit /etc/sysctl.conf (sudo nano /etc/sysctl.conf) and add

vm.overcommit_memory = 1

编辑/etc/rc.local(sudo nano/etc/rc.local)并添加

Edit /etc/rc.local (sudo nano /etc/rc.local) and add

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

这篇关于Ubuntu 16.04 Systemd Redis与ulimit问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆