下面按**“先测速,再优化”**的思路,给你一套在 CentOS 上搭建/优化 FTP(通常是 vsftpd)服务器的实用方案。
CentOS 常用的是 vsftpd:
rpm -qa | grep vsftpd
在服务器本机测试磁盘 IO:
dd if=/dev/zero of=/tmp/test bs=1M count=1000 oflag=direct
看写入速度(MB/s)
ftp ftp://user:pass@server_ip
ftp> put bigfile.iso
ftp> get bigfile.iso
或用 lftp(推荐,支持多线程):
lftp -u user,pass ftp://server_ip
lftp> pget -n 10 bigfile.iso
iperf3 -s # 服务端
iperf3 -c server_ip # 客户端
如果 iperf 很快但 FTP 慢 → FTP 配置问题
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=31000
防火墙放行:
firewall-cmd --add-port=30000-31000/tcp --permanent
firewall-cmd --reload
reverse_lookup_enable=NO
max_clients=200
max_per_ip=10
anonymous_enable=NO
local_enable=YES
write_enable=YES
async_abor_enable=YES
use_localtime=YES
cat >> /etc/sysctl.conf <<EOF
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
EOF
sysctl -p
echo deadline > /sys/block/sda/queue/scheduler
setenforce 0
正式环境改为:
setsebool -P ftpd_full_access on
FTP 本身明文 + 多端口,性能和安全都不如:
scp bigfile.iso user@server:/path
ssl_enable=YES
如果你愿意,可以告诉我:
我可以直接帮你写一份最优 vsftpd.conf。