一键开启关闭集群中所有zookeeper
解决痛点:
我有三台虚拟机,现在我想运行一个命令把三台虚拟机的所有zookeeper开启。
首先我们需要把自己的集群ip起上别名,不起别名也可以,在脚本里面写各个linux的ip就行。
用vim编辑/etc/hosts:
vim /etc/hosts
192.168.132.101 mahqi1
192.168.132.102 mahqi2
192.168.132.103 mahqi3
1、启动集群中所有zookeeper脚本
2、关闭集群中所有zookeeper脚本
代码在下面,自取即可
开启zookeeper
#!/bin/bash
for eml in mahqi1 mahqi2 mahqi3
do
ssh $eml "source /etc/profile;zkServer.sh start"
done
echo "ZOOKEEPER START SUCCESSFILLY........."
关闭zookeeper
#!/bin/bash
for eml in mahqi1 mahqi2 mahqi3
do
ssh $eml "source /etc/profile;zkServer.sh stop"
done
echo "# ZOOKEEPER STOP #"