三台物理机集群失败

来源:5-3 三台物理机(虚拟机)安装zookeeper集群

慕盖茨0063281

2019-06-10

这个id为1的zookeeper启动的报错,连接不到2和3,都是因为没有到主机的路由,2和3的zookeeper报相同的错。
可是,它们之间是能互相ping通的。
报错信息如下:

2019-06-10 13:19:10,923 [myid:1] - WARN  [WorkerSender[myid=1]:QuorumCnxManager@584] - Cannot open channel to 2 at election address /192.168.56.3:3888
java.net.NoRouteToHostException: 没有到主机的路由 (Host unreachable)
        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:558)
        at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:534)
        at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:454)
        at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:435)
        at java.lang.Thread.run(Thread.java:748)
2019-06-10 13:19:10,925 [myid:1] - INFO  [WorkerSender[myid=1]:QuorumPeer$QuorumServer@185] - Resolved hostname: 192.168.56.3 to address: /192.168.56.3
2019-06-10 13:19:10,927 [myid:1] - WARN  [WorkerSender[myid=1]:QuorumCnxManager@584] - Cannot open channel to 3 at election address /192.168.56.4:3888
java.net.NoRouteToHostException: 没有到主机的路由 (Host unreachable)
        at java.net.PlainSocketImpl.socketConnect(Native Method)

其中一个zookeeper的配置文件如下:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# 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=/development/usr/zookeeper/dataDir
dataLogDir=/development/usr/zookeeper/dataLogDir
# 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

4lw.commands.whitelist=*

server.1=192.168.56.2:2888:3888
server.2=192.168.56.3:2888:3888
server.3=192.168.56.4:2888:3888
写回答

2回答

慕盖茨0063281

提问者

2019-06-10

额,还真是防火墙的问题,我的centos7是最小化安装的,以为不带防火墙或者没有启用防火墙,但是它还真的在启用防火墙,关闭防火墙就好了。

centos7中相关防火墙的操作:

* 查看防火墙的状态的命令为:`systemctl status firewalld`
* 启动防火墙: `systemctl start firewalld`
* 启用防火墙,需要重启系统生效:`systemctl enable firewalld`
* 关闭防火墙:`systemctl stop firewalld`
* 禁用防火墙,重启也不会使用了:`systemctl disable firewalld`

1
0

风间影月

2019-06-10

哈哈,好了就行

0
0

ZK分布式专题与Dubbo微服务入门,成长与加薪必备

进阶中高级工程师必备技能,大数据与微服务最常用的中间件

1859 学习 · 321 问题

查看课程