copy all scp instructions
scp -r /opt/module dev1@hadoop100:/opt/
rsync: The speed of fast synchronization is faster than scp (only updates the difference file).
For example:
rsync -rvl /opt/software/ dev1@hadoop102:/opt/software
Mysync command:
- Need configuration file
Switch directory:
cd /home/dev1
mkdir bin
cd bin/
vim Mysync
Add in the Mysync file
#!/bin/bash
#1 获取输入参数个数,如果没有参数,直接退出
pcount=$#
if((pcount==0)); then
echo no args;
exit;
fi
#2 获取文件名称
p1=$1
fname=`basename $p1`
echo fname=$fname
#3 获取上级目录到绝对路径
pdir=`cd -P $(dirname $p1); pwd`
echo pdir=$pdir
#4 获取当前用户名称
user=`whoami`
#5 循环 这个地方的主机名是自己的,一定要改成自己可以起作用
for((host=100; host<103; host++)); do
echo ------------------- hadoop$host --------------
rsync -rvl $pdir/$fname $user@hadoop$host:$pdir
done
Modify execution permissions
sudo chmod 777 Mysync
No light up means no permission
- Command format
Mysync + file name
For example
Mysync /home/dev1/bin
Then there will be a prompt to enter the password, enter the password of hadoop100, hadoop101, hadoop102, and hadoop193 in turn.