【问题标题】:Kafka consumer not able to consume messages using bootstrap server nameKafka 消费者无法使用引导服务器名称消费消息
【发布时间】:2018-08-29 15:34:21
【问题描述】:

我在使用引导服务器(即 Kafka 服务器)使用消息时遇到问题。知道为什么没有 zookeeper 就不能消费消息吗?

  • 卡夫卡版本:kafka_2.11-1.0.0
  • 动物园管理员版本:kafka_2.11-1.0.0
  • Zookeeper 主机和端口:zkp02.mp.com:2181
  • Kafka 主机和端口:kfk03.mp.com:9092

产生一些信息:

[kfk03.mp.com ~]$ /bnsf/kafka/bin/kafka-console-producer.sh --broker-list kfk03.mp.com:9092 --topic test
>hi
>hi

如果我给–-bootstrap-server,消费者将无法消费消息:

[kfk03.mp.com ~]$
/bnsf/kafka/bin/kafka-console-consumer.sh --bootstrap-server kfk03.mp.com:9092 --topic test --from-beginning

当给定--zookeeper 服务器而不是--bootstrap-server 时,消费者可以消费消息 -:

[kfk03.mp.com ~]$ /bnsf/kafka/bin/kafka-console-consumer.sh --zookeeper zkp02.mp.com:2181 --topic test --from-beginning

Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper].

{"properties": {"messageType": "test", "sentDateTime": "2018-02-25T21:46:00.000+0000"}, "name": "Uttam Anand", "age": 29}
{"properties": {"messageType": "test", "sentDateTime": "2018-02-25T21:46:00.000+0000"}, "name": "Uttam Anand", "age": 29}
{"properties": {"messageType": "test", "sentDateTime": "2018-02-25T21:46:00.000+0000"}, "name": "Uttam Anand", "age": 29}
hi
{"properties": {"messageType": "test", "sentDateTime": "2018-02-25T21:46:00.000+0000"}, "name": "Uttam Anand", "age": 29}
{"properties": {"messageType": "test", "sentDateTime": "2018-02-25T21:46:00.000+0000"}, "name": "Uttam Anand", "age": 29}
{"properties": {"messageType": "test", "sentDateTime": "2018-02-25T21:46:00.000+0000"}, "name": "Uttam Anand", "age": 29}
{"properties": {"messageType": "test", "sentDateTime": "2018-02-25T21:46:00.000+0000"}, "name": "Uttam Anand", "age": 29}
{"properties": {"messageType": "test", "sentDateTime": "2018-02-25T21:46:00.000+0000"}, "name": "Uttam Anand", "age": 29}
hi
hi
uttam
hi
hi
hi
hello
hi
^CProcessed a total of 17 messages

【问题讨论】:

  • server.properties broker.id=0 listeners=PLAINTEXT://:9092 port=9092 host.name=kfk03.mp.com advertised.host.name=kfk03.mp.com Advertisementd.port =9092 num.network.threads=3 num.io.threads=8 socket.send.buffer.bytes=102400 socket.receive.buffer.bytes=102400 socket.request.max.bytes=104857600 log.dirs=/bnsf/ kafka-logs num.partitions=1 num.recovery.threads.per.data.dir=1 log.retention.hours=1440 log.segment.bytes=1073741824 log.retention.check.interval.ms=300000 zookeeper.connect= zkp02.mp.com:2181 zookeeper.connection.timeout.ms=60000
  • 较新版本的 Kafka 将一些进程从 zookeeper 转移到 Kafka 代理中。这使他们能够保护 zookeeper 免受意外中断的影响。虽然在 zookeeper 中保留了主要的操作功能。这就是为什么当 --zookeeper 没有给出 --bootstrap-server 时,你的消费者能够消费消息

标签: apache-kafka producer-consumer


【解决方案1】:

当使用 bootstrap-server 参数从 kafka 消费消息时,连接是通过 kafka 服务器而不是 zookeeper 发生的。 Kafka 代理将偏移详细信息存储在 __consumer_offsets 主题中。

检查 __consumer_offsets 是否存在于您的主题列表中。如果不存在,请检查 kafka 日志以查找原因。

我们遇到了类似的问题。在我们的例子中,由于以下错误,__consumer_offsets 没有被创建:

错误 [KafkaApi-1001] 活动代理的数量“1”不满足偏移主题所需的复制因子“3”(通过“offsets.topic.replication.factor”配置)。

【讨论】:

  • Tnx 获取此提示。这花了我 3 小时的调试时间。再次欢呼
猜你喜欢
  • 2018-10-31
  • 2017-09-23
  • 1970-01-01
  • 1970-01-01
  • 2020-08-11
  • 2019-11-21
  • 1970-01-01
  • 2015-11-25
  • 2019-05-25
相关资源
最近更新 更多