12 9 6 3
just a phper
linux网速优化以及遇到的权限问题

关于


在国内,一般的云服务都是按速度来买网络的,比如 1Mb/s 2Mb/s,
经常出现 高峰拥堵,低峰浪费的情况
但在国外,更多是 按月买流量的形式,网速基本是没有上限的
所以提高网络性能极为重要

系统配置调优


通过google学习, 发现linux网络优化的方法有很多,主要分两类:

  1. 通过第三方软件调优(总感觉凉凉的,不提了)
  2. 通过系统参数调优

/etc/sysctl.d/local.conf中追加一下内容:

fs.file-max = 51200

net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.rmem_default = 65536
net.core.wmem_default = 65536
net.core.netdev_max_backlog = 4096
net.core.somaxconn = 4096

net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_congestion_control = hybla

然后执行 sysctl --system,执行完,即可最大限度的使用网络,
然而,我遇到了一下问题 :

权限问题

报错信息 permission denied on key 'net.nf_conntrack_max'

解决方案:

rm -f /sbin/sysctl
ln -s /bin/true /sbin/sysctl

参考


参考源


自由转载-非商用-非衍生-保持署名(创意共享3.0许可证