- 选择一个配置好环境变量的目录下
进入编写程序
[root@master bin]
/opt/zookeeper/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/jdk/bin:/opt/hadoop/bin:/opt/hadoop/sbin:/opt/flink/bin:/root/bin
[root@master bin]
[root@master bin]
- 编写脚本
if [ $
then
echo Not Enough Arguement!
exit;
fi
for host in master slave01 slave02 slave03
do
echo ========================= $host ===========================
for file in $@
do
if [ -e $file ]
then
pdir=$(cd -P $(dirname $file); pwd)
fname=$(basename $file)
ssh $host "mkdir -p $pdir"
rsync -av $pdir/$fname $host:$pdir
else
echo $file does not exists!
fi
done
done