LearningKafka学习笔记(七) - 18965050/learning-kafka GitHub Wiki


  • Kafka管理工具
  • Kafka集群镜像
  • 和其他工具集成

Kafka管理工具

  • 关闭broker server(这个命令似乎不太好用,会抛出异常.可使用kill -15替代 )

     bin/kafka-run-class.sh kafka.admin.ShutdownBroker --zookeeper <zookeeper_host:port/namespace> --broker <brokerID> --num.retries 3 --retry.interval.ms 100
    
  • broker均衡的分布分区复制(partition replica)

     bin/kafka-preferred-replica-election.sh --zookeeper <zookeeper_host:port/namespace>
    

    可通过如下命令查看broker分区复制情况

     bin/kafka-preferred-replica-election.sh --zookeeper <zookeeper_host:port/namespace> --path-to-json-file topicPartitionList.json
    

添加broker

  • 重新分区: kafka-reassignpartitions.sh,其有三种使用模式
    • generate:将特定topic的所有分区移植到新的broker
    • execute:根据用户提供的分区文件(--reassignment-json-file)进行分区
    • verify: 确认分区状态

主题管理

  • 创建主题
bin/kafka-topics.sh --create --zookeeper localhost:2181chroot --replication-factor 3 --partitions 10 --topic kafkatopic
  • 更新主题
bin/kafka-topics.sh --alter --zookeeper localhost:2181/chroot --partitions 20 --topic kafkatopic
  • 删除主题
bin/kafka-topics.sh --delete --zookeeper localhost:2181/chroot --topic kafkatopic
  • 配置主题参数
bin/kafka-topics.sh --alter --zookeeper localhost:2181/chroot --topic kafkatopic --config <key>=<value>
  • 删除主题参数
bin/kafka-topics.sh --alter --zookeeper localhost:2181/chroot --topic kafkatopic --deleteconfig <key>=<value>
  • 列表主题
bin/kafka-topics.sh --list --zookeeper localhost:2181

Kafka集群镜像

集群镜像用于将复制原有的kafka集群. kafka-storm

⚠️ **GitHub.com Fallback** ⚠️