cp source destination
cp -r /abc /def
//把远程Hadoop101上的/opt/module拷贝到Hadoop102相同的位置
scp -r hadoop101:/opt/module/hadoop-2.7.7 hadoop102:/opt/module
[zhenghui@hadoop101 ~]$ scp -r root@hadoop101:/opt/module/hadoop-2.7.7/ root@hadoop102:/opt/module
yum -y install xinetd rsync
rsync -av hadoop101:/opt/module/hadoop-2.7.7 /opt/module
copypath文件脚本
#!/bin/bash
pcount=$#
echo count=$pcount
if ((pcount==0)); then
echo no args;
exit;
fi
p1=$1
fname=$(basename $p1)
echo fname=$fname
pdir=$(cd -P $(dirname $p1); pwd)
echo pdir=$pdir
user=$(whoami)
for((host=102;host<105;host++));do
echo -------------hadoop$host-------------
rsync -av $pdir/$fname $user@hadoop$host:$pdir
#echo rsync -av $pdir/$fname $user@hadoop$host:$pdir
done
执行:copypath 要发送的文件或者文件夹路径
例如:
[zhenghui@hadoop103 ~]$ ./copypath /opt/software
来源:CSDN
作者:郑晖同学
链接:https://blog.csdn.net/qq_17623363/article/details/104108316