在 CentOS 上提升 SFTP 传输速度,可以从系统参数、SSH/SFTP 配置、网络、磁盘、客户端用法几个层面入手。下面按实用程度给你一套方案。
编辑:
vi /etc/ssh/sshd_config
建议修改/新增:
# 使用更快的加密算法
Ciphers aes128-ctr,aes192-ctr,aes256-ctr
# 启用压缩(带宽小、CPU富余时)
# Compression yes
# 提高吞吐量
TCPKeepAlive yes
重启服务:
systemctl restart sshd
⚠️ 压缩在高速网络下反而可能变慢,建议先测试
编辑:
vi /etc/sysctl.conf
加入:
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 0
生效:
sysctl -p
sftp -C(压缩)sftp -C user@host
lftp(比原生 sftp 快)yum install lftp -y
lftp sftp://user@host
> pget -n 10 file
pget -n 10 表示 10 个并发线程
SFTP 本身不支持多线程,但你可以:
rsync + sshrsync -avz -e ssh /data/ user@host:/backup/
tar czf - /data | ssh user@host "cd /backup && tar xzf -"
iostat -x 1
ping host
mtr host
iperf3 -s # 服务端
iperf3 -c host # 客户端
# CPU
top
# 网络
iftop
# 磁盘
iostat -x 1
如果你愿意,可以告诉我:
我可以给你针对性配置模板。