环境:

VirtualBox:5.1.6

Centos:7

Java:1.8

Zookeeper:3.4.9

VirtualBox搭建的三个Zookeeper环境。


连接被拒绝

[root@centos_105_239 bin]# zkCli.sh -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2016-11-01 22:20:40,226 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT
2016-11-01 22:20:40,229 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=
2016-11-01 22:20:40,229 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_111
2016-11-01 22:20:40,230 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2016-11-01 22:20:40,231 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/java/jdk1.8.0_111/jre
2016-11-01 22:20:40,231 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/opt/zookeeper-3.4.9/bin/../build/classes:/opt/zookeeper-3.4.9/bin/../build/lib/*.jar:/opt/zookeeper-3.4.9/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper-3.4.9/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper-3.4.9/bin/../lib/netty-3.10.5.Final.jar:/opt/zookeeper-3.4.9/bin/../lib/log4j-1.2.16.jar:/opt/zookeeper-3.4.9/bin/../lib/jline-0.9.94.jar:/opt/zookeeper-3.4.9/bin/../zookeeper-3.4.9.jar:/opt/zookeeper-3.4.9/bin/../src/java/lib/*.jar:/opt/zookeeper-3.4.9/bin/../conf:
2016-11-01 22:20:40,231 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2016-11-01 22:20:40,231 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2016-11-01 22:20:40,231 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=
2016-11-01 22:20:40,231 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2016-11-01 22:20:40,231 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2016-11-01 22:20:40,231 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.10.0-327.el7.x86_64
2016-11-01 22:20:40,231 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
2016-11-01 22:20:40,231 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
2016-11-01 22:20:40,231 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/opt/zookeeper-3.4.9/bin
2016-11-01 22:20:40,232 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@446cdf90
Welcome to ZooKeeper!
JLine support is enabled
2016-11-01 22:20:40,345 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2016-11-01 22:20:40,505 [myid:] - WARN  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1162] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)

解决:重启Zookeeper服务 - zkServer.sh restart


ZooKeeper集群IP不能正确映射

三个虚拟机的单机模式都正常,例如:

[root@centos_1 data]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
Mode: standalone

从centos_1(192.168.1.156)中 ping centos_2(192.168.1.158)正常:

[root@centos_1 data]# ping -c 2 192.168.1.158
PING 192.168.1.158 (192.168.1.158) 56(84) bytes of data.
64 bytes from 192.168.1.158: icmp_seq=1 ttl=64 time=0.603 ms
64 bytes from 192.168.1.158: icmp_seq=2 ttl=64 time=0.795 ms

--- 192.168.1.158 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.603/0.699/0.795/0.096 ms

从centos_2(192.168.1.158)中 ping centos_3(192.168.1.159)正常:

[root@centos_2 data]# ping -c 2 192.168.1.159
PING 192.168.1.159 (192.168.1.159) 56(84) bytes of data.
64 bytes from 192.168.1.159: icmp_seq=1 ttl=64 time=0.561 ms
64 bytes from 192.168.1.159: icmp_seq=2 ttl=64 time=1.10 ms

--- 192.168.1.159 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.561/0.830/1.100/0.271 ms

配置文件:

# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5 
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/opt/zookeeper-3.4.9/data
 
# 日志文件
dataLogDir=/opt/zookeeper-3.4.9/logs
 
# the port at which the clients will connect
clientPort=2181 
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60 
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1 
server.1=centos_1:2888:3888server.2=centos_2:2888:3888server.3=centos_3:2888:3888

集群不能正常启动,下面是具体的log:

[root@centos_3 data]# cat zookeeper.out 2016-11-03 19:33:18,609 [myid:] - INFO  [main:QuorumPeerConfig@124] - Reading configuration from: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
2016-11-03 19:33:18,625 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_3 to address: centos_3/192.168.1.1592016-11-03 19:33:33,628 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_2 to address: centos_2/220.250.64.2252016-11-03 19:33:38,633 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_1 to address: centos_1/220.250.64.2252016-11-03 19:33:38,634 [myid:] - INFO  [main:QuorumPeerConfig@352] - Defaulting to majority quorums
2016-11-03 19:33:38,643 [myid:1] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 32016-11-03 19:33:38,646 [myid:1] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 02016-11-03 19:33:38,646 [myid:1] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2016-11-03 19:33:38,663 [myid:1] - INFO  [main:QuorumPeerMain@127] - Starting quorum peer
2016-11-03 19:33:38,678 [myid:1] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:21812016-11-03 19:33:38,725 [myid:1] - INFO  [main:QuorumPeer@1019] - tickTime set to 20002016-11-03 19:33:38,725 [myid:1] - INFO  [main:QuorumPeer@1039] - minSessionTimeout set to -1
2016-11-03 19:33:38,725 [myid:1] - INFO  [main:QuorumPeer@1050] - maxSessionTimeout set to -1
2016-11-03 19:33:38,725 [myid:1] - INFO  [main:QuorumPeer@1065] - initLimit set to 102016-11-03 19:33:38,742 [myid:1] - INFO  [main:QuorumPeer@533] - currentEpoch not found! Creating with a reasonable default of 0. This should only happen when you are upgrading your installation
2016-11-03 19:33:38,765 [myid:1] - INFO  [main:QuorumPeer@548] - acceptedEpoch not found! Creating with a reasonable default of 0. This should only happen when you are upgrading your installation
2016-11-03 19:33:38,778 [myid:1] - INFO  [ListenerThread:QuorumCnxManager$Listener@534] - My election bind port: centos_1/220.250.64.225:38882016-11-03 19:33:38,780 [myid:1] - ERROR [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@547] - Exception while listening
java.net.BindException: Cannot assign requested address (Bind failed)
	at java.net.PlainSocketImpl.socketBind(Native Method)
	at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
	at java.net.ServerSocket.bind(ServerSocket.java:375)
	at java.net.ServerSocket.bind(ServerSocket.java:329)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java:537)
2016-11-03 19:33:38,784 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer@774] - LOOKING
2016-11-03 19:33:38,785 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@818] - New election. My id =  1, proposed zxid=0x0
2016-11-03 19:33:38,790 [myid:1] - INFO  [WorkerReceiver[myid=1]:FastLeaderElection@600] - Notification: 1 (message format version), 1 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LOOKING (n.state), 1 (n.sid), 0x0 (n.peerEpoch) LOOKING (my state)
2016-11-03 19:33:39,782 [myid:1] - INFO  [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@534] - My election bind port: centos_1/220.250.64.225:38882016-11-03 19:33:39,782 [myid:1] - ERROR [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@547] - Exception while listening
java.net.BindException: Cannot assign requested address (Bind failed)
	at java.net.PlainSocketImpl.socketBind(Native Method)
	at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
	at java.net.ServerSocket.bind(ServerSocket.java:375)
	at java.net.ServerSocket.bind(ServerSocket.java:329)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java:537)
2016-11-03 19:33:40,784 [myid:1] - INFO  [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@534] - My election bind port: centos_1/220.250.64.225:38882016-11-03 19:33:40,785 [myid:1] - ERROR [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@547] - Exception while listening
java.net.BindException: Cannot assign requested address (Bind failed)
	at java.net.PlainSocketImpl.socketBind(Native Method)
	at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
	at java.net.ServerSocket.bind(ServerSocket.java:375)
	at java.net.ServerSocket.bind(ServerSocket.java:329)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java:537)
2016-11-03 19:33:41,785 [myid:1] - INFO  [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@560] - Leaving listener
2016-11-03 19:33:41,786 [myid:1] - ERROR [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@562] - As I'm leaving the listener thread, I won't be able to participate in leader election any longer: centos_1/220.250.64.225:38882016-11-03 19:33:43,795 [myid:1] - WARN  [WorkerSender[myid=1]:QuorumCnxManager@400] - Cannot open channel to 2 at election address centos_2/220.250.64.225:3888java.net.SocketTimeoutException: connect timed out
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:381)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:354)
	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:452)
	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:433)
	at java.lang.Thread.run(Thread.java:745)
2016-11-03 19:33:43,796 [myid:1] - INFO  [WorkerSender[myid=1]:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_2 to address: centos_2/220.250.64.2252016-11-03 19:33:43,797 [myid:1] - WARN  [WorkerSender[myid=1]:QuorumCnxManager@400] - Cannot open channel to 3 at election address centos_3/192.168.1.159:3888java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:381)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:354)
	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:452)
	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:433)
	at java.lang.Thread.run(Thread.java:745)
2016-11-03 19:33:43,798 [myid:1] - INFO  [WorkerSender[myid=1]:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_3 to address: centos_3/192.168.1.1592016-11-03 19:33:48,802 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 2 at election address centos_2/220.250.64.225:3888java.net.SocketTimeoutException: connect timed out
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:381)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:426)
	at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:843)
	at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:822)
2016-11-03 19:33:48,803 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_2 to address: centos_2/220.250.64.2252016-11-03 19:33:48,804 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 4002016-11-03 19:33:54,206 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 2 at election address centos_2/220.250.64.225:3888java.net.SocketTimeoutException: connect timed out
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:381)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:426)
	at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:843)
	at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:822)
2016-11-03 19:33:54,208 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_2 to address: centos_2/220.250.64.2252016-11-03 19:33:54,209 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 3 at election address centos_3/192.168.1.159:3888java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:381)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:426)
	at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:843)
	at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:822)
2016-11-03 19:33:54,212 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_3 to address: centos_3/192.168.1.1592016-11-03 19:33:54,212 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 8002016-11-03 19:34:00,021 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 2 at election address centos_2/220.250.64.225:3888java.net.SocketTimeoutException: connect timed out
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:381)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:426)
	at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:843)
	at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:822)
2016-11-03 19:34:00,022 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_2 to address: centos_2/220.250.64.2252016-11-03 19:34:00,024 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 3 at election address centos_3/192.168.1.159:3888java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:381)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:426)
	at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:843)
	at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:822)
2016-11-03 19:34:00,024 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_3 to address: centos_3/192.168.1.1592016-11-03 19:34:00,025 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 16002016-11-03 19:34:06,632 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 2 at election address centos_2/220.250.64.225:3888java.net.SocketTimeoutException: connect timed out
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:381)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:426)
	at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:843)
	at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:822)

解决:不能根据hostname正常解析ip,可直接把hostname替换为ip


虚拟机中ping不通宿主机

主机可Ping通三个虚拟机,虚拟机网络正常,但ping不通宿主机。


解决:宿主机的防火墙设置问题.

windows防火墙-》高级设置-》入站规则(双击文件和打印机共享-icmpv4-in)-》启用

zookeeper集群搭建中遇到的问题_第1张图片

zookeeper集群搭建中遇到的问题_第2张图片zookeeper集群搭建中遇到的问题_第3张图片