Apache kafka 如何从带有特定偏移量的卡夫卡主题中获取消息
我们有一个HDP集群,有3名卡夫卡经纪人(来自hortonworks) 我们希望运行kafka控制台消费者,以便从主题中获取一条具有特定偏移量的消息Apache kafka 如何从带有特定偏移量的卡夫卡主题中获取消息,apache-kafka,kafka-consumer-api,hdp,Apache Kafka,Kafka Consumer Api,Hdp,我们有一个HDP集群,有3名卡夫卡经纪人(来自hortonworks) 我们希望运行kafka控制台消费者,以便从主题中获取一条具有特定偏移量的消息 /usr/hdp/current/kafka-broker/bin/kafka-console-consumer.sh --zookeeper zoo01:2181 --topic lopet.lo.pm--partition 0 --offset 34537263 --max-messages 1 但我们得到了以下结果: 我们错在哪里 Usi
/usr/hdp/current/kafka-broker/bin/kafka-console-consumer.sh --zookeeper zoo01:2181 --topic lopet.lo.pm--partition 0 --offset 34537263 --max-messages 1
但我们得到了以下结果:
我们错在哪里
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].
Partition-offset based consumption is supported in the new consumer only.
Option Description
------ -----------
--blacklist <blacklist> Blacklist of topics to exclude from
consumption.
--bootstrap-server <server to connect REQUIRED (unless old consumer is
to> used): The server to connect to.
--consumer-property <consumer_prop> A mechanism to pass user-defined
properties in the form key=value to
the consumer.
--consumer.config <config file> Consumer config properties file. Note
that [consumer-property] takes
precedence over this config.
--csv-reporter-enabled If set, the CSV metrics reporter will
be enabled
--delete-consumer-offsets If specified, the consumer path in
zookeeper is deleted when starting up
--enable-systest-events Log lifecycle events of the consumer
in addition to logging consumed
messages. (This is specific for
system tests.)
--formatter <class> The name of a class to use for
formatting kafka messages for
display. (default: kafka.tools.
DefaultMessageFormatter)
--from-beginning If the consumer does not already have
an established offset to consume
from, start with the earliest
message present in the log rather
than the latest message.
--key-deserializer <deserializer for
key>
--max-messages <Integer: num_messages> The maximum number of messages to
consume before exiting. If not set,
consumption is continual.
--metrics-dir <metrics directory> If csv-reporter-enable is set, and
this parameter isset, the csv
metrics will be outputed here
--new-consumer Use the new consumer implementation.
This is the default.
--offset <consume offset> The offset id to consume from (a non-
negative number), or 'earliest'
which means from beginning, or
'latest' which means from end
(default: latest)
不推荐将ConsoleConsumer与旧使用者一起使用,并将在未来的主要版本中删除。考虑使用新的用户通过[引导服务器]而不是[ZooKeal]。
仅在新使用者中支持基于分区偏移量的使用。
选项说明
------ -----------
--黑名单要从中排除的主题的黑名单
消费。
--引导服务器(已使用):要连接到的服务器。
--使用者属性传递用户定义属性的机制
格式为key=value to的属性
消费者。
--consumer.config消费者配置属性文件。注
(消费性房地产)需要
优先于此配置。
--csv报告器启用如果设置,csv度量报告器将
启用
--删除使用者偏移如果指定,则在
启动时将删除zookeeper
--启用systest事件记录使用者的生命周期事件
除了日志记录之外
信息。(这是针对
系统测试。)
--格式化程序要用于的类的名称
设置卡夫卡消息的格式
展示。(默认值:kafka.tools。
DefaultMessageFormatter)
--从一开始,如果消费者还没有
已建立的消耗补偿
从最早的开始
日志中存在消息,而不是
而不是最新的消息。
--密钥反序列化器
--最大消息要发送的最大消息数
在退出前消费。如果没有设置,
消费是持续的。
--如果设置了csv报告器启用,则为metrics dir,以及
此参数设置为csv
指标将在此处输出
--新使用者使用新使用者实现。
这是默认设置。
--偏移要从中使用的偏移id(非-
负数),或“最早”
这意味着从一开始,或者
“最新的”,意思是从末尾开始
(默认值:最新版本)
仅在新消费者中支持基于分区偏移的消费
kafka控制台消费者
应使用--引导服务器
,如警告所述
而且您在--分区之前缺少一个空格
但除此之外,——分区x——偏移量y
是正确的
全权指挥
kafka-console-consumer \
--bootstrap-server kafka0:9092 \
--topic lopet.lo.pm \
--partition 0 \
--offset 34537263 \
--max-messages 1
如果您想安装卡夫卡,使用卡夫卡是另一种选择
仅在新消费者中支持基于分区偏移的消费
kafka控制台消费者
应使用--引导服务器
,如警告所述
而且您在--分区之前缺少一个空格
但除此之外,——分区x——偏移量y
是正确的
全权指挥
kafka-console-consumer \
--bootstrap-server kafka0:9092 \
--topic lopet.lo.pm \
--partition 0 \
--offset 34537263 \
--max-messages 1
使用卡夫卡塔特是另一种选择,如果您想安装它,因为这些字段不用于该目的,请告诉我正确的语法是什么?在stright中,这是不可能的,因此我需要从CLI中排除---max messages 1?因为这些字段不用于该目的。请告诉我正确的语法是什么?在stright中,它不是可能的话,我需要从CLI中排除----max消息1?