说明:

由于一开始部署了集群机器为2台,后面新加了1台。

这导致了Zookeeper集群出现了故障。

报错信息:

org.apache.zookeeper.server.persistence.FileTxnSnapLog$SnapDirContentCheckException: Snapshot directory has log files. Check if dataLogDir and dataDir configuration is correct.
at org.apache.zookeeper.server.persistence.FileTxnSnapLog.checkSnapDir(FileTxnSnapLog.java:135)
at org.apache.zookeeper.server.persistence.FileTxnSnapLog.(FileTxnSnapLog.java:108)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig(QuorumPeerMain.java:141)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:114)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:81)

环境:

单机模拟三台伪分布式zookeeper

zk1>data1,log1
zk2>data2,log2
zk3>data3,log3

解决方案:

删除每一个data和log文件夹下的version文件夹,重新运行即可

报错原因:

第一次运行三个服务器时没有配置dataLogDir,之后再配置运行后可能与之前默认的log目录产生了冲突

来源:食火的埃尔德里奇