kafka offset

topic

  • 创建主题
sh /opt/kafka/bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --create --topic yf_mysoft_prd --partitions 2 --replication-factor 1
  • 查看所有主题
sh /opt/kafka/bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --list
  • 查看所有主题
sh /opt/kafka/bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --list

配置offset

  • kafka指定topic和partition设置offset
sh /usr/local/kafka/bin/kafka-consumer-groups.sh \
    --bootstrap-server 127.0.0.1:9092            \
    --reset-offsets                              \
    --to-offset  270623312                       \
    --topic topic_01:1                   \
    --group group_id                          \
    --execute

生产

消费

  • 消费主题数据
sh /opt/kafka/bin/kafka-console-consumer.sh --zookeeper 127.0.0.1:2181 --topic yf_mysoft_prd --from-beginning
  • 指定topic、partition、offset的消息

./kafka-console-consumer.sh        \
--bootstrap-server localhost:9092  \
--topic mycommunity_prod           \
--partition 1                      \
--max-messages 1                   \
--offset 296638215                 \
|jq .

posted @ 2018-05-02 13:34  chenzechao  阅读(123)  评论(0)    收藏  举报