修改内核参数
操作步骤
vi /etc/sysctl.conf
不合适的内核参数,可能导致请求偶发延时、端口监听失败、暴露端口失败、系统异常等情况。基于最佳实践结合ONES业务特点,我们推荐下面的内核参数。
vm.swappiness=0
kernel.sysrq=1
net.ipv4.neigh.default.gc_stale_time=120
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.default.arp_announce=2
net.ipv4.conf.lo.arp_announce=2
net.ipv4.conf.all.arp_announce=2
net.ipv4.tcp_max_tw_buckets=5000
net.ipv4.tcp_syncookies=1
net.ipv4.tcp_max_syn_backlog=1024
net.ipv4.tcp_synack_retries=2
net.ipv4.tcp_slow_start_after_idle=0
net.ipv4.ip_forward=1
net.ipv4.tcp_keepalive_time=600
net.ipv4.tcp_keepalive_intvl=60
net.ipv4.tcp_keepalive_probes=20
net.ipv4.ip_local_reserved_ports=30000-32767
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-arptables=1
net.bridge.bridge-nf-call-ip6tables=1
fs.inotify.max_user_watches=10485760
fs.inotify.max_user_instances=8192
使配置生效
sudo sysctl -p
⚠️ 必须重启服务器!
重启服务器
如果服务器已经安装了 ONES 系统,请使用如下方法重启服务器