I have a two-nodes Kafka cluster (EC2 instances) where each node is used as a separate broker. When I run a producer on the leader instance with the following command:
kafka-console-producer.sh --broker-list localhost:9092 --topic test
I get the following errors.
test message [2017-01-09 13:22:39,483] WARN Error while fetching metadata with correlation id 0 : {test=UNKNOWN_TOPIC_OR_PARTITION} (org.apache.kafka.clients.NetworkClient) [2017-01-09 13:22:39,562] WARN Error while fetching metadata with correlation id 1 : {test=UNKNOWN_TOPIC_OR_PARTITION} (org.apache.kafka.clients.NetworkClient) [2017-01-09 13:22:39,663] WARN Error while fetching metadata with correlation id 2 : {test=UNKNOWN_TOPIC_OR_PARTITION} (org.apache.kafka.clients.NetworkClient) ...
Listing the topics with kafka-topics.sh
shows that the topic exists.
The description of the topic with:
kafka-topics.sh --zookeeper localhost:2181 --describe --topic test
returns
Topic:test PartitionCount:8 ReplicationFactor:1 Configs:
Topic: test Partition: 0 Leader: 1 Replicas: 1 Isr: 1
Topic: test Partition: 1 Leader: 2 Replicas: 2 Isr: 2
Topic: test Partition: 2 Leader: 1 Replicas: 1 Isr: 1
Topic: test Partition: 3 Leader: 2 Replicas: 2 Isr: 2
Topic: test Partition: 4 Leader: 1 Replicas: 1 Isr: 1
Topic: test Partition: 5 Leader: 2 Replicas: 2 Isr: 2
Topic: test Partition: 6 Leader: 1 Replicas: 1 Isr: 1
Topic: test Partition: 7 Leader: 2 Replicas: 2 Isr: 2
I am using Kafka 0.10.1.1.
server.properties
file contains:
listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://0.0.0.0:9092
port=9092
host.name=kafka-node1(kafka-node1 for the second host)
advertised.host.name=kafka-node1(kafka-node2 for the second host)
advertised.port=9092
When I try to produce messages from the second host I get the message below:
WARN Got error produce response with correlation id 1 on topic-partition test-4, retrying (2 attempts left). Error: NOT_LEADER_FOR_PARTITION (org.apache.kafka.clients.producer.internals.Sender) ....
Can anyone please help?
When publishing a message, I get Unknown Topic Or Partition: the request is for a topic or partition that does not exist on this broker, event though it should create the message by default, as far as I understand the README.md. It worked before, when I was using the exact same setup on NixOS (until I switched to Arch Linux yesterday).
While the topic is a logical concept in Kafka, a partition is the smallest storage unit that holds a subset of records owned by a topic. Each partition is a single log file where records are written to it in an append-only fashion. When talking about the content inside a partition, I will use the terms record and message interchangeably.
While the topic is a logical concept in Kafka, a partition is the smallest storage unit that holds a subset of records owned by a topic. Each partition is a single log file where records are written to it in an append-only fashion.
Each partition is a single log file where records are written to it in an append-only fashion. When talking about the content inside a partition, I will use the terms record and message interchangeably. The records in the partitions are each assigned a sequential identifier called the offset, which is unique for each record within the partition.
If you are getting UNKNOWN_TOPIC_OR_PARTITION
then add the below properties to server.properties
file :
listeners=PLAINTEXT://host.name:port
advertised.listeners=PLAINTEXT://host.name:port
in my cases values were as follows:
listeners=PLAINTEXT://localhost:9092
advertised.listeners=PLAINTEXT://localhost:9092
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With