SSserver的加速优化配置(三)
in Tutorial with 1 comment
SSserver的加速优化配置(三)
in Tutorial with 1 comment

完成《新购置的VPS如何搭建SSserver(一)》和《安装SSserver和配置(二)》的配置工作之后,最重要的是优化SSserver

这里优化工作分为两部分,第一部分是常规的内核优化,谷歌搜索上有很多相关教程,可以算是一份备忘,第二部分是安装 net-speeder,这部分可做可不做

优化

逐条执行下面命令

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

然后修改配置文件limits.conf,输入下面命令

vi /etc/security/limits.conf

打开后在最后未处添加

* soft nofile 51200
* hard nofile 51200

然后停止shadowsocks运行,设置参数

ssserver -c /etc/shadowsocks.json -d stop
ulimit -n 51200

修改配置文件sysctl.conf,输入下面命令

vi /etc/sysctl.conf

打开后在最后未处添加

fs.file-max = 51200

net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.netdev_max_backlog = 250000
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 = 8192
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 -p

最后rebootvps就完成了。

安装net-speeder(选做)

安装net-speeder的步骤和过程参照了vobe.io和cmsky.com

过程如下

CentOS安装,逐条执行下面命令

wget --no-check-certificate https://gist.github.com/LazyZhu/dc3f2f84c336a08fd6a5/raw/d8aa4bcf955409e28a262ccf52921a65fe49da99/net_speeder_lazyinstall.sh
./net_speeder_lazyinstall.sh

安装完毕后再输入下面命令

nohup /usr/local/net_speeder/net_speeder venet0 "ip" >/dev/null 2>&1 &

加入开机启动

nohup /var/net_speeder eth0 "ip";echo "nohup /var/net_speeder eth0 "ip" >/dev/null 2>&1 &" >> /etc/rc.local

输入下面命令查看是否添加成功,,成功就退出

vi /etc/rc.local

设置时区,输入下面命令

echo "Asia/Shanghai" >/etc/timezone

设置定时开关,输入下面命令

echo '0 13 * * * root nohup /root/net_speeder venet0 "ip" >/dev/null 2>&1 &' >>/etc/crontab
echo "0 2 * * * root killall net_speeder" >>/etc/crontab
/etc/init.d/cron restart

Ok,至此优化工作已完成···

系列教程如下:

辅助教程如下:

Responses
  1. 博主……你都把/bin/true软链到sysctl和modprobe了,无条件exit 0,当然怎么做也不会报错啊

    Reply