本文共 3305 字,大约阅读时间需要 11 分钟。
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | 我的博客已迁移到xdoujiang.com请去那边和我交流 基础环境说明及安装 1、服务器 serverA=192.168.1.124(debian7.8) serverB=192.168.1.122(debian6.0.10) 2、需要将serverB下的目录testtransfer(4.5G)下全部远程复制到serverA下 3、需要用到软件 1)apt-cache search pigz pigz - Parallel Implementation of GZip(多线程压缩) 2)apt-cache search pv | grep "^pv" pv - Shell pipeline element to meter data passing through 3)apt-cache search netcat netcat - TCP /IP swiss army knife -- transitional package 4)apt-get -y install pigz 5)apt-get -y install pv 6)apt-get -y install netcat 7)apt-get -y install wget 8)apt-get -y install rsync 9)apt-get -y install vsftpd 10)apt-get -y install lftp 11)apt-get -y install python 一、 ssh + tar + gzip (pigz) 1、使用 ssh + tar + gzip 方式( ssh 协议)在(serverB)上 time tar czf - testtransfer/| ssh -q jimmy@192.168.1.124 "tar zxf - -C /tmp" real 13m20.771s user 4m43.186s sys 1m55.239s 2、使用 ssh + tar +pigz方式( ssh 协议)在(serverB)上 time tar cf - testtransfer/|pigz| ssh -q jimmy@192.168.1.124 "pigz -d|tar xf - -C /tmp" real 12m7.335s user 4m12.200s sys 1m46.455s 参数说明 -d, --decompress Decompress the compressed input 二、nc+ tar + gzip (pigz) 1、使用nc+ tar + gzip 方式(tcp协议) nc -lp 55555| tar -zxf - -C /tmp (serverA) time tar -zcf - testtransfer/|pv|nc -w 1 192.168.1.124 55555(serverB) real 11m31.341s user 4m25.589s sys 1m35.162s 2、使用nc+ tar +pigz方式(tcp协议) nc -lp 55555|pigz -d| tar xf - -C /tmp (serverA) time tar -cf - testtransfer/|pigz|pv|nc -w 1 192.168.1.124 55555(serverB) real 10m42.789s user 4m9.968s sys 1m6.860s 参数说明 -w secs timeout for connects and final net reads 三、python或web服务器 1、python web服务在(serverB)上 nohup python -m SimpleHTTPServer 50000 & 2、在(serverA)上使用wget去下载 wget -r -q 192.168.1.122:50000 real 4m35.531s user 0m0.360s sys 0m33.218s 参数说明 -m module-name Searches sys.path for the named module and runs the corresponding .py file as a script. 四、 rsync ( rsync 协议) 1、服务端配置(serverB) 1)配置rsyncd.conf cat rsyncd.conf [aaa] path = /opt/testtransfer use chroot = yes read only = yes uid = jimmy gid = jimmy auth users = www-data secrets file = /etc/rsyncd .secrets 2)配置验证密码 cat /etc/rsyncd .secrets www-data:123456 3)权限 chmod 600 /etc/rsyncd .secrets 2、客户端配置(serverA) 1)配置密码 cat /etc/rsyncd .secrets 123456 2)开始传输 time rsync -az --password- file = /etc/rsyncd .secrets www-data@192.168.1.122::aaa /opt/111 real 9m46.331s user 0m5.600s sys 1m0.448s 参数说明 -a, --archive This is equivalent to -rlptgoD. -z, --compress With this option, rsync compresses the file data as it is sent to the destination machine, which reduces the amount of data being transmitted -- something that is useful over a slow connection. 五、 ftp ( ftp 协议) 1、服务端配置(serverB) 1)配置vsftpd.conf cat /etc/vsftpd .conf listen=YES local_enable=YES pam_service_name=vsftpd 2、客户端配置(serverA) time lftp jimmy:redhat@192.168.1.122 -e "mirror /opt/testtransfer;quit" real 7m29.727s user 0m1.252s sys 0m46.495s PS:serverB上的jimmy用户建立过的,密码是redhat |