gpt4 book ai didi

java - 无法连接到本地主机上的 Zookeeper :2181

转载 作者:太空宇宙 更新时间:2023-11-04 10:16:08 26 4
gpt4 key购买 nike

我的应用程序正在尝试连接到 Zookeeper @ localhost:2181。 Zookeeper 正在运行并在命令提示符下进行检查。但是,当应用程序运行时,我反复看到以下异常:

2018-08-06 22:25:09 DEBUG ZkClient:919 - Closing ZkClient...
2018-08-06 22:25:09 INFO ZkEventThread:82 - Terminate ZkClient event thread.
2018-08-06 22:25:09 DEBUG ZkConnection:77 - Closing ZooKeeper connected to localhost:2181
2018-08-06 22:25:09 DEBUG ZooKeeper:673 - Closing session: 0x0
2018-08-06 22:25:09 DEBUG ClientCnxn:1306 - Closing client for session: 0x0
2018-08-06 22:25:10 INFO ClientCnxn:975 - Opening socket connection to server localhost.localdomain/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-08-06 22:25:10 DEBUG ClientCnxn:1086 - An exception was thrown while closing send thread for session 0x0 : Connection refused
2018-08-06 22:25:10 DEBUG ClientCnxnSocketNIO:203 - Ignoring exception during shutdown input
java.nio.channels.ClosedChannelException
at sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:780)
at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:399)
at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:200)
at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1185)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1122)
2018-08-06 22:25:10 DEBUG ClientCnxnSocketNIO:210 - Ignoring exception during shutdown output
java.nio.channels.ClosedChannelException
at sun.nio.ch.SocketChannelImpl.shutdownOutput(SocketChannelImpl.java:797)
at sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:407)
at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:207)
at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1185)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1122)
2018-08-06 22:25:10 DEBUG ClientCnxn:1290 - Disconnecting client for session: 0x0
2018-08-06 22:25:10 INFO ZooKeeper:684 - Session: 0x0 closed
2018-08-06 22:25:10 DEBUG ZkClient:932 - Closing ZkClient...done
2018-08-06 22:25:10 INFO ClientCnxn:512 - EventThread shut down

而且,在日志中,它说

ClientCnxn:975 - Opening socket connection to server localhost.localdomain/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)

这意味着它是否正在尝试连接 localhost.localdomain?

请帮我解决。

最佳答案

我也有类似的问题。我在zoo.cfg(C:\kafka_folder\zookeeper-3.5.4\conf)中配置了以下参数,错误消失了。

admin.enableServer=true
admin.serverPort=9990

或者试试这个 ZkClient zkClient = new ZkClient("localhost:9091", 5000, 5000, ZKStringSerializer$.MODULE$);

人们也会在kafka-unit或kafka-junit(集成测试)中遇到此错误。在这种情况下,您必须使用kafka-client依赖版本1.0.2(其他版本不支持kafka-unit或kafka-junit)。

 <dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>

关于java - 无法连接到本地主机上的 Zookeeper :2181,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51718544/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com