自用Debian系,网络优化脚本,开启bbr,增大 open files 参数等。
使用方法,新建一个 .bbr 文件,添加下面内容,然后运行 bash .bbr 即可。注意,此脚本运行后,服务器会重启一次。
cd /usr/src && wget -N --no-check-certificate "https://www.kkpig.cn/bbr/.bbr" && chmod +x .bbr && ./.bbr
删掉 /etc/sysctl.conf 里的文件就恢复了。
#!/bin/sh
# Issues https://www.kkpig.cn
if [[ $EUID -ne 0 ]]; then
clear
echo "Error: This script must be run as root!"
exit 1
fi
timedatectl set-timezone Asia/Shanghai
cat >/etc/security/limits.conf<<EOF
* soft nproc 655360
* hard nproc 655360
* soft nofile 655360
* hard nofile 655360
root soft nproc 655360
root hard nproc 655360
root soft nofile 655360
root hard nofile 655360
bro soft nproc 655360
bro hard nproc 655360
bro soft nofile 655360
bro hard nofile 655360
EOF
echo "session required pam_limits.so" >> /etc/pam.d/common-session
echo "session required pam_limits.so" >> /etc/pam.d/common-session-noninteractive
echo "DefaultLimitNOFILE=655360" >> /etc/systemd/system.conf
cat >/etc/sysctl.conf<<EOF
fs.file-max = 655360
net.ipv4.tcp_congestion_control = bbr
net.core.default_qdisc = fq
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_rmem = 8192 262144 536870912
net.ipv4.tcp_wmem = 4096 16384 536870912
net.ipv4.tcp_adv_win_scale = -2
net.ipv4.tcp_notsent_lowat = 131072
EOF
sleep 3 && reboot >/dev/null 2>&1
评论 (0)