今天用自己写的脚本启动zookeeper集群(用hadoop102启动自己及hadoop103,hadoop104)的时候突然报错如下:
Error contacting service. It is probably not running.
网上找了很久也没解决,查看zookeeper.out报的错误如下:
Cannot open channel to 2 at election address hadoop103/192.168.10.103:3888
java.net.ConnectException: 拒绝连接 (Connection refused)
我ssh免密登录也配了,扑所迷离的问题....
然后我查看自己写的脚本如下:
#!/bin/bash echo "-------------------正在启动zookeeper集群-------- " ssh root@hadoop102 '/opt/module/zookeeper-3.4.6/bin/zkServer.sh start' ssh root@hadoop103 '/opt/module/zookeeper-3.4.6/bin/zkServer.sh start' ssh root@hadoop104 '/opt/module/zookeeper-3.4.6/bin/zkServer.sh start' echo "-------------------查看是否启动成功及状态信息----------- " echo "---------------hadoop102查看--------" ssh root@hadoop102 'source /etc/profile;jps;/opt/module/zookeeper-3.4.6/bin/zkServer.sh status' echo "---------------hadoop103查看--------" ssh root@hadoop103 'source /etc/profile;jps;/opt/module/zookeeper-3.4.6/bin/zkServer.sh status' echo "---------------hadoop104查看--------" ssh root@hadoop104 'source /etc/profile;jps;/opt/module/zookeeper-3.4.6/bin/zkServer.sh status'
之前一直启动得好好得.....然后我尝试在启动集群的时候也增加source /etc/profile命令,改为:
#!/bin/bash echo "-------------------正在启动zookeeper集群-------- " ssh root@hadoop102 'source /etc/profile;/opt/module/zookeeper-3.4.6/bin/zkServer.sh start' ssh root@hadoop103 'source /etc/profile;/opt/module/zookeeper-3.4.6/bin/zkServer.sh start' ssh root@hadoop104 'source /etc/profile;/opt/module/zookeeper-3.4.6/bin/zkServer.sh start' echo "-------------------查看是否启动成功及状态信息----------- " echo "---------------hadoop102查看--------" ssh root@hadoop102 'source /etc/profile;jps;/opt/module/zookeeper-3.4.6/bin/zkServer.sh status' echo "---------------hadoop103查看--------" ssh root@hadoop103 'source /etc/profile;jps;/opt/module/zookeeper-3.4.6/bin/zkServer.sh status' echo "---------------hadoop104查看--------" ssh root@hadoop104 'source /etc/profile;jps;/opt/module/zookeeper-3.4.6/bin/zkServer.sh status'
.....然后奇迹般的可以正常启动了