我一直在使用下面的 CMD 从打开纯文本端口的 Kafka 队列中获取最新的偏移量
kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list server:9092 --topic sample_topic --time -1
但是,现在我们只打开了 SSL 端口,所以我尝试将 SSL 详细信息作为属性文件传递
kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list server:9093 --topic sample_topic --time -1 --consumer-config /path/to/file
出现以下错误 -
Exception in thread "main" joptsimple.UnrecognizedOptionException: consumer-config is not a recognized option
如何将 SSL 详细信息传递给此命令?这些是 kafka-run-class.sh kafka.tools.GetOffsetShell 的所有可用参数
--broker-list <String: hostname:and port,...,hostname:port>
--max-wait-ms <Integer: ms>
--offsets <Integer: count>
--partitions <String: partition ids>
--time <Long: timestamp/-1(latest)/-2
--topic <String: topic>
很遗憾kafka.tools.GetOffsetShell
仅支持明文连接。这个工具使用得并不多,也没有人费心去更新它。
根据您的用例,您有以下几种选择:
Use the kafka-consumer-groups.sh
工具:假设您有一个消费者组从该主题消费,该工具显示每个分区的日志结束偏移量
Patch kafka.tools.GetOffsetShell
:通过使用其他工具的逻辑来添加对安全连接的支持相对容易。如果您这样做,请考虑向 Kafka 发送补丁 =)
编写一个调用的小工具Consumer.endOffsets() https://kafka.apache.org/23/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html#endOffsets-java.util.Collection-
- Use
kafka.tools.DumpLogSegments
:作为最后的手段,该工具也可用于查找最后的偏移量
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)