zookeeper集群启动脚本
zookeeper集群启动脚本
在Hadoop01的bin/目录下创建zookeeper启动脚本zk.sh
vim zk.sh
插入以下内容
#!/bin/bash case $1 in "start"){ for i in hadoop01 hadoop02 hadoop03 do echo ---------- zookeeper $i 启动 ------------ ssh $i "/opt/zookeeper-3.5.7/bin/zkServer.sh start" done };; "stop"){ for i in hadoop01 hadoop02 hadoop03 do echo ---------- zookeeper $i 停止 ------------ ssh $i "/opt/zookeeper-3.5.7/bin/zkServer.sh stop" done };; "status"){ for i in hadoop01 hadoop02 hadoop03 do echo ---------- zookeeper $i 状态 ------------ ssh $i "/opt/zookeeper-3.5.7/bin/zkServer.sh status" done };; esac
设置权限
chmod 777 zk.sh
测试脚本
zookeeper启动
zk.sh start
zookeeper停止
zk.sh stop