【问题标题】:Invalid argument" setting key "net.core.somaxconn"无效参数”设置键“net.core.somaxconn”
【发布时间】:2014-07-14 18:31:39
【问题描述】:

我尝试设置 Linux 内核。编辑 /etc/sysctl.conf 并执行sysctl -p
它显示错误

Invalid argument" setting key "net.core.somaxconn"

Linux 发行版:Ubuntu 12.04.4 LTS、x86_64、3.2.0-60-generic

$ cat /etc/sysctl.conf
net.ipv4.conf.eth0.arp_notify = 1
vm.swappiness = 0
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
fs.file-max = 1048576
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_max_syn_backlog = 409600
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_max_orphans = 262144

我可以将net.core.somaxconn 增加到262144 吗?

【问题讨论】:

    标签: linux networking tcp linux-kernel sysctl


    【解决方案1】:

    我在尝试微调我的 nginx 时遇到了同样的问题。这是为 Ubuntu 内核制作的补丁的问题。

    sock 结构的 sk_max_ack_backlog 字段定义为 unsigned short。

    因此,inet_listen() 中的 backlog 参数 不应超过USHRT_MAXlisten() 系统调用中的 backlog 参数被截断为 somaxconn 值。 因此,somaxconn 的值不应超过 65535 (USHRT_MAX)。

    因此,简而言之,要让您的 net.core.somaxconn 工作,您不应该给予大于 65535 的价值

    net.core.somaxconn = 65535

    这很可悲,但我们必须忍受它,除非您可以重新修补内核: https://lists.ubuntu.com/archives/kernel-team/2013-October/033041.html

    【讨论】:

      猜你喜欢
      • 2016-08-15
      • 2012-08-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-30
      • 2021-12-30
      • 2014-12-24
      • 2017-10-11
      • 2023-02-23
      相关资源
      最近更新 更多