Chinaunix首页 | 论坛 | 博客
  • 博客访问: 213526
  • 博文数量: 25
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 238
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-11 10:03
个人简介

linux运维

文章分类

全部博文(25)

文章存档

2017年(5)

2016年(2)

2015年(18)

我的朋友

分类: 系统运维

2016-01-25 17:01:31



背景介绍:
目前项目在美国东西部以及欧洲都有服务器节点,跨互联网的数据传输速度很不稳定,之前我们主要是通过SCP以及Rsync等方式进行数据传输的。
无意间发现了BBCP这个软件之后,经过测试,效果非常好,速度提升效果很明显,并且传输速度一直比较稳定,同时支持日志以及失败后重试等参数,非常不错。

参考资料:


安装配置(可以根据自己的服务器情况选择性下载对应的文件):
[heydevops@east-server1 ~]$ sudo wget ~abh/bbcp/bin/amd64_rhel60/bbcp -O /usr/bin/bbcp
[heydevops@east-server1 ~]$ sudo chmod +x /usr/bin/bbcp

[heydevops@west-server1 ~]$ sudo wget ~abh/bbcp/bin/amd64_rhel60/bbcp -O /usr/bin/bbcp
[heydevops@west-server1 ~]$ sudo chmod +x /usr/bin/bbcp

[heydevops@east-server1 ~]$ which bbcp
/usr/bin/bbcp
[heydevops@east-server1 ~]$ ssh west-server1 which bbcp
/usr/bin/bbcp

[heydevops@east-server1 ~]$ cd heydevops
[heydevops@east-server1 heydevops]$ sudo dd if=/dev/zero of=/home/heydevops/heydevops/file.2g bs=1024M count=2

点击(此处)折叠或打开

  1. 2+0 records in
  2. 2+0 records out
  3. 2147483648 bytes (2.1 GB) copied, 45.9129 s, 46.8 MB/s


[heydevops@east-server1 heydevops]$ ls -lh
total 2.0G
-rw-r--r-- 1 root root 2.0G Mar 4 06:40 file.2g

[heydevops@east-server1 heydevops]$ time bbcp -r -P 2 -V -w 8m -s 16 file.2g west-server1:/home/heydevops/heydevops/

点击(此处)折叠或打开

  1. bbcp: Window size reduced to 245760 bytes.
  2. bbcp: Indexing files to be copied...
  3. bbcp: Copying 0 files in 0 directories.
  4. Source east-server1.heylinux.com using initial send window of 18700
  5. Target west-server1.heylinux.com using initial recv window of 87380
  6. bbcp: Creating /home/heydevops/heydevops/file.2g
  7. bbcp: 140304 06:46:12 0% done; 8.5 MB/s, avg 8.5 MB/s
  8. bbcp: 140304 06:46:14 1% done; 6.9 MB/s, avg 7.5 MB/s
  9. ...
  10. bbcp: 140304 06:51:46 99% done; 7.7 MB/s, avg 6.1 MB/s
  11. bbcp: 140304 06:51:48 99% done; 3.3 MB/s, avg 6.1 MB/s
  12. Source cpu=3.643 (sys=3.552 usr=0.091).
  13. File /home/heydevops/heydevops/file.2g created; 2147483648 bytes at 6.0 MB/s
  14. 48 buffers used with 0 reorders; peaking at 0.
  15. Source east-server1.heylinux.com using a final send window of 433840
  16. Target cpu=15.149 (sys=14.505 usr=0.644).
  17. Target west-server1.heylinux.com using a final recv window of 2298624
  18. 1 file copied at effectively 6.0 MB/s
  19.  
  20. real 5m42.236s
  21. user 0m0.104s
  22. sys 0m3.567s
[heydevops@east-server1 heydevops]$ time scp file.2g west-server1:/home/heydevops/heydevops/

点击(此处)折叠或打开

  1. file.2g 100% 2048MB 2.1MB/s 16:06  
  2. real 16m8.448s
  3. user 0m43.497s
  4. sys 0m7.548s

结论:
在上面的测试中,传输一个大小为2G的文件,使用BBCP耗时仅5分钟,而普通的SCP则耗时16分钟,速度提升超过60%。
更进一步的测试报告可以在这里看到:

