03.大数据集群必备脚本大合集

/usr/local/bin

sudo nano .hosts

s101
s102
s103
s104
s105

 xcall.sh

#!/bin/bash
for host in `cat /usr/local/bin/.hosts` ;
do
    tput setaf 2
         echo ======== $host ========
    tput setaf 7
        ssh $host "source /etc/profile;$@"
done
 
xcall.sh  "yum install -y  rsync.x86_64"
 scp -r /soft/hadoop/etc centos@s104:/soft/hadoop/   不支持软连接
   rsync -lr /soft/hadoop/etc centos@s104:/soft/hadoop/
 
xsync.sh
#!/bin/bash
name=`whoami`
# 指定文件所在文件夹名称
dir=`dirname $1`
# 指定文件的文件名
filename=`basename $1`
# 进入到dir中
cd $dir
# 得到当前目录的绝对路径
fullpath=`pwd`

for((i=102 ; i<=105; i++)) ; 
do
    tput setaf 2
    echo ==================== s$i $@ ===================
    tput setaf 9
    rsync -lr $filename "$name"@s"$i":$fullpath

done

 记得给文件执行权限   chmod  777    xcall.sh 

原文地址:https://www.cnblogs.com/star521/p/10241047.html