yml中配置了bootstrap-servers: 服务器地址:9092,但是连接时却报了
Connection to node -1 (localhost/127.0.0.1:9092) could not be established.
17:23:08.731 [kafka-admin-client-thread | adminclient-1] WARN o.a.k.c.NetworkClient - [processDisconnection,782] - [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
17:23:11.738 [kafka-admin-client-thread | adminclient-1] WARN o.a.k.c.NetworkClient - [processDisconnection,782] - [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
17:23:14.889 [kafka-admin-client-thread | adminclient-1] WARN o.a.k.c.NetworkClient - [processDisconnection,782] - [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
17:23:18.115 [kafka-admin-client-thread | adminclient-1] WARN o.a.k.c.NetworkClient - [processDisconnection,782] - [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
17:23:21.010 [kafka-admin-client-thread | adminclient-1] WARN o.a.k.c.NetworkClient - [processDisconnection,782] - [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
17:23:21.355 [kafka-admin-client-thread | adminclient-1] INFO o.a.k.c.a.i.AdminMetadataManager - [updateFailed,235] - [AdminClient clientId=adminclient-1] Metadata update failed
org.apache.kafka.common.errors.TimeoutException: Call(callName=fetchMetadata, deadlineMs=1687685001348, tries=1, nextAllowedTryMs=1687685001449) timed out at 1687685001349 after 1 attempt(s)
Caused by: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: fetchMetadata
17:23:21.369 [restartedMain] ERROR o.s.k.c.KafkaAdmin - [error,149] - Could not configure topics
org.springframework.kafka.KafkaException: Timed out waiting to get existing topics; nested exception is java.util.concurrent.TimeoutException
chat给我的回复如下,通过一些列检查我确定了在服务器上,kafka没有问题
最后还是从一篇博客中的第一句话得到了答案,博客链接放在最下方
我是docker安装的kafka,因此修改配置文件的步骤如下:
docker exec -it ${CONTAINER ID} /bin/bash
vi /opt/kafka/config/server.properties
advertised.listeners=PLAINTEXT://112.126.74.249:9092