#!/bin/bash
#集群命令执行脚本
#sh 1.sh "ZKserver.sh stop" hadoop
#sh 1.sh "命令" 进程
#deploy.conf必须存在
#conf=/root/shell/deploy.conf
bin=`dirname $0`
bin=`cd "$conf";pwd`
conf="$bin"/deploy.conf
if [ $# -lt 2 ]
then
echo "请输入两个参数"
exit
fi
cmd=$1
tag=$2
if [ -f $conf ]
then
for server in `cat ${conf} | grep -v "#" | grep ${tag} | awk -F "," '{print $1}'`
do
echo "*******************$server***************************"
ssh $server "source ~/.bash_profile; $cmd"
done
else
echo "Erro:conf does not exist"
fi
#集群配置
192.168.175.51,node1,namenode,hadoop
192.168.175.52,node2,datanode,hadoop
192.168.175.53,node3,datanode,hadoop