如何增加 memcached 服务的最大打开文件数

tar*_*art 2 pam ulimit

使用 ulimit -ni 可以设置基于每个 shell 的最大打开文件限制

为了使这个值持久化,我可以在 /etc/security/limits.conf 中编辑它并重新启动 ubuntu 12.10 框,这是配置

*               soft    nofile          10240
*               hard    nofile          10240
root            soft    nofile          10240
root            hard    nofile          10240
Run Code Online (Sandbox Code Playgroud)

但上述值并未应用于 memcached 服务,如何将“最大打开文件数 10240”设置为 memcached 服务。

即使在设置limits.conf之后,memcached仍然显示

xx@xx:~$ ps aux|grep mem
mysql     2044  0.0  0.0 327436  1260 ?        Sl   17:09   0:00 /usr/bin/memcached -vv -m 256 -p 11211 -u mysql -l 0.0.0.0

xx@xx:~$ cat /proc/2044/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             30402                30402                processes
Max open files            1024                 1024                 files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       30402                30402                signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us
Run Code Online (Sandbox Code Playgroud)

请让我知道如何为 memcached 服务增加“最大打开文件数”

Joh*_*ley 6

在 memcache 配置中使用以下方法设置最大打开连接数:

-c 10240
Run Code Online (Sandbox Code Playgroud)

您可以通过listen_disabled_num在运行时检查来检查这是否真的有必要:

echo stats | nc localhost 11211
Run Code Online (Sandbox Code Playgroud)

如果最大连接数是个问题,您应该会看到该值高于 0。