Zookeeper群起脚本启动失败及查看状态出现:Error contacting service. It is probably not running

时间:2020-12-27 22:46:02

1.问题:

群起脚本启动后查看jps没有出现:QuorumPeerMain

Zookeeper正常启动但是群起脚本查状态出现:Error contacting service. It is probably not running错误

ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.4./bin/../conf/zoo.cfg
Error contacting service. It is probably not running.

2.原因:

脚本没有加上source /etc/profile;

3.正确脚本:(仅供参考,请指正)

#! /bin/bash

case $ in
"start"){
for i in hadoop201 hadoop202 hadoop203
do
ssh $i "source /etc/profile;/opt/module/zookeeper-3.4.10/bin/zkServer.sh start"
done
};;
"stop"){
for i in hadoop201 hadoop202 hadoop203
do
ssh $i "/opt/module/zookeeper-3.4.10/bin/zkServer.sh stop"
done
};;
"status"){
for i in hadoop201 hadoop202 hadoop203
do
ssh $i "source /etc/profile;/opt/module/zookeeper-3.4.10/bin/zkServer.sh status"
done
};;
esac