背景介绍:
目前项目在美国东西部以及欧洲都有服务器节点,跨互联网的数据传输速度很不稳定,之前我们主要是通过SCP以及Rsync等方式进行数据传输的。
无意间发现了BBCP这个软件之后,经过测试,效果非常好,速度提升效果很明显,并且传输速度一直比较稳定,同时支持日志以及失败后重试等参数,非常不错。
参考资料:
http://www.slac.stanford.edu/~abh/bbcp/
http://pcbunn.cithep.caltech.edu/bbcp/using_bbcp.htm
https://www.olcf.ornl.gov/kb_articles/transferring-data-with-bbcp/
安装配置:
$ sudo wget http://www.slac.stanford.edu/~abh/bbcp/bin/amd64_rhel60/bbcp -O /usr/bin/bbcp
$ sudo chmod +x /usr/bin/bbcp
$ sudo wget http://www.slac.stanford.edu/~abh/bbcp/bin/amd64_rhel60/bbcp -O /usr/bin/bbcp
$ sudo chmod +x /usr/bin/bbcp
$ which bbcp
/usr/bin/bbcp
$ ssh west-ads1 which bbcp
/usr/bin/bbcp
1
2
3
4
5
6
7
8
$sudowgethttp://www.slac.stanford.edu/~abh/bbcp/bin/amd64_rhel60/bbcp -O /usr/bin/bbcp
$sudochmod+x/usr/bin/bbcp
$sudowgethttp://www.slac.stanford.edu/~abh/bbcp/bin/amd64_rhel60/bbcp -O /usr/bin/bbcp
$sudochmod+x/usr/bin/bbcp
$whichbbcp
/usr/bin/bbcp
$sshwest-ads1whichbbcp
/usr/bin/bbcp
创建测试文件:
$ cd dong
$ sudo dd if=/dev/zero of=/home/adsymp/dong/file.2g bs=1024M count=2
2+0 records in
2+0 records out
2147483648 bytes (2.1 GB) copied, 45.9129 s, 46.8 MB/s
$ ls -lh
total 2.0G
-rw-r--r-- 1 root root 2.0G Mar 4 06:40 file.2g
1
2
3
4
5
6
7
8
$cddong
$sudoddif=/dev/zeroof=/home/adsymp/dong/file.2gbs=1024Mcount=2
2+0recordsin
2+0recordsout
2147483648bytes(2.1GB)copied,45.9129s,46.8MB/s
$ls-lh
total2.0G
-rw-r--r--1rootroot2.0GMar406:40file.2g
测试:
$ time bbcp -r -P 2 -V -w 8m -s 16 file.2g west-ads1:/home/adsymp/dong/
bbcp: Window size reduced to 245760 bytes.
bbcp: Indexing files to be copied...
bbcp: Copying 0 files in 0 directories.
Source sc2-admin1002.drawbrid.ge using initial send window of 18700
Target iad2-admin1002.drawbrid.ge using initial recv window of 87380
bbcp: Creating /home/adsymp/dong/file.2g
bbcp: 140304 06:46:12 0% done; 8.5 MB/s, avg 8.5 MB/s
bbcp: 140304 06:46:14 1% done; 6.9 MB/s, avg 7.5 MB/s
...
bbcp: 140304 06:51:46 99% done; 7.7 MB/s, avg 6.1 MB/s
bbcp: 140304 06:51:48 99% done; 3.3 MB/s, avg 6.1 MB/s
Source cpu=3.643 (sys=3.552 usr=0.091).
File /home/adsymp/dong/file.2g created; 2147483648 bytes at 6.0 MB/s
48 buffers used with 0 reorders; peaking at 0.
Source sc2-admin1002.drawbrid.ge using a final send window of 433840
Target cpu=15.149 (sys=14.505 usr=0.644).
Target iad2-admin1002.drawbrid.ge using a final recv window of 2298624
1 file copied at effectively 6.0 MB/s
real 5m42.236s
user 0m0.104s
sys 0m3.567s
$ time scp file.2g west-ads1:/home/adsymp/dong/
file.2g 100% 2048MB 2.1MB/s 16:06
real 16m8.448s
user 0m43.497s
sys 0m7.548s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$timebbcp-r-P2-V-w8m-s16file.2gwest-ads1:/home/adsymp/dong/
bbcp:Windowsizereducedto245760bytes.
bbcp:Indexingfilestobecopied...
bbcp:Copying0filesin0directories.
Sourcesc2-admin1002.drawbrid.geusinginitialsendwindowof18700
Targetiad2-admin1002.drawbrid.geusinginitialrecvwindowof87380
bbcp:Creating/home/adsymp/dong/file.2g
bbcp:14030406:46:120%done;8.5MB/s,avg8.5MB/s
bbcp:14030406:46:141%done;6.9MB/s,avg7.5MB/s
...
bbcp:14030406:51:4699%done;7.7MB/s,avg6.1MB/s
bbcp:14030406:51:4899%done;3.3MB/s,avg6.1MB/s
Sourcecpu=3.643(sys=3.552usr=0.091).
File/home/adsymp/dong/file.2gcreated;2147483648bytesat6.0MB/s
48buffersusedwith0reorders;peakingat0.
Sourcesc2-admin1002.drawbrid.geusingafinalsendwindowof433840
Targetcpu=15.149(sys=14.505usr=0.644).
Targetiad2-admin1002.drawbrid.geusingafinalrecvwindowof2298624
1filecopiedateffectively6.0MB/s
real5m42.236s
user0m0.104s
sys0m3.567s
$timescpfile.2gwest-ads1:/home/adsymp/dong/
file.2g100%2048MB2.1MB/s16:06
real16m8.448s
user0m43.497s
sys0m7.548s
结论:
在上面的测试中,传输一个大小为2G的文件,使用BBCP耗时仅5分钟,而普通的SCP则耗时16分钟,速度提升超过60%。
更进一步的测试报告可以在这里看到:http://heylinux.com/en/?p=258
转自:http://heylinux.com/archives/2984.html