把登录用户名写进去
添加写入权限
1.2.5 脚本准备
这是一个批处理脚本,转载自网友“子墨良言”
通过它可以方便地在一整个集群当中执行相同的命令并获得回显。
deploy.conf
masternode,all,namenode,zookeeper,resourcemanager,
slavenode1,all,slave,namenode,zookeeper,resourcemanager,
slavenode2,all,slave,datanode,zookeeper,
deploy.sh
#!/bin/bash
#set -x
if [ $# -lt 3 ]
then
echo “Usage: ./deply.sh srcFile(or Dir) descFile(or Dir) MachineTag”
echo “Usage: ./deply.sh srcFile(or Dir) descFile(or Dir) MachineTag confFile”
exit
fi
src=$1
dest=$2
tag=$3
if [ ‘a’$4’a’ == ‘aa’ ]
then
confFile=/home/hadoop/tools/deploy.conf
else
confFile=$4
fi
if [ -f $confFile ]
then
if [ -f $src ]
then
for server in cat $confFile|grep -v '^#'|grep ','$tag','|awk -F',' '{print $1}'
do
scp $src s e r v e r " : " server":" server":"{dest}
done
elif [ -d $src ]
then
for server in cat $confFile|grep -v '^#'|grep ','$tag','|awk -F',' '{print $1}'
do
scp -r $src s e r v e r " : " server":" serv