作者:张华 发表于:2020-10-22
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
由于运营商对non-http流量限速,从国外ftp下载大数据将变得异常艰难.目前采用的方法如下:
1, 国外虚机上安装curlftpfs将ftp站点镜像到/mnt/ftp
sudo apt install curlftpfs -y
#sudo fusermount -zu /mnt/ftp
sudo mkdir -p /mnt/ftp && sudo chown -R $USER /mnt/ftp
sudo bash -c 'cat >>/etc/fstab' <<EOF
curlftpfs#@ftp.hycom.org/datasets/global/GLBa0.08_rect/data /mnt/ftp fuse defaults,rw,allow_other,uid=1000,gid=1000,_netdev 0 0
EOF
sudo mount -a
2, 安装nginx指向/mnt/ftp将ftp变http
sudo apt install nginx -y
sudo vim /etc/nginx/sites-available/default
#root /var/www/html;
root /mnt/ftp;
location / {
try_files $uri $uri/ =404;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
3, 国内采用下列命令下载.
wget -c -m http://3.18.xx.xx
#rsync -avztur -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ~/.aws/xxx.pem" --progress ubuntu@3.18.xx.xx:/mnt/ftp .
但还是很快报了404错误,但通过下列方法debug curlftpfs显示是虚机和ftp.hycom.org之前的网络不通,重启虚机问题一样,但新建虚机可以telent ftp.hycom.org 21
#debug curlftpfs
sudo fusermount -zu /mnt/ftp/2d
sudo curlftpfs -f -v -o debug,ftpfs_debug=3,rw,allow_other,uid=1000,gid=1000 ftp://ftp.hycom.org/datasets/global/GLBa0.08_rect/data/2d /mnt/ftp/2d
难道是curlftpfs使用passive mode时遇到了防火墙问题, 这个网页(https://serverfault.com/questions/144266/allow-curlftpfs-though-iptables-firewall-how)提到了使用" -oftp_port=- "化解,但我没有试.
目前直接新开虚机,新建了一个6T的大硬盘,然后在虚机上运行
sudo mkfs.ext4 /dev/xvdb
#sudo parted /dev/xvdb #print
sudo mount /dev/xvdb /mnt/
cd /mnt
wget -c -m ftp://ftp.hycom.org/datasets/global/GLBa0.08_rect/data/
然后nginx的目录指向: /mnt/ftp.hycom.org/datasets/global/GLBa0.08_rect/data
国内机器可以同时通过: wget -c -m http://xxx命令下载
另外,若要内网远程连接,简单地:
curl -s https://install.zerotier.com | sudo bash
zerotier-cli join e4da7455b283ffb8
systemctl enable zerotier-one