在启动zookeeper是否感到烦恼?博主为大家带来了zookeeper一键启动脚本
下面所有.sh文件必须放在/bin目录下,用chmod 777 xx.sh为增加权限,让文件可以执行
启动zookeeper:
zkServer.sh start
脚本名为:start-zkall.sh
#!/bin/sh
for host in hadoop01 hadoop02 hadoop03
doecho "---------------------------------------------------------------------------"
ssh $host "source /etc/profile;zkServer.sh start"
echo "$host zk is started"done
echo "---------------------------------------------------------------------------"
关闭zookeeper:
zkServer.sh stop
脚本名为:stop-zkall.sh
#!/bin/sh
for host in hadoop01 hadoop02 hadoop03
doecho "---------------------------------------------------------------------------"
ssh $host "source /etc/profile;zkServer.sh stop"
echo "$host zk is stop"done
echo "---------------------------------------------------------------------------"
查看zookeeper状态:
zkServer.sh status
脚本名为:status-zkall.sh
#!/bin/sh
for host in hadoop01 hadoop02 hadoop03
doecho "---------------------------------------------------------------------------"
ssh $host "source /etc/profile;zkServer.sh status"
echo "$host's status"done
echo "---------------------------------------------------------------------------"