zoukankan      html  css  js  c++  java
  • kafka学习总结

     kafka启动流程:

    创建topic kafka-topics.sh --zookeeper master:2181 --create --partitions 2 --replication-factor 3 --topic bd14first

    查看topic: kafka-topics.sh --zookeeper master:2181 --list

     查看刚刚创建的partition的信息

    kafka-topics.sh --zookeeper master:2181 --describe --topic bd14first

    offset:

    kafka-console-consumer.sh --bootstrap-server master:9092,master:9093 --topic bd14first --offset earliest --partition 0

    执行delete之后使用list指令,查看的topic的状态为

    marked for deletion,此时topic并未被真正的删除
    [root@slaver1 ~]# kafka-topics.sh --zookeeper master:2181 --list
    __consumer_offsets
    bd14first - marked for deletion

     删除topic有两种方式,一种是在配置文件中配置delete.topic.enable为true

    另一种是在zookeeper的客户端中删除对应topic下的partitions:

    [zk: localhost:2181(CONNECTED) 11] rmr /brokers/topics/bd14first/partitions

    kafka的数据丢失:kafka的元数据维护是由kafka自身类完成的,数据丢失出现在读数据的时候

    在从kafka中取出数据的时候,offset会发生变化,取出的数据有可能要进行复杂的计算,计算过程中可能会发生失败的情况

    ,再启动之后offset已经发生变化,会造成数据丢失;解决办法是把kafka的数据自己维护,但是会比较麻烦

    Kafka delivery guarantee

    有这么几种可能的delivery guarantee

    • At most once 消息可能会丢,但绝不会重复传输
    • At least one 消息绝不会丢,但可能会重复传输
    • Exactly once 每条消息肯定会被传输一次且仅传输一次,很多时候这是用户所想要的。

  • 相关阅读:
    5860. 从双倍数组中还原原数组
    5847. 找到所有的农场组
    5846. 找到数组的中间位置
    442. 数组中重复的数据
    1987. 不同的好子序列数目
    1986. 完成任务的最少工作时间段
    1985. 找出数组中的第 K 大整数
    1984. 学生分数的最小差值
    学习内容整合
    spring-DI和spring-mybatis整合
  • 原文地址:https://www.cnblogs.com/zuizui1204/p/7808631.html
Copyright © 2011-2022 走看看