最近更新:
目前,我们在线上正式使用BBCP已经有一个月了,效果不错,下面,将我们用到的参数分享给大家:
[dong.guo@heydevops ~]$ dd if=/dev/zero of=/home/dong.guo/file.16m bs=1M count=16
[dong.guo@heydevops ~]$ pwd
[dong.guo@heydevops ~]$ ls -lh file.16m
total 2.0G
-rw-r--r-- 1 dong.guo adm 16M May  5 12:08 file.16m
[dong.guo@heydevops ~]$ bbcp -k -a /tmp/bbcp_checkpoint -r -P 2 -V -f -w 9m -s 16 -T "ssh -x -a -p 2222 -oFallBackToRsh=no -i /home/dong.guo/.ssh/id_rsa -l heydevops heylinux.com /usr/bin/bbcp" file.16m heydevops@heylinux.com:/tmp/

点击(此处)折叠或打开

  1. Warning: the RSA host key for '[heylinux.com]:2222' differs from the key for the IP address '[54.238.131.140]:2222'
  2. Offending key for IP in /home/dong.guo/.ssh/known_hosts:517
  3. Matching host key in /home/dong.guo/.ssh/known_hosts:528
  4. bbcp: Sink I/O buffers (147456K) > 25% of available free memory (40988K); copy may be slow
  5. bbcp: Window size reduced to 245760 bytes.
  6. bbcp: Indexing files to be copied...
  7. bbcp: Copying 0 files in 0 directories.
  8. Source heydevops using initial send window of 19800
  9. Target ec2-tokyo.localdomain using initial recv window of 87380
  10. bbcp: Appending to /tmp/file.16m at offset 0
  11. 11    bbcp: 140505 12:11:30 28% done; 4.0 MB/s, avg 4.0 MB/s
  12. bbcp: 140505 12:11:32 30% done; 148.0 KB/s, avg 1.6 MB/s
  13. Source cpu=0.239 (sys=0.233 usr=0.006).
  14. File /tmp/file.16m created; 16777216 bytes at 3.3 MB/s
  15. 288 buffers used with 33 reorders; peaking at 21.
  16. Target cpu=0.303 (sys=0.291 usr=0.012).
  17. Target ec2-tokyo.localdomain using a final recv window of 502864
  18. Source heydevops using a final send window of 71280
  19. 1 file copied at effectively 1.5 MB/s


参数详解:

点击(此处)折叠或打开

  1. 01    -k 保留所有未传输完成的文件,并允许在重试时进行覆盖
  2. 02    -a 保留checkpoint信息用于校验文件的完整性
  3. 03    -r 递归传输指定路径下的所有文件
  4. 04    -P 2 每两秒显示传输的进程
  5. 05    -V 打印调试信息
  6. 06    -f 强制清除远程主机上传输失败的数据
  7. 07    -w 设置Disk (I/O) buffers
  8. 08     算法为(window = netspeed/8*RTT = 1000Mb/8*74ms = 1000/1000/8*74 = 9.25 M)
  9. 09     对应链接:http://www.slac.stanford.edu/~abh/bbcp/#_Toc332986061
  10. 10    -s 16 设置并发数为16
  11. 11     参考官方建议:http://www.slac.stanford.edu/~abh/bbcp/#_Streams_(-s)
  12. 12    -"ssh -x -a -p 2222 -oFallBackToRsh=no -i /home/dong.guo/.ssh/id_rsa -l heydevops heylinux.com /usr/bin/bbcp"
  13. 13     指定远端主机的认证方式:
  14. 14     采用-p 2222指定端口;
  15. 15     设置-oFallBackToRsh=no减少ssh响应时间;
  16. 16     设置-i /home/dong.guo/.ssh/id_rsa指定SSH Key;
  17. 17     设置-l heydevops指定登陆用户;
  18. 18     heylinux.com为远程主机地址;
  19. 19     /usr/bin/bbcp为远程主机的bbcp路径;


原文地址:



阅读(2997) | 评论(0) | 转发(0) |
0

上一篇:Codis安装部署全架构

下一篇:python操作redis

给主人留下些什么吧!~~