扶梯优化手册

· BBR

1、使用 uname -r 来确认内核是否大于4.9;

2、使用 lsmod | grep bbr 来确认是否有bbr模块,如有,跳到3;

没有发现bbr模块,执行:

sudo modprobe tcp_bbr
echo “tcp_bbr” | sudo tee –append /etc/modules-load.d/modules.conf

3、执行:

echo "net.core.default_qdisc=fq" | sudo tee --append /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" | sudo tee --append /etc/sysctl.conf

4、保存生效:

sudo sysctl -p

· 系统优化

1、在 /etc/sysctl.conf 最后加入:

net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_fastopen_blackhole_timeout_sec = 0
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_slow_start_after_idle = 0
fs.file-max = 1024000
net.ipv4.tcp_retries2 = 8
fs.inotify.max_user_instances = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.core.somaxconn = 32768
net.core.netdev_max_backlog = 32768
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_max_orphans = 32768

2、保存生效:

sudo sysctl -p

3、在 /etc/security/limits.conf 最后加入:

* soft nofile 1024000
* soft nproc 1024000
* hard nofile 1024000
* hard nproc 1024000
root soft nofile 1024000
root soft nproc 1024000
root hard nofile 1024000
root hard nproc 1024000
nobody soft nofile 1024000
nobody soft nproc 1024000
nobody hard nofile 1024000
nobody hard nproc 1024000

4、重启生效