sartions
sartions

Reputation: 123

ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException

I've a 2-node cluster with 2 kafka-broker (1 in each) but when I try to generate a kafka-topic with replication factor = 2:

bin/kafka-topics.sh --create --zookeeper bigdata:2181 --replication-factor 2 --partitions 1 --topic programaCsd

I'm getting the error:

Error while executing topic command : replication factor: 2 larger than available brokers: 1
[2017-09-14 10:12:43,872] ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: replication factor: 2 larger than available brokers: 1
 (kafka.admin.TopicCommand$)

In ambari I can see both kafka-brokers correctly installed and working.

Some idea why is this happening?

Thanks.

Upvotes: 1

Views: 6397

Answers (2)

sartions
sartions

Reputation: 123

Finally the solution was to completely remove kafka service and brokers and add them again with both brokers at the same time with the desired configuration. After deploying, you can change broker id in each node in /kafka-logs/meta.properties.

Before reinstalling kafka, it's better to delete all topics in the system so that there would be no invalid leaders or replicas.

Upvotes: 0

TobiSH
TobiSH

Reputation: 2913

Sounds like your kafka brokers are not working together as a cluster. You can check this by having a closer look at your zookeeper:

Use the zookeeper shell: bin/zookeeper-shell.sh bigdata:2181

To list all brooker ids: ls /brokers/ids

You should see something like "[1001, 1002]" depending on how you set the brookerids at the server.properties (see property broker.id).

If you get just one id than your broker don't know each other.

Upvotes: 2

Related Questions