我正在尝试在documentation之后配置3个节点的集合。所有这些都在Linux Ubuntu上。 在所有三个节点上配置文件如下所示:
$ pOOKEEPER_HOME / conf 下的zoo.cfg
tickTime=2000
dataDir=/home/zkuser/zookeeper_data
clientPort=2181
initLimit=5
syncLimit=2
server.1=ip.of.zk1:2888:3888
server.2=ip.of.zk2:2888:3888
server.3=ip.of.zk3:2888:3888
我还放置了各自的" myid
" /home/zkuser/zookeeper_data/
目录下的文件。
这个myid文件包含1在节点(ip.of.zk1)上,依此类推。
当我使用bin / zkServer.sh启动zk服务器时,在控制台上没有显示任何异常。 但是,当我打开bin目录下的zookeeper.out文件时,我看到以下错误。
2014-11-04 00:23:49,120 [myid:3] - WARN [WorkerSender[myid=3]:QuorumCnxManager@382] - Cannot open channel to 1 at election address /ip.of.zk1:3888
java.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:385)
at java.net.Socket.connect(Socket.java:546)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:368)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:341)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:449)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:430)
at java.lang.Thread.run(Thread.java:701)
2014-11-04 00:23:49,123 [myid:3] - WARN [WorkerSender[myid=3]:QuorumCnxManager@382] - Cannot open channel to 2 at election address /ip.of.zk2:3888
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:385)
at java.net.Socket.connect(Socket.java:546)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:368)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:341)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:449)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:430)
at java.lang.Thread.run(Thread.java:701)
注意:我已经在每台机器上使用iptables打开了相应的端口。 例如 : Chain INPUT(政策接受)
target prot opt source destination
ACCEPT all -- IP.of.ZK1 anywhere
ACCEPT all -- IP.of.ZK2 anywhere
ACCEPT all -- IP.of.ZK3 anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
任何人都可以告诉我我错过了什么吗?
此致 JE
答案 0 :(得分:4)
我有类似的问题。我已经从here和here得到了一些问题的提示。在我的例子中,命令netstat -plutn
的输出
正在为选举端口3888显示包括127.0.0.1:3888
在内的内容。我通过更改服务器n上的一部分zoo.cfg解决了这个问题,比如
server.1=name.of.s1:2888.3888
...
server.n=localhost:2888:3888
...
到
server.1=name.of.s1:2888.3888
...
server.n=0.0.0.0:2888:3888
...
ZooKeeper重启后,netstat -plutn
的输出包括:::3888
。
显然,ZooKeeper需要正确公开选举端口,在本例中为3888。
答案 1 :(得分:3)
确保:
echo ruok | netcat ip.of.zk2 2181
,所有服务器都以非错误模式运行。如果没问题,服务器应该回复imok
(仅供参考,这里是list of all supported 4-letter commands)/home/zkuser/zookeeper_data/myid
分别包含每个服务器的值1/2/3 如果有兴趣,我创建了一个vagrant + ansible脚本来创建一个3节点的虚拟Zookeeper集群,请参阅https://github.com/mkrcah/virtual-zookeeper-cluster