linux大文件传输

Mysql复制,初始化服务器,备份/还原等大文件复制是很常见的任务,他们完成的实际任务可以概括为:

1,(可选)压缩文件

2,发送文件

3,解压文件

4,验证文件一致性

下面介绍几种方法:

1,最简单的:

先进行压缩,再用scp发送到服务器

gzip -c /folder/bigfiles/ > bigfiles.gz
scp bigfiles.gz root@test.host:/folder/bigfiles/

然后在服务器的解压:

gunzip /folder/bigfiles/bigfiles.gz

这种方法效率不高,因为涉及到压缩,复制,解压缩等串行化操作,写磁盘速度比较慢...

2,一步到位的方法,

gzip -c /folder/bigfiles | ssh root@test.host "gunzip -c - > /folder/bigfiles"

 上面这些方法都会进行压缩和安全性认证,耗时还是比较大的;下面使用nc来进行传输;

3,nc的使用:

     在服务器端执行: nc  -l -p 12345 | gunzip -c - > /folder/bigfiles 

     在客户端执行:    gzip -c - /folder/bigfiles | nc -q server.host 123456

原文地址:https://www.cnblogs.com/trying/p/3378148.html