Mark
Mark

Reputation: 5622

Replication Factor Error when starting Kafka consumer

I am seeing the following error on repeat when starting a Kafka consumer:

Number of alive brokers '1' does not meet the required replication factor '3' for the offsets topic

My Kafka consumer config is as follows:

    final Properties props = new Properties();
    props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
    props.put(ConsumerConfig.GROUP_ID_CONFIG, "verifi");
    props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, Class.forName("org.apache.kafka.common.serialization.StringDeserializer"));
    props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, Class.forName("org.apache.kafka.common.serialization.StringDeserializer"));
    props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");

    final Consumer<String, String> consumer = new KafkaConsumer<>(props);

How do I correct this error?

Upvotes: 0

Views: 982

Answers (1)

Mark
Mark

Reputation: 5622

The solution was to configure offsets.topic.replication.factor to equal 1 in my Kafka configuration. The default is 3.

I happen to be running Kafka in Docker, so to set it, I just added the following environment variable:

KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

Upvotes: 3

Related Questions