当前位置:   article > 正文

KAFKA 命令_kafka 命令文件路径

kafka 命令文件路径

在kafka安装的目录下执行

bin/kafka-server-start.sh  -daemon config/server.properties 

(注意server.properties 的目录和当前所在目录)

以下是通过脚本启动kafka集群

#!/bin/bash

case $1  in
"start")
     for  i  in 192.168.37.131  192.168.37.132  192.168.37.133  192.168.37.134
     do 
          echo  "-----启动 $i kafka------"
          ssh $i  "/var/dalong/kafka/bin/kafka-server-start.sh  -daemon /var/dalong/kafka/config/server.properties"
      done
;;
"start")
     for  i  in 192.168.37.131  192.168.37.132  192.168.37.133  192.168.37.134
     do 
          echo  "-----停止 $i kafka------"
          ssh $i  "/var/dalong/kafka/bin/kafka-server-stop.sh "
      done
;;
esac

连接上kafka

列出

bin/kafka-topics.sh  --bootstrap-server 192.168.37.133:9092  --list

创建

bin/kafka-topics.sh  --bootstrap-server 192.168.37.133:9092  --topic first  --create  --partitions 1 --replication-factor  3

bin/kafka-topics.sh  --bootstrap-server 192.168.37.133:9092  --topic first  --describe

消息生产:

kafka-console-producer.sh  --bootstrap-server  192.168.37.132:9092   --topic first

消息消费:
kafka-console-consumer.sh  --bootstrap-server  192.168.37.132:9092  --topic first

历史消息

kafka-console-consumer.sh  --bootstrap-server  192.168.37.132:9092  --topic first --from-beginning

查看消息组信息

kafka-consumer-groups.sh --bootstrap-server 192.168.37.131:9092 --list
查看分组详情

kafka-consumer-groups.sh --bootstrap-server 192.168.37.131:9092  --describe --group XXDD3

退役节点 节点数据转移

{
  "topics":[
   {"topic":"six"}
  ],
  "version":1
}

kafka-reassign-partitions.sh --bootstrap-server 192.168.37.133:9092   --topics-to-move.json  --broker-list "0,2"  --generate

  1. [root@k8s-master01 datas]# kafka-reassign-partitions.sh --bootstrap-server 192.168.37.133:9092 --topics-to-move-json-file topics-to-move.json --broker-list "0,2" --generate
  2. Current partition replica assignment
  3. {"version":1,"partitions":[{"topic":"six","partition":0,"replicas":[0,1],"log_dirs":["any","any"]},{"topic":"six","partition":1,"replicas":[2,0],"log_dirs":["any","any"]},{"topic":"six","partition":2,"replicas":[1,2],"log_dirs":["any","any"]}]}
  4. Proposed partition reassignment configuration
  5. {"version":1,"partitions":[{"topic":"six","partition":0,"replicas":[0,2],"log_dirs":["any","any"]},{"topic":"six","partition":1,"replicas":[2,0],"log_dirs":["any","any"]},{"topic":"six","partition":2,"replicas":[0,2],"log_dirs":["any","any"]}]}

将以下内容保存为文件 命名为increase-replication-factor.json

{"version":1,"partitions":[{"topic":"six","partition":0,"replicas":[0,2],"log_dirs":["any","any"]},{"topic":"six","partition":1,"replicas":[2,0],"log_dirs":["any","any"]},{"topic":"six","partition":2,"replicas":[0,2],"log_dirs":["any","any"]}]}

再执行计划

 kafka-reassign-partitions.sh --bootstrap-server 192.168.37.133:9092   --reassignment-json-file increase-replication-factor.json --execute
执行计划前分区情况

执行计划后分区情况

 

 

kafka启动报错

kafka启动报错:【Cluster ID】不匹配的问题 - 灰信网(软件开发博客聚合)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/557067
推荐阅读
相关标签
  

闽ICP备14008679号