组协调员不可用-Kafka [英] The group coordinator is not available-Kafka

查看:21
本文介绍了组协调员不可用-Kafka的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在给kafka写topic时,报错:Offset commit failed:

When I am write a topic to kafka,there is an error:Offset commit failed:

2016-10-29 14:52:56.387 INFO [nioEventLoopGroup-3-1][org.apache.kafka.common.utils.AppInfoParser$AppInfo:82] - Kafka version : 0.9.0.1
2016-10-29 14:52:56.387 INFO [nioEventLoopGroup-3-1][org.apache.kafka.common.utils.AppInfoParser$AppInfo:83] - Kafka commitId : 23c69d62a0cabf06
2016-10-29 14:52:56.409 ERROR [nioEventLoopGroup-3-1][org.apache.kafka.clients.consumer.internals.ConsumerCoordinator$DefaultOffsetCommitCallback:489] - Offset commit failed.
org.apache.kafka.common.errors.GroupCoordinatorNotAvailableException: The group coordinator is not available.
2016-10-29 14:52:56.519 WARN [kafka-producer-network-thread | producer-1][org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater:582] - Error while fetching metadata with correlation id 0 : {0085000=LEADER_NOT_AVAILABLE}
2016-10-29 14:52:56.612 WARN [pool-6-thread-1][org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater:582] - Error while fetching metadata with correlation id 1 : {0085000=LEADER_NOT_AVAILABLE}

当使用命令创建一个新主题时,就可以了.

When create a new topic using command,it is ok.

./kafka-topics.sh --zookeeper localhost:2181 --create --topic test1 --partitions 1 --replication-factor 1 --config max.message.bytes=64000 --config flush.messages=1

这是使用Java的生产者代码:

This is the producer code using Java:

public void create() {
        Properties props = new Properties();
        props.clear();
        String producerServer = PropertyReadHelper.properties.getProperty("kafka.producer.bootstrap.servers");
        String zookeeperConnect = PropertyReadHelper.properties.getProperty("kafka.producer.zookeeper.connect");
        String metaBrokerList = PropertyReadHelper.properties.getProperty("kafka.metadata.broker.list");
        props.put("bootstrap.servers", producerServer);
        props.put("zookeeper.connect", zookeeperConnect);//声明ZooKeeper
        props.put("metadata.broker.list", metaBrokerList);//声明kafka broker
        props.put("acks", "all");
        props.put("retries", 0);
        props.put("batch.size", 1000);
        props.put("linger.ms", 10000);
        props.put("buffer.memory", 10000);
        props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        producer = new KafkaProducer<String, String>(props);
    }

哪里错了?

推荐答案

我遇到了类似的问题.问题是当您启动 Kafka 代理时,有一个与之关联的属性KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR".如果您使用的是单节点集群,请确保将此属性设置为值1".由于其默认值为 3.此更改解决了我的问题.(您可以在 Kafka.properties 文件中查看该值)注意:我使用的是 confluent kafka 4.0.0 版的基础镜像 (confluentinc/cp-kafka:4.0.0)

I faced a similar issue. The problem was when you start your Kafka broker there is a property associated with it, "KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR". If you are working with a single node cluster make sure you set this property with the value '1'. As its default value is 3. This change resolved my problem. (you can check the value in Kafka.properties file) Note: I was using base image of confluent kafka version 4.0.0 ( confluentinc/cp-kafka:4.0.0)

这篇关于组协调员不可用-Kafka的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