在zookeeper/bin目录下新建脚本文件 zkmanager.sh
#!/bin/bash
for i in {"hadoop2","hadoop3","hadoop4"};
do
echo "----------$1ing $i----------"
ssh $i "source /etc/profile;/usr/local/zookeeper-3.5/bin/zkServer.sh $1"
done
sleep 5
for j in {"hadoop2","hadoop3","hadoop4"};
do
echo "----------$j status----------"
ssh $j "source /etc/profile;/usr/local/zookeeper-3.5/bin/zkServer.sh status"
done
启动
zkmanager.sh start
>>>
----------starting hadoop2----------
Warning: Permanently added 'hadoop2,172.17.0.3' (RSA) to the list of known hosts.
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
----------starting hadoop3----------
Warning: Permanently added 'hadoop3,172.17.0.4' (RSA) to the list of known hosts.
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
----------starting hadoop4----------
Warning: Permanently added 'hadoop4,172.17.0.5' (RSA) to the list of known hosts.
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
----------hadoop2 status----------
Warning: Permanently added 'hadoop2,172.17.0.3' (RSA) to the list of known hosts.
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: follower
----------hadoop3 status----------
Warning: Permanently added 'hadoop3,172.17.0.4' (RSA) to the list of known hosts.
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: leader
----------hadoop4 status----------
Warning: Permanently added 'hadoop4,172.17.0.5' (RSA) to the list of known hosts.
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: follower