簡體   English   中英

獲取相關 ID 為 74 的元數據時出錯:{topicC=LEADER_NOT_AVAILABLE}

[英]Error while fetching metadata with correlation id 74 : {topicC=LEADER_NOT_AVAILABLE}

Error while fetching metadata with correlation id 74 : {topicC=LEADER_NOT_AVAILABLE}

這是我的代碼:我在 docker 創建了一些容器,只使用 jdk 映像。

三個動物園管理員容器

zookeeper00 00, zookeeper01zookeeper02

dataDir=/data/config
clientPort=2181
maxClientCnxns=0
syncLimit=5
server.1=zookeeper00:2888:3888
server.2=zookeeper01:2888:3888
server.3=zookeeper02:2888:3888
initLimit=10
docker run -d --name zookeeper00 --network andy --network-alias zookeeper00 -p 2181:2181 ...

三個卡夫卡容器

kafka00kafka01kafka02

broker.id=0
listeners=PLAINTEXT://kafka00:9092
advertised.listeners=PLAINTEXT://database_host:9092
zookeeper.connect=zookeeper00:2181,zookeeper01:2181,zookeeper02:2181

我在 windows 的 hosts 文件中添加了192.168.153.131 database_host 192.168.153.131是我的centos IP

docker run -d --name kafka00 --network andy --network-alias kafka00 -p 9092:9092 ...

接着

docker exec -it kafka00 bash

我創建了一個主題,但是當我發送一些消息時,它Error while fetching metadata with correlation id 38 : {topicC=LEADER_NOT_AVAILABLE}

root@2c9e266d16a2:/# bash /data/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper00:2181 --replication-factor 2 --partitions 2 --topic topicC
Created topic topicC.
root@0613111ca4db:/# bash /data/kafka/bin/kafka-topics.sh --zookeeper zookeeper00:2181 --describe --topic topicC
Topic:topicC    PartitionCount:2        ReplicationFactor:2     Configs:
        Topic: topicC   Partition: 0    Leader: 2       Replicas: 2,0   Isr: 2
        Topic: topicC   Partition: 1    Leader: 1       Replicas: 0,1   Isr: 1
root@0613111ca4db:/# bash /data/kafka/bin/kafka-console-producer.sh --broker-list kafka00:9092 --topic topicC
>test message
[2019-09-02 09:13:16,969] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 38 : {topicC=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2019-09-02 09:13:17,073] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 39 : {topicC=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2019-09-02 09:13:17,182] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 40 : {topicC=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
...

當我在java中發送消息時,它也會拋出同樣的錯誤。

final Properties p = new Properties();
p.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,"DATABASE_HOST:9092,DATABASE_HOST:9093,DATABASE_HOST:9094");
p.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
p.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,StringSerializer.class);
p.put(ProducerConfig.CLIENT_ID_CONFIG,"producer-aa-1");
p.put(ProducerConfig.ACKS_CONFIG,"all");
producer = new KafkaProducer<>(p);
producer.send(new ProducerRecord<>(topicName, "a04", "test-msg-a04"));
Sending metadata request (type=MetadataRequest, topics=topicC) to node DATABASE_HOST:9093 (id: -2 rack: null)
Error while fetching metadata with correlation id 4 : {topicC=LEADER_NOT_AVAILABLE}

能否指出問題所在,謝謝!

我通過添加另一個端口監聽解決了這個問題。 這是我的server.properties

broker.id=1
listener.security.protocol.map=INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
advertised.listeners=INSIDE://kafka00:9092,OUTSIDE://database_host:19090
listeners=INSIDE://:9092,OUTSIDE://:19090
inter.broker.listener.name=INSIDE
zookeeper.connect=zookeeper00:2181,zookeeper01:2181,zookeeper02:2181

來自https://stackoverflow.com/a/55649654/10417592

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM