zookeeper集群搭建Exception when following the leader java.io.EOFException


zk配置后集群選舉失敗,集群中全部無法進行選舉,但是應用又起來了。

先講原因:后經人指點,server的端口配置錯誤導致。server占用了client的端口號導致的。說明server.1=127.0.0.1:2181:3181中2181是server端口但是我又配置了clientPort=2181.把server端口和client端口混為一談導致的(汗顏並吐槽:zk既然配置錯誤了,就不應該讓項目啟動成功,應該直接停止程序或者直接報錯)。

修改zoo.cnf中集群錯誤配置:

server.1=127.0.0.1:2181:3181
server.2=127.0.0.1:2182:3182
server.3=127.0.0.1:2183:3183

為正確配置:

server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3899
server.3=127.0.0.1:2890:3890

 

附件:

Exception when following the leader
java.io.EOFException

線上異常截圖:

 

 

 

用zkServer.sh status的狀態命令查看如下:

 

 

 

錯誤配置文件:

# 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=D:/Dev/data/zookeeper/z1
# 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

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
server.1=127.0.0.1:2181:3181
server.2=127.0.0.1:2182:3182
server.3=127.0.0.1:2183:3183

正確配置:

# 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=D:/Dev/data/zookeeper/z1
# 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

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3899
server.3=127.0.0.1:2890:3890

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM