我使用以下Kafka Docker 形象:https://hub.docker.com/r/wurstmeister/kafka/
我可以使用以下属性启动apache kafka:
<KAFKA_ADVERTISED_HOST_NAME>${local.ip}</KAFKA_ADVERTISED_HOST_NAME>
<KAFKA_ADVERTISED_PORT>${kafka.port}/KAFKA_ADVERTISED_PORT>
<KAFKA_ZOOKEEPER_CONNECT>zookeeper:2181</KAFKA_ZOOKEEPER_CONNECT>
<KAFKA_MESSAGE_MAX_BYTES>15000000</KAFKA_MESSAGE_MAX_BYTES>
但我在尝试将消息发送到主题时看到以下警告:
WARN 9248 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Error while fetching metadata with correlation id 4 : {post.sent=LEADER_NOT_AVAILABLE}
我在网上看到几篇文章,说这个问题可能和老物业有关,比如 KAFKA_ADVERTISED_HOST_NAME
以及 KAFKA_ADVERTISED_PORT
我应该重新配置 KAFKA_ADVERTISED_LISTENERS
以及 KAFKA_LISTENERS
. 但是当我启动具有以下属性的kafka容器时:
<KAFKA_ADVERTISED_LISTENERS>PLAINTEXT://${local.ip}:${kafka.port}</KAFKA_ADVERTISED_LISTENERS>
<KAFKA_LISTENERS>PLAINTEXT://${local.ip}:${kafka.port}</KAFKA_LISTENERS>
<KAFKA_ZOOKEEPER_CONNECT>zookeeper:2181</KAFKA_ZOOKEEPER_CONNECT>
<KAFKA_MESSAGE_MAX_BYTES>15000000</KAFKA_MESSAGE_MAX_BYTES>
我的应用程序无法连接到Kafka:
2018-08-25 16:20:57.407 INFO 17440 --- [ main] o.a.kafka.common.utils.AppInfoParser : Kafka version : 1.1.0
2018-08-25 16:20:57.408 INFO 17440 --- [ main] o.a.kafka.common.utils.AppInfoParser : Kafka commitId : fdcf75ea326b8e07
2018-08-25 16:20:58.513 WARN 17440 --- [| adminclient-1] org.apache.kafka.clients.NetworkClient : [AdminClient clientId=adminclient-1] Connection to node -1 could not be established. Broker may not be available.
2018-08-25 16:20:59.567 WARN 17440 --- [| adminclient-1] org.apache.kafka.clients.NetworkClient : [AdminClient clientId=adminclient-1] Connection to node -1 could not be established. Broker may not be available.
如何正确地重新配置docker kafka以便能够使用 KAFKA_ADVERTISED_LISTENERS
以及 KAFKA_LISTENERS
?
暂无答案!
目前还没有任何答案,快来回答吧!