1、在自己的用户下创建脚本文件(此目录下的脚本Mark用户可以在任何情景下使用)
[code][Mark@hadoop102 bin]$ cd /home/Mark/bin[Mark@hadoop102 bin]$ mkdir zkS.sh
2、进入文件编写脚本内容
[code][Mark@hadoop12 bin]$ vim zkS.sh
[code]#!/bin/bashif (($#==0))thenexit 1;fifor i in hadoop12 hadoop13 hadoop14doecho \"===================== Starting zk in $i =======================\"ssh $i \"zkServer.sh $1\" 2> /dev/nulldone
3、执行脚本
[code][Mark@hadoop12 ~]$ zkS.sh start
执行结果:
[code]===================== Starting zk in hadoop12 =======================Starting zookeeper ... STARTED===================== Starting zk in hadoop13 =======================Starting zookeeper ... STARTED===================== Starting zk in hadoop14 =======================Starting zookeeper ... STARTED