简体   繁体   中英

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

Error while fetching metadata with correlation id 74 : {topicC=LEADER_NOT_AVAILABLE} when I send news to a topic.

Here are my codes: I create some containers at docker, just use jdk image.

three zookeeper containers

zookeeper00 , zookeeper01 , zookeeper02

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 ...

three kafka containers

kafka00 , kafka01 , kafka02

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

I added 192.168.153.131 database_host in windows' hosts file. 192.168.153.131 is my centos IP

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

and then

docker exec -it kafka00 bash

I created a topic, but when I sended some messages, it throwed 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)
...

and when I send message in java, it throws the same error too.

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}

Could you please point out the problem, thank you!

I solve the problem by adding another port listening. here are my 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

from https://stackoverflow.com/a/55649654/10417592

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM